OSDN Git Service

for gcc 2.95.4
authortsutsumi <>
Sun, 5 Oct 2003 11:29:59 +0000 (11:29 +0000)
committertsutsumi <>
Sun, 5 Oct 2003 11:29:59 +0000 (11:29 +0000)
src/ccunit/CCUnitList.c
src/ccunit/CCUnitPrintSuite.c
src/ccunit/CCUnitReadSuite.c
src/ccunit/CCUnitTestCase.c
src/ccunit/CCUnitTestCase.h
src/ccunit/CCUnitTestFixture.h
src/ccunit/CCUnitTestSuite.h

index 441de54..c640cdc 100755 (executable)
@@ -144,9 +144,10 @@ bool ccunit_hasNextListIterator (struct CCUnitListIterator* it)
 
 void* ccunit_nextListIterator (struct CCUnitListIterator* it)
 {
+  void* contents;
   if (!ccunit_hasNextListIterator (it))
     return NULL;
-  void* contents = it->current->contents;
+  contents = it->current->contents;
   it->current = it->current->next;
   return contents;
 }
index 2361e37..b6335e3 100644 (file)
@@ -100,21 +100,20 @@ static void printPrototypes (FILE* ofp, _CCUnitTestSuiteDef* suitedef)
 }
 
 static inline void printTestFunc (FILE* ofp,
-                                 const char* leadspc,
                                  _CCUnitFuncDef* fndef)
 {
-  fprintf (ofp, "%s{\n", leadspc);
+  fprintf (ofp, "  {\n");
   if (!fndef)
-    fprintf (ofp, "%s  NULL, NULL, NULL\n", leadspc);
+    fprintf (ofp, "    NULL, NULL, NULL\n");
   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);
+            "    \"%s\",\n"
+            "    \"%s\",\n"
+            "    %s\n",
+            fndef->name,
+            fndef->desc,
+            fndef->name);
+  fprintf (ofp, "  },\n");
 }
 
 /**
@@ -126,12 +125,22 @@ static inline void printTestFunc (FILE* ofp,
 static void printFixture  (FILE* ofp, _CCUnitTestFixtureDef* fxdef)
 {
   static int fxid = 0;
+  CCUnitListIterator fnitor;
+  _CCUnitFuncDef* fndef;
   if (!fxdef->testdef.idname)
     {
       fxdef->testdef.idname = calloc (1, 8);
       fxid ++;
       sprintf (fxdef->testdef.idname, "fx_%03d", fxid);
     }
+  fprintf (ofp, "static CCUnitTestFunc %s_cases[] = {\n", fxdef->testdef.idname);
+  ccunit_initListIterator (&fxdef->testCases, &fnitor);
+  while ((fndef = ccunit_nextListIterator (&fnitor)) != NULL)
+    {
+      printTestFunc (ofp, fndef);
+    }
+  printTestFunc (ofp, NULL);
+  fputs ("};\n\n", ofp);
   fprintf (ofp,
           "static CCUnitTestFixtureDfn %s = {\n"
           "  { %s },\n"
@@ -139,20 +148,10 @@ static void printFixture  (FILE* ofp, _CCUnitTestFixtureDef* fxdef)
           fxdef->testdef.idname,
           ccunitTypeNames[fxdef->testdef.type],
           !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)
-      {
-       printTestFunc (ofp, "    ", fndef);
-      }
-    printTestFunc (ofp, "    ", NULL);
-  }
-  fputs ("  }\n};\n\n", ofp);
+  printTestFunc (ofp, fxdef->setUp);
+  printTestFunc (ofp, fxdef->tearDown);
+  fprintf (ofp, "  %s_cases,\n", fxdef->testdef.idname);
+  fputs ("};\n\n", ofp);
 }
 
 /**
@@ -183,21 +182,23 @@ static void printSuite (FILE* ofp, const char* name, _CCUnitTestSuiteDef* suite)
       else
        ;
     }
+  fprintf (ofp, "static CCUnitTestDfn* %s_test[] = {\n", suite->testdef.idname);
+  ccunit_initListIterator (&suite->testdefs, &itor);
+  while ((testdef = ccunit_nextListIterator (&itor)) != NULL)
+    {
+      fprintf (ofp, "    &%s.test,\n", testdef->idname);
+    }
+  fputs ("    NULL,\n};\n\n", ofp);
   fprintf (ofp,
           "static CCUnitTestSuiteDfn %s = {\n"
           "  { %s },\n"
           "  \"%s\",\n"
-          "  {\n",
+          "  %s_test\n",
           suite->testdef.idname,
           ccunitTypeNames[suite->testdef.type],
-          !suite->testdef.name ? "" : suite->testdef.name);
-  ccunit_initListIterator (&suite->testdefs, &itor);
-  while ((testdef = ccunit_nextListIterator (&itor)) != NULL)
-    {
-      fprintf (ofp, "    &%s.test,\n", testdef->idname);
-    }
-  fputs ("    NULL,\n  },\n", ofp);
-  fputs ("};\n", ofp);
+          !suite->testdef.name ? "" : suite->testdef.name,
+          suite->testdef.idname);
+  fputs ("};\n\n", ofp);
 }
 
 /*
index f4811f9..4d5d761 100644 (file)
@@ -132,9 +132,10 @@ static _CCUnitTestDef* addTestDef (_CCUnitTestSuiteDef* suite,
 static inline _CCUnitTestDef* addTestSuiteDef (_CCUnitTestSuiteDef* suite,
                                               _CCUnitTestSuiteDef* test)
 {
+  const char* name;
   if (!suite || !test)
     return NULL;
-  const char* name = test->testdef.name;
+  name = test->testdef.name;
   if (!name)
     name = "";
   ccunit_log ("add test suite: %s", name);
@@ -151,9 +152,10 @@ static inline _CCUnitTestDef* addTestSuiteDef (_CCUnitTestSuiteDef* suite,
 static inline _CCUnitTestDef* addTestFixtureDef (_CCUnitTestSuiteDef* suite,
                                                 _CCUnitTestFixtureDef* test)
 {
+  const char* name;
   if (!suite || !test)
     return NULL;
-  const char* name = test->testdef.name;
+  name = test->testdef.name;
   if (!name)
     name = "";
   ccunit_log ("add test fixture: %s", name);
@@ -263,6 +265,10 @@ static struct _CCUnitLine line;
 static int readline ()
 {
   static const size_t MIN_LINE_BUF_LEN = 512;
+  char* insertAt;
+  size_t restSize;
+  char* sp;
+  char* tail;
   /* buffer hasn't been allocate yet */
   if (line.str == NULL)
     {
@@ -274,15 +280,16 @@ static int readline ()
   /* shrink to minimum size */
   else if (line.capacity > MIN_LINE_BUF_LEN)
     {
+      char* str;
       line.capacity = MIN_LINE_BUF_LEN;
-      char* str = realloc (line.str, line.capacity);
+      str = realloc (line.str, line.capacity);
       if (str)
        line.str = str;
     }
-  char* insertAt = line.str;
-  size_t restSize = line.capacity;
+  insertAt = line.str;
+  restSize = line.capacity;
   line.length = 0;
-  char* sp = 0;
+  sp = 0;
   while ((sp = fgets (insertAt, restSize, line.ifp)) != NULL)
     {
       line.length += strlen(insertAt);
@@ -311,7 +318,7 @@ static int readline ()
   if (!sp)
     return 0;
   /* chomp CR/LF */
-  char* tail = line.str + line.length - 1;
+  tail = line.str + line.length - 1;
   while (*tail == '\n' || *tail == '\r')       /* for dos/mac? */
     {
       line.length --;
index 155cbb1..4e8be5a 100755 (executable)
@@ -24,7 +24,7 @@
  * TestCase module implementation.
  */
 
-#include <CCUnit/CCUnitTestCase.h>
+#include <ccunit/CCUnitTestCase.h>
 
 /**
  * @addtogroup CCUnitTestCase
index ee7f803..7c62787 100755 (executable)
@@ -29,7 +29,7 @@
 #ifndef CCUNITTESTCASE_H
 #define CCUNITTESTCASE_H
 
-#include <CCUnit/CCUnitConfig.h>
+#include <ccunit/CCUnitConfig.h>
 
 /**
  * @ingroup CCUnitTestFixture
index 568c9d3..0d7c5c6 100644 (file)
@@ -142,7 +142,7 @@ typedef struct CCUnitTestFixtureDfn
   const char* name;                            /**< test fixture name */
   CCUnitTestFunc setUp;                                /**< setUp function */
   CCUnitTestFunc tearDown;                     /**< tearDown function */
-  CCUnitTestFunc testCases[];                  /**< test cases */
+  CCUnitTestFunc* testCases;                   /**< test cases */
 } CCUnitTestFixtureDfn;
 
 /**
index 68be755..711f02b 100755 (executable)
@@ -66,7 +66,7 @@ typedef struct CCUnitTestSuiteDfn
 {
   CCUnitTestDfn test;              /**< super class */
   const char* name;                /**< test suite name */
-  CCUnitTestDfn* tests[];          /**< added test case/suite list */
+  CCUnitTestDfn** tests;           /**< added test case/suite list */
 } CCUnitTestSuiteDfn;
 
 /**