OSDN Git Service

ctor/dtor was deleted.
authortsntsumi <tsntsumi@users.sourceforge.jp>
Wed, 1 Oct 2003 20:40:15 +0000 (20:40 +0000)
committertsntsumi <tsntsumi@users.sourceforge.jp>
Wed, 1 Oct 2003 20:40:15 +0000 (20:40 +0000)
A common code was collected in the function.

src/ccunit/CCUnitPrintSuite.c

index cecc27e..2361e37 100644 (file)
@@ -82,10 +82,6 @@ static void printPrototypes (FILE* ofp, _CCUnitTestSuiteDef* suitedef)
          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)
@@ -103,7 +99,23 @@ static void printPrototypes (FILE* ofp, _CCUnitTestSuiteDef* suitedef)
   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.
@@ -123,34 +135,22 @@ static void printFixture  (FILE* ofp, _CCUnitTestFixtureDef* fxdef)
   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);
 }