From: tsutsumi <> Date: Sun, 5 Oct 2003 11:29:59 +0000 (+0000) Subject: for gcc 2.95.4 X-Git-Tag: rev-1_0~6 X-Git-Url: http://git.osdn.net/view?p=ccunit%2Fccunit.git;a=commitdiff_plain;h=a1669367a11dc9a7601dd2e0858ad3c9d110fc69;hp=4fb852f0bb17557d2b5e7d4040c4692fe108b995 for gcc 2.95.4 --- diff --git a/src/ccunit/CCUnitList.c b/src/ccunit/CCUnitList.c index 441de54..c640cdc 100755 --- a/src/ccunit/CCUnitList.c +++ b/src/ccunit/CCUnitList.c @@ -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; } diff --git a/src/ccunit/CCUnitPrintSuite.c b/src/ccunit/CCUnitPrintSuite.c index 2361e37..b6335e3 100644 --- a/src/ccunit/CCUnitPrintSuite.c +++ b/src/ccunit/CCUnitPrintSuite.c @@ -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); } /* diff --git a/src/ccunit/CCUnitReadSuite.c b/src/ccunit/CCUnitReadSuite.c index f4811f9..4d5d761 100644 --- a/src/ccunit/CCUnitReadSuite.c +++ b/src/ccunit/CCUnitReadSuite.c @@ -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 --; diff --git a/src/ccunit/CCUnitTestCase.c b/src/ccunit/CCUnitTestCase.c index 155cbb1..4e8be5a 100755 --- a/src/ccunit/CCUnitTestCase.c +++ b/src/ccunit/CCUnitTestCase.c @@ -24,7 +24,7 @@ * TestCase module implementation. */ -#include +#include /** * @addtogroup CCUnitTestCase diff --git a/src/ccunit/CCUnitTestCase.h b/src/ccunit/CCUnitTestCase.h index ee7f803..7c62787 100755 --- a/src/ccunit/CCUnitTestCase.h +++ b/src/ccunit/CCUnitTestCase.h @@ -29,7 +29,7 @@ #ifndef CCUNITTESTCASE_H #define CCUNITTESTCASE_H -#include +#include /** * @ingroup CCUnitTestFixture diff --git a/src/ccunit/CCUnitTestFixture.h b/src/ccunit/CCUnitTestFixture.h index 568c9d3..0d7c5c6 100644 --- a/src/ccunit/CCUnitTestFixture.h +++ b/src/ccunit/CCUnitTestFixture.h @@ -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; /** diff --git a/src/ccunit/CCUnitTestSuite.h b/src/ccunit/CCUnitTestSuite.h index 68be755..711f02b 100755 --- a/src/ccunit/CCUnitTestSuite.h +++ b/src/ccunit/CCUnitTestSuite.h @@ -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; /**