ccunit_log ("fixturdef: %s", fdef->testdef.name);
if (fdef->testdef.name)
fprintf (ofp, "/* test fixture: %s */\n", fdef->testdef.name);
- if (fdef->ctor)
- printPrototype (ofp, "ctor", fdef->ctor);
- if (fdef->dtor)
- printPrototype (ofp, "dtor", fdef->dtor);
if (fdef->setUp)
printPrototype (ofp, "setUp", fdef->setUp);
if (fdef->tearDown)
fputc ('\n', ofp);
}
-#define GETNAME(P) ((!(P) || !((P)->name)) ? "NULL" : (P)->name)
+static inline void printTestFunc (FILE* ofp,
+ const char* leadspc,
+ _CCUnitFuncDef* fndef)
+{
+ fprintf (ofp, "%s{\n", leadspc);
+ if (!fndef)
+ fprintf (ofp, "%s NULL, NULL, NULL\n", leadspc);
+ else
+ fprintf (ofp,
+ "%s \"%s\",\n"
+ "%s \"%s\",\n"
+ "%s %s\n",
+ leadspc, fndef->name,
+ leadspc, fndef->desc,
+ leadspc, fndef->name);
+ fprintf (ofp, "%s},\n", leadspc);
+}
/**
* print test fixture adding function.
fprintf (ofp,
"static CCUnitTestFixtureDfn %s = {\n"
" { %s },\n"
- " \"%s\",\n"
- " %s,\n"
- " %s,\n"
- " %s,\n"
- " %s,\n"
- " {\n",
+ " \"%s\",\n",
fxdef->testdef.idname,
ccunitTypeNames[fxdef->testdef.type],
- GETNAME (&fxdef->testdef),
- GETNAME (fxdef->ctor),
- GETNAME (fxdef->dtor),
- GETNAME (fxdef->setUp),
- GETNAME (fxdef->tearDown));
+ !fxdef->testdef.name ? "NULL" : fxdef->testdef.name);
+ printTestFunc (ofp, " ", fxdef->setUp);
+ printTestFunc (ofp, " ", fxdef->tearDown);
+ fputs (" {\n", ofp);
{
CCUnitListIterator fnitor;
_CCUnitFuncDef* fndef;
ccunit_initListIterator (&fxdef->testCases, &fnitor);
while ((fndef = ccunit_nextListIterator (&fnitor)) != NULL)
{
- fputs (" {\n", ofp);
- fprintf (ofp,
- " \"%s\",\n"
- " \"%s\",\n"
- " %s,\n",
- fndef->name, fndef->desc, fndef->name);
- fputs (" },\n", ofp);
+ printTestFunc (ofp, " ", fndef);
}
- fputs (" { NULL, NULL, NULL }\n", ofp);
+ printTestFunc (ofp, " ", NULL);
}
fputs (" }\n};\n\n", ofp);
}