OSDN Git Service
(root)
/
ccunit
/
ccunit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c64a860
)
Changed to use a global variable though delivered a pointer to the second argument...
author
tsntsumi
<tsntsumi@users.sourceforge.jp>
Sat, 14 Aug 2010 09:14:27 +0000
(09:14 +0000)
committer
tsntsumi
<tsntsumi@users.sourceforge.jp>
Sat, 14 Aug 2010 09:14:27 +0000
(09:14 +0000)
src/ccunit/CCUnitTestFixture.c
patch
|
blob
|
history
diff --git
a/src/ccunit/CCUnitTestFixture.c
b/src/ccunit/CCUnitTestFixture.c
index
217512f
..
da12152
100644
(file)
--- a/
src/ccunit/CCUnitTestFixture.c
+++ b/
src/ccunit/CCUnitTestFixture.c
@@
-32,14
+32,14
@@
#include <setjmp.h>
/**
#include <setjmp.h>
/**
- * run test
fixture
s exception.
+ * run tests exception.
*/
*/
-jmp_buf _ccunit_run_env;
+jmp_buf _ccunit_run
Test
_env;
/**
/**
- * run tests exception
.
+ * run tests exception
*/
*/
-
jmp_buf _ccunit_runTest_env
;
+
CCUnitTestFailure* _ccunit_testFailure
;
extern void _ccunit_startTest (CCUnitTestResult* result,
struct CCUnitTestCase* test);
extern void _ccunit_startTest (CCUnitTestResult* result,
struct CCUnitTestCase* test);
@@
-70,44
+70,45
@@
CCUnitTestCase* ccunit_addNewTestCase (CCUnitTestFixture* fixture,
/*
* Runs the bare test sequence.
*
/*
* Runs the bare test sequence.
*
- * @
throws _ccunit_run_env
+ * @
return failure
*/
*/
-static
void
runTest (CCUnitTestCase* testCase,
- CCUnitTestFunc* setUp,
- CCUnitTestFunc* tearDown,
- CCUnitTestResult* result)
+static
CCUnitTestFailure*
runTest (CCUnitTestCase* testCase,
+
CCUnitTestFunc* setUp,
+
CCUnitTestFunc* tearDown,
+
CCUnitTestResult* result)
{
{
- int failure = 0;
- int runFailure = 0;
+ CCUnitTestFailure* runFailure = NULL;
if (setUp && setUp->runTest)
{
if (setUp && setUp->runTest)
{
- if (
(failure = setjmp (_ccunit_runTest_env)
) == 0)
+ if (
setjmp (_ccunit_runTest_env
) == 0)
setUp->runTest ();
else
{
setUp->runTest ();
else
{
-
((CCUnitTestFailure*)failure)
->testCase = setUp;
-
longjmp (_ccunit_run_env, failure)
;
+
_ccunit_testFailure
->testCase = setUp;
+
return _ccunit_testFailure
;
}
}
}
}
- if (
(runFailure = setjmp (_ccunit_runTest_env)
) == 0)
+ if (
setjmp (_ccunit_runTest_env
) == 0)
{
result->runCount ++;
testCase->runTest ();
}
else
{
result->runCount ++;
testCase->runTest ();
}
else
- ((CCUnitTestFailure*)runFailure)->testCase = testCase;
+ {
+ runFailure = _ccunit_testFailure;
+ runFailure->testCase = testCase;
+ }
if (tearDown && tearDown->runTest)
{
if (tearDown && tearDown->runTest)
{
- if (
(failure = setjmp (_ccunit_runTest_env)
) == 0)
+ if (
setjmp (_ccunit_runTest_env
) == 0)
tearDown->runTest ();
else
{
tearDown->runTest ();
else
{
-
((CCUnitTestFailure*)failure)
->testCase = tearDown;
- ccunit_addFailure (result,
(CCUnitTestFailure*)f
ailure);
+
_ccunit_testFailure
->testCase = tearDown;
+ ccunit_addFailure (result,
_ccunit_testF
ailure);
}
}
}
}
- if (runFailure)
- longjmp (_ccunit_run_env, runFailure);
+ return runFailure;
}
/**
}
/**
@@
-118,18
+119,17
@@
static void runTest (CCUnitTestCase* testCase,
static void run (CCUnitTest* test, CCUnitTestResult* result)
{
CCUnitTestFixture* fixture = (CCUnitTestFixture*)test;
static void run (CCUnitTest* test, CCUnitTestResult* result)
{
CCUnitTestFixture* fixture = (CCUnitTestFixture*)test;
- int failure = 0;
CCUnitListIterator itor;
CCUnitTestCase* testCase;
assert (test->type == ccunitTypeFixture);
ccunit_initListIterator (&fixture->testCases, &itor);
while ((testCase = ccunit_nextListIterator (&itor)) != NULL)
{
CCUnitListIterator itor;
CCUnitTestCase* testCase;
assert (test->type == ccunitTypeFixture);
ccunit_initListIterator (&fixture->testCases, &itor);
while ((testCase = ccunit_nextListIterator (&itor)) != NULL)
{
+ CCUnitTestFailure* failure = NULL;
_ccunit_startTest (result, testCase);
_ccunit_startTest (result, testCase);
- if ((failure = setjmp (_ccunit_run_env)) == 0)
- runTest (testCase, fixture->setUp, fixture->tearDown, result);
- else
- ccunit_addFailure (result, (CCUnitTestFailure*)failure);
+ failure = runTest (testCase, fixture->setUp, fixture->tearDown, result);
+ if (failure)
+ ccunit_addFailure (result, failure);
_ccunit_endTest (result, testCase);
}
}
_ccunit_endTest (result, testCase);
}
}
@@
-143,7
+143,7
@@
static void destroy (CCUnitTest* test)
CCUnitTestFixture* fixture;
assert (test->type == ccunitTypeFixture);
fixture = (CCUnitTestFixture*)test;
CCUnitTestFixture* fixture;
assert (test->type == ccunitTypeFixture);
fixture = (CCUnitTestFixture*)test;
- safe_free (
(char*)
fixture->name);
+ safe_free (fixture->name);
ccunit_deleteTestFunc (fixture->setUp);
ccunit_deleteTestFunc (fixture->tearDown);
ccunit_deleteList (&fixture->testCases,
ccunit_deleteTestFunc (fixture->setUp);
ccunit_deleteTestFunc (fixture->tearDown);
ccunit_deleteList (&fixture->testCases,