Merge pull request #1518 from cgundogan/remove_tabs_tests

converting tabs to spaces in tests (#1439)
This commit is contained in:
Oleg Hahm 2014-07-31 23:06:29 +02:00
commit db2cf8df1a
30 changed files with 492 additions and 492 deletions

View File

@ -38,63 +38,63 @@
void assertImplementationInt(int expected,int actual, long line, const char *file) void assertImplementationInt(int expected,int actual, long line, const char *file)
{ {
char buffer[32]; /*"exp -2147483647 was -2147483647"*/ char buffer[32]; /*"exp -2147483647 was -2147483647"*/
char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/ char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/
stdimpl_strcpy(buffer, "exp "); stdimpl_strcpy(buffer, "exp ");
{ stdimpl_itoa(expected, numbuf, 10); { stdimpl_itoa(expected, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); } stdimpl_strncat(buffer, numbuf, 11); }
stdimpl_strcat(buffer, " was "); stdimpl_strcat(buffer, " was ");
{ stdimpl_itoa(actual, numbuf, 10); { stdimpl_itoa(actual, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); } stdimpl_strncat(buffer, numbuf, 11); }
addFailure(buffer, line, file); addFailure(buffer, line, file);
} }
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file) void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file)
{ {
char buffer[ASSERT_STRING_BUFFER_MAX]; char buffer[ASSERT_STRING_BUFFER_MAX];
#define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */ #define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */
int el; int el;
int al; int al;
if (expected) { if (expected) {
el = stdimpl_strlen(expected); el = stdimpl_strlen(expected);
} else { } else {
el = 4; el = 4;
expected = "null"; expected = "null";
} }
if (actual) { if (actual) {
al = stdimpl_strlen(actual); al = stdimpl_strlen(actual);
} else { } else {
al = 4; al = 4;
actual = "null"; actual = "null";
} }
if (el > exp_act_limit) { if (el > exp_act_limit) {
if (al > exp_act_limit) { if (al > exp_act_limit) {
al = exp_act_limit; al = exp_act_limit;
el = exp_act_limit; el = exp_act_limit;
} else { } else {
int w = exp_act_limit + (exp_act_limit - al); int w = exp_act_limit + (exp_act_limit - al);
if (el > w) { if (el > w) {
el = w; el = w;
} }
} }
} else { } else {
int w = exp_act_limit + (exp_act_limit - el); int w = exp_act_limit + (exp_act_limit - el);
if (al > w) { if (al > w) {
al = w; al = w;
} }
} }
stdimpl_strcpy(buffer, "exp \""); stdimpl_strcpy(buffer, "exp \"");
stdimpl_strncat(buffer, expected, el); stdimpl_strncat(buffer, expected, el);
stdimpl_strcat(buffer, "\" was \""); stdimpl_strcat(buffer, "\" was \"");
stdimpl_strncat(buffer, actual, al); stdimpl_strncat(buffer, actual, al);
stdimpl_strcat(buffer, "\""); stdimpl_strcat(buffer, "\"");
addFailure(buffer, line, file); addFailure(buffer, line, file);
} }

View File

@ -32,40 +32,40 @@
* *
* $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $ * $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $
*/ */
#ifndef __ASSERTIMPL_H__ #ifndef __ASSERTIMPL_H__
#define __ASSERTIMPL_H__ #define __ASSERTIMPL_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/ void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/
void assertImplementationInt(int expected,int actual, long line, const char *file); void assertImplementationInt(int expected,int actual, long line, const char *file);
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file); void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file);
#define TEST_ASSERT_EQUAL_STRING(expected,actual)\ #define TEST_ASSERT_EQUAL_STRING(expected,actual)\
if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;} if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;}
#define TEST_ASSERT_EQUAL_INT(expected,actual)\ #define TEST_ASSERT_EQUAL_INT(expected,actual)\
if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;} if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;}
#define TEST_ASSERT_NULL(pointer)\ #define TEST_ASSERT_NULL(pointer)\
TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.") TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.")
#define TEST_ASSERT_NOT_NULL(pointer)\ #define TEST_ASSERT_NOT_NULL(pointer)\
TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.") TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.")
#define TEST_ASSERT_MESSAGE(condition, message)\ #define TEST_ASSERT_MESSAGE(condition, message)\
if (condition) {} else {TEST_FAIL(message);} if (condition) {} else {TEST_FAIL(message);}
#define TEST_ASSERT(condition)\ #define TEST_ASSERT(condition)\
if (condition) {} else {TEST_FAIL(#condition);} if (condition) {} else {TEST_FAIL(#condition);}
#define TEST_FAIL(message)\ #define TEST_FAIL(message)\
if (0) {} else {addFailure(message,__LINE__,__FILE__);return;} if (0) {} else {addFailure(message,__LINE__,__FILE__);return;}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -32,28 +32,28 @@
* *
* $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $ * $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __HELPERMACRO_H__ #ifndef __HELPERMACRO_H__
#define __HELPERMACRO_H__ #define __HELPERMACRO_H__
#define EMB_UNIT_TESTCASE(ca,sup,tdw,run) \ #define EMB_UNIT_TESTCASE(ca,sup,tdw,run) \
static const TestCase ca = new_TestCase(#ca,sup,tdw,run) static const TestCase ca = new_TestCase(#ca,sup,tdw,run)
#define EMB_UNIT_TESTSUITE(su,array) \ #define EMB_UNIT_TESTSUITE(su,array) \
static const TestSuite su = new_TestSuite(#su,(Test**)array,sizeof(array)/sizeof(array[0])) static const TestSuite su = new_TestSuite(#su,(Test**)array,sizeof(array)/sizeof(array[0]))
#define EMB_UNIT_TESTREFS(tests) \ #define EMB_UNIT_TESTREFS(tests) \
static Test* const tests[] = static Test* const tests[] =
#define EMB_UNIT_ADD_TESTREF(testref) \ #define EMB_UNIT_ADD_TESTREF(testref) \
(Test*) testref (Test*) testref
#define EMB_UNIT_TESTCALLER(caller,sup,tdw,fixtures) \ #define EMB_UNIT_TESTCALLER(caller,sup,tdw,fixtures) \
static const TestCaller caller = new_TestCaller(#caller,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures) static const TestCaller caller = new_TestCaller(#caller,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures)
#define EMB_UNIT_TESTFIXTURES(fixtures) \ #define EMB_UNIT_TESTFIXTURES(fixtures) \
static const TestFixture fixtures[] = static const TestFixture fixtures[] =
#define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \ #define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \
static const RepeatedTest repeater = new_RepeatedTest(test,tmrp) static const RepeatedTest repeater = new_RepeatedTest(test,tmrp)
#endif/*__HELPERMACRO_H__*/ #endif/*__HELPERMACRO_H__*/

View File

@ -37,25 +37,25 @@
char* RepeatedTest_name(RepeatedTest* self) char* RepeatedTest_name(RepeatedTest* self)
{ {
return Test_name(self->test); return Test_name(self->test);
} }
void RepeatedTest_run(RepeatedTest* self,TestResult* result) void RepeatedTest_run(RepeatedTest* self,TestResult* result)
{ {
int i; int i;
Test* test = self->test; Test* test = self->test;
for (i=0; i<self->timesRepeat; i++) { for (i=0; i<self->timesRepeat; i++) {
Test_run(test, result); Test_run(test, result);
} }
} }
int RepeatedTest_countTestCases(RepeatedTest* self) int RepeatedTest_countTestCases(RepeatedTest* self)
{ {
return Test_countTestCases(self->test) * self->timesRepeat; return Test_countTestCases(self->test) * self->timesRepeat;
} }
const TestImplement RepeatedTestImplement = { const TestImplement RepeatedTestImplement = {
(TestNameFunction) RepeatedTest_name, (TestNameFunction) RepeatedTest_name,
(TestRunFunction) RepeatedTest_run, (TestRunFunction) RepeatedTest_run,
(TestCountTestCasesFunction)RepeatedTest_countTestCases, (TestCountTestCasesFunction)RepeatedTest_countTestCases,
}; };

View File

@ -32,25 +32,25 @@
* *
* $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ * $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __REPEATEDTEST_H__ #ifndef __REPEATEDTEST_H__
#define __REPEATEDTEST_H__ #define __REPEATEDTEST_H__
typedef struct __RepeatedTest RepeatedTest; typedef struct __RepeatedTest RepeatedTest;
typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/ typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/
struct __RepeatedTest { struct __RepeatedTest {
TestImplement* isa; TestImplement* isa;
Test* test; Test* test;
int timesRepeat; int timesRepeat;
}; };
extern const TestImplement RepeatedTestImplement; extern const TestImplement RepeatedTestImplement;
#define new_RepeatedTest(test,tmrp)\ #define new_RepeatedTest(test,tmrp)\
{\ {\
(TestImplement*)&RepeatedTestImplement,\ (TestImplement*)&RepeatedTestImplement,\
(Test*)test,\ (Test*)test,\
tmrp,\ tmrp,\
} }
#endif/*__REPEATEDTEST_H__*/ #endif/*__REPEATEDTEST_H__*/

View File

@ -32,34 +32,34 @@
* *
* $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $ * $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TEST_H__ #ifndef __TEST_H__
#define __TEST_H__ #define __TEST_H__
typedef struct __TestResult TestResult; typedef struct __TestResult TestResult;
typedef struct __TestResult* TestResultRef;/*downward compatible*/ typedef struct __TestResult* TestResultRef;/*downward compatible*/
typedef struct __TestImplement TestImplement; typedef struct __TestImplement TestImplement;
typedef struct __TestImplement* TestImplementRef;/*downward compatible*/ typedef struct __TestImplement* TestImplementRef;/*downward compatible*/
typedef char*(*TestNameFunction)(void*); typedef char*(*TestNameFunction)(void*);
typedef void(*TestRunFunction)(void*,TestResult*); typedef void(*TestRunFunction)(void*,TestResult*);
typedef int(*TestCountTestCasesFunction)(void*); typedef int(*TestCountTestCasesFunction)(void*);
struct __TestImplement { struct __TestImplement {
TestNameFunction name; TestNameFunction name;
TestRunFunction run; TestRunFunction run;
TestCountTestCasesFunction countTestCases; TestCountTestCasesFunction countTestCases;
}; };
typedef struct __Test Test; typedef struct __Test Test;
typedef struct __Test* TestRef;/*downward compatible*/ typedef struct __Test* TestRef;/*downward compatible*/
struct __Test { struct __Test {
TestImplement* isa; TestImplement* isa;
}; };
#define Test_name(s) ((Test*)s)->isa->name(s) #define Test_name(s) ((Test*)s)->isa->name(s)
#define Test_run(s,r) ((Test*)s)->isa->run(s,r) #define Test_run(s,r) ((Test*)s)->isa->run(s,r)
#define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s) #define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s)
#endif/*__TEST_H__*/ #endif/*__TEST_H__*/

View File

@ -38,30 +38,30 @@
char* TestCaller_name(TestCaller* self) char* TestCaller_name(TestCaller* self)
{ {
return self->name; return self->name;
} }
void TestCaller_run(TestCaller* self,TestResult* result) void TestCaller_run(TestCaller* self,TestResult* result)
{ {
TestCase cs = new_TestCase(0,0,0,0); TestCase cs = new_TestCase(0,0,0,0);
int i; int i;
cs.setUp= self->setUp; cs.setUp= self->setUp;
cs.tearDown = self->tearDown; cs.tearDown = self->tearDown;
for (i=0; i<self->numberOfFixtuers; i++) { for (i=0; i<self->numberOfFixtuers; i++) {
cs.name = self->fixtuers[i].name; cs.name = self->fixtuers[i].name;
cs.runTest = self->fixtuers[i].test; cs.runTest = self->fixtuers[i].test;
/*run test*/ /*run test*/
Test_run(&cs,result); Test_run(&cs,result);
} }
} }
int TestCaller_countTestCases(TestCaller* self) int TestCaller_countTestCases(TestCaller* self)
{ {
return self->numberOfFixtuers; return self->numberOfFixtuers;
} }
const TestImplement TestCallerImplement = { const TestImplement TestCallerImplement = {
(TestNameFunction) TestCaller_name, (TestNameFunction) TestCaller_name,
(TestRunFunction) TestCaller_run, (TestRunFunction) TestCaller_run,
(TestCountTestCasesFunction)TestCaller_countTestCases, (TestCountTestCasesFunction)TestCaller_countTestCases,
}; };

View File

@ -32,41 +32,41 @@
* *
* $Id: TestCaller.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestCaller.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTCALLER_H__ #ifndef __TESTCALLER_H__
#define __TESTCALLER_H__ #define __TESTCALLER_H__
typedef struct __TestFixture TestFixture; typedef struct __TestFixture TestFixture;
typedef struct __TestFixture* TestFixtureRef;/*downward compatible*/ typedef struct __TestFixture* TestFixtureRef;/*downward compatible*/
struct __TestFixture { struct __TestFixture {
char *name; char *name;
void(*test)(void); void(*test)(void);
}; };
#define new_TestFixture(test) { #test, test } #define new_TestFixture(test) { #test, test }
typedef struct __TestCaller TestCaller; typedef struct __TestCaller TestCaller;
typedef struct __TestCaller* TestCallerRef;/*downward compatible*/ typedef struct __TestCaller* TestCallerRef;/*downward compatible*/
struct __TestCaller { struct __TestCaller {
TestImplement* isa; TestImplement* isa;
char *name; char *name;
void(*setUp)(void); void(*setUp)(void);
void(*tearDown)(void); void(*tearDown)(void);
int numberOfFixtuers; int numberOfFixtuers;
TestFixture *fixtuers; TestFixture *fixtuers;
}; };
extern const TestImplement TestCallerImplement; extern const TestImplement TestCallerImplement;
#define new_TestCaller(name,sup,tdw,numberOfFixtuers,fixtuers)\ #define new_TestCaller(name,sup,tdw,numberOfFixtuers,fixtuers)\
{\ {\
(TestImplement*)&TestCallerImplement,\ (TestImplement*)&TestCallerImplement,\
name,\ name,\
sup,\ sup,\
tdw,\ tdw,\
numberOfFixtuers,\ numberOfFixtuers,\
fixtuers,\ fixtuers,\
} }
#endif/*__TESTCALLER_H__*/ #endif/*__TESTCALLER_H__*/

View File

@ -41,43 +41,43 @@ static TestCase* self_;
char* TestCase_name(TestCase* self) char* TestCase_name(TestCase* self)
{ {
return self->name; return self->name;
} }
void TestCase_run(TestCase* self,TestResult* result) void TestCase_run(TestCase* self,TestResult* result)
{ {
TestResult_startTest(result, (Test*)self); TestResult_startTest(result, (Test*)self);
if (self->setUp) { if (self->setUp) {
self->setUp(); self->setUp();
} }
if (self->runTest) { if (self->runTest) {
TestResult* wr =result_; /*push*/ TestResult* wr =result_; /*push*/
TestCase* ws = self_; /*push*/ TestCase* ws = self_; /*push*/
result_ = result; result_ = result;
self_ = self; self_ = self;
self->runTest(); self->runTest();
result_ = wr; /*pop*/ result_ = wr; /*pop*/
self_ = ws; /*pop*/ self_ = ws; /*pop*/
} }
if (self->tearDown) { if (self->tearDown) {
self->tearDown(); self->tearDown();
} }
TestResult_endTest(result, (Test*)self); TestResult_endTest(result, (Test*)self);
} }
int TestCase_countTestCases(TestCase* self) int TestCase_countTestCases(TestCase* self)
{ {
(void)self; (void)self;
return 1; return 1;
} }
const TestImplement TestCaseImplement = { const TestImplement TestCaseImplement = {
(TestNameFunction) TestCase_name, (TestNameFunction) TestCase_name,
(TestRunFunction) TestCase_run, (TestRunFunction) TestCase_run,
(TestCountTestCasesFunction)TestCase_countTestCases, (TestCountTestCasesFunction)TestCase_countTestCases,
}; };
void addFailure(const char *msg, long line, const char *file) void addFailure(const char *msg, long line, const char *file)
{ {
TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file); TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file);
} }

View File

@ -32,29 +32,29 @@
* *
* $Id: TestCase.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestCase.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTCASE_H__ #ifndef __TESTCASE_H__
#define __TESTCASE_H__ #define __TESTCASE_H__
typedef struct __TestCase TestCase; typedef struct __TestCase TestCase;
typedef struct __TestCase* TestCaseRef;/*compatible embUnit1.0*/ typedef struct __TestCase* TestCaseRef;/*compatible embUnit1.0*/
struct __TestCase { struct __TestCase {
TestImplement* isa; TestImplement* isa;
char *name; char *name;
void(*setUp)(void); void(*setUp)(void);
void(*tearDown)(void); void(*tearDown)(void);
void(*runTest)(void); void(*runTest)(void);
}; };
extern const TestImplement TestCaseImplement; extern const TestImplement TestCaseImplement;
#define new_TestCase(name,setUp,tearDown,runTest)\ #define new_TestCase(name,setUp,tearDown,runTest)\
{\ {\
(TestImplement*)&TestCaseImplement,\ (TestImplement*)&TestCaseImplement,\
name,\ name,\
setUp,\ setUp,\
tearDown,\ tearDown,\
runTest,\ runTest,\
} }
#endif/*__TESTCASE_H__*/ #endif/*__TESTCASE_H__*/

View File

@ -32,31 +32,31 @@
* *
* $Id: TestListener.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestListener.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTLISTENER_H__ #ifndef __TESTLISTENER_H__
#define __TESTLISTENER_H__ #define __TESTLISTENER_H__
typedef struct __TestListnerImplement TestListnerImplement; typedef struct __TestListnerImplement TestListnerImplement;
typedef struct __TestListnerImplement* TestListnerImplementRef;/*downward compatible*/ typedef struct __TestListnerImplement* TestListnerImplementRef;/*downward compatible*/
typedef void(*TestListnerStartTestCallBack)(void*,void*); typedef void(*TestListnerStartTestCallBack)(void*,void*);
typedef void(*TestListnerEndTestCallBack)(void*,void*); typedef void(*TestListnerEndTestCallBack)(void*,void*);
typedef void(*TestListnerAddFailureCallBack)(void*,void*,const char*,int,const char*); typedef void(*TestListnerAddFailureCallBack)(void*,void*,const char*,int,const char*);
struct __TestListnerImplement { struct __TestListnerImplement {
TestListnerStartTestCallBack startTest; TestListnerStartTestCallBack startTest;
TestListnerEndTestCallBack endTest; TestListnerEndTestCallBack endTest;
TestListnerAddFailureCallBack addFailure; TestListnerAddFailureCallBack addFailure;
}; };
/*typedef struct __TestListner TestListner;*/ /*->TestResult.h*/ /*typedef struct __TestListner TestListner;*/ /*->TestResult.h*/
/*typedef struct __TestListner* TestListnerRef;*/ /*->TestResult.h*/ /*typedef struct __TestListner* TestListnerRef;*/ /*->TestResult.h*/
struct __TestListner { struct __TestListner {
TestListnerImplement* isa; TestListnerImplement* isa;
}; };
#define TestListner_startTest(s,t) ((TestListner*)s)->isa->startTest(s,t) #define TestListner_startTest(s,t) ((TestListner*)s)->isa->startTest(s,t)
#define TestListner_endTest(s,t) ((TestListner*)s)->isa->endTest(s,t) #define TestListner_endTest(s,t) ((TestListner*)s)->isa->endTest(s,t)
#define TestListner_addFailure(s,t,m,l,f) ((TestListner*)s)->isa->addFailure(s,t,m,l,f) #define TestListner_addFailure(s,t,m,l,f) ((TestListner*)s)->isa->addFailure(s,t,m,l,f)
#endif/*__TESTLISTENER_H__*/ #endif/*__TESTLISTENER_H__*/

View File

@ -38,30 +38,30 @@
void TestResult_init(TestResult* self,TestListner* listner) void TestResult_init(TestResult* self,TestListner* listner)
{ {
self->runCount = 0; self->runCount = 0;
self->failureCount = 0; self->failureCount = 0;
self->listener = listner; self->listener = listner;
} }
void TestResult_startTest(TestResult* self,Test* test) void TestResult_startTest(TestResult* self,Test* test)
{ {
self->runCount++; self->runCount++;
if (self->listener) { if (self->listener) {
TestListner_startTest(self->listener, test); TestListner_startTest(self->listener, test);
} }
} }
void TestResult_endTest(TestResult* self,Test* test) void TestResult_endTest(TestResult* self,Test* test)
{ {
if (self->listener) { if (self->listener) {
TestListner_endTest(self->listener, test); TestListner_endTest(self->listener, test);
} }
} }
void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file) void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file)
{ {
self->failureCount++; self->failureCount++;
if (self->listener) { if (self->listener) {
TestListner_addFailure(self->listener, test, msg, line, file); TestListner_addFailure(self->listener, test, msg, line, file);
} }
} }

View File

@ -32,38 +32,38 @@
* *
* $Id: TestResult.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestResult.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTRESULT_H__ #ifndef __TESTRESULT_H__
#define __TESTRESULT_H__ #define __TESTRESULT_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*typedef struct __TestResult TestResult;*//* -> Test.h*/ /*typedef struct __TestResult TestResult;*//* -> Test.h*/
/*typedef struct __TestResult* TestResultRef;*//* -> Test.h*/ /*typedef struct __TestResult* TestResultRef;*//* -> Test.h*/
typedef struct __TestListner TestListner; typedef struct __TestListner TestListner;
typedef struct __TestListner* TestListnerRef;/*downward compatible*/ typedef struct __TestListner* TestListnerRef;/*downward compatible*/
struct __TestResult { struct __TestResult {
unsigned short runCount; unsigned short runCount;
unsigned short failureCount; unsigned short failureCount;
TestListner* listener; TestListner* listener;
}; };
#define new_TestResult(listener)\ #define new_TestResult(listener)\
{\ {\
0,\ 0,\
0,\ 0,\
(TestListner*)listener,\ (TestListner*)listener,\
} }
void TestResult_init(TestResult* self,TestListner* listner); void TestResult_init(TestResult* self,TestListner* listner);
void TestResult_startTest(TestResult* self,Test* test); void TestResult_startTest(TestResult* self,Test* test);
void TestResult_endTest(TestResult* self,Test* test); void TestResult_endTest(TestResult* self,Test* test);
void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file); void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -47,7 +47,7 @@ static void TestRunner_startTest(TestListner* self,Test* test)
{ {
(void)self; (void)self;
(void)test; (void)test;
stdimpl_print("."); stdimpl_print(".");
} }
static void TestRunner_endTest(TestListner* self,Test* test) static void TestRunner_endTest(TestListner* self,Test* test)
@ -59,63 +59,63 @@ static void TestRunner_endTest(TestListner* self,Test* test)
static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file) static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file)
{ {
(void)self; (void)self;
stdimpl_print("\n"); stdimpl_print("\n");
stdimpl_print(Test_name(root_)); stdimpl_print(Test_name(root_));
stdimpl_print("."); stdimpl_print(".");
stdimpl_print(Test_name(test)); stdimpl_print(Test_name(test));
{ {
char buf[16]; char buf[16];
stdimpl_print(" ("); stdimpl_print(" (");
stdimpl_print(file); stdimpl_print(file);
stdimpl_print(" "); stdimpl_print(" ");
stdimpl_itoa(line, buf, 10); stdimpl_itoa(line, buf, 10);
stdimpl_print(buf); stdimpl_print(buf);
stdimpl_print(") "); stdimpl_print(") ");
} }
stdimpl_print(msg); stdimpl_print(msg);
stdimpl_print("\n"); stdimpl_print("\n");
TestRunnerHadErrors = 1; TestRunnerHadErrors = 1;
} }
static const TestListnerImplement TestRunnerImplement = { static const TestListnerImplement TestRunnerImplement = {
(TestListnerStartTestCallBack) TestRunner_startTest, (TestListnerStartTestCallBack) TestRunner_startTest,
(TestListnerEndTestCallBack) TestRunner_endTest, (TestListnerEndTestCallBack) TestRunner_endTest,
(TestListnerAddFailureCallBack) TestRunner_addFailure, (TestListnerAddFailureCallBack) TestRunner_addFailure,
}; };
static const TestListner testrunner_ = { static const TestListner testrunner_ = {
(TestListnerImplement*)&TestRunnerImplement, (TestListnerImplement*)&TestRunnerImplement,
}; };
void TestRunner_start(void) void TestRunner_start(void)
{ {
TestResult_init(&result_, (TestListner*)&testrunner_); TestResult_init(&result_, (TestListner*)&testrunner_);
} }
void TestRunner_runTest(Test* test) void TestRunner_runTest(Test* test)
{ {
root_ = test; root_ = test;
Test_run(test, &result_); Test_run(test, &result_);
} }
void TestRunner_end(void) void TestRunner_end(void)
{ {
char buf[16]; char buf[16];
if (result_.failureCount) { if (result_.failureCount) {
stdimpl_print("\nrun "); stdimpl_print("\nrun ");
stdimpl_itoa(result_.runCount, buf, 10); stdimpl_itoa(result_.runCount, buf, 10);
stdimpl_print(buf); stdimpl_print(buf);
stdimpl_print(" failures "); stdimpl_print(" failures ");
stdimpl_itoa(result_.failureCount, buf, 10); stdimpl_itoa(result_.failureCount, buf, 10);
stdimpl_print(buf); stdimpl_print(buf);
stdimpl_print("\n"); stdimpl_print("\n");
TestRunnerHadErrors = 1; TestRunnerHadErrors = 1;
} else { } else {
stdimpl_print("\nOK ("); stdimpl_print("\nOK (");
stdimpl_itoa(result_.runCount, buf, 10); stdimpl_itoa(result_.runCount, buf, 10);
stdimpl_print(buf); stdimpl_print(buf);
stdimpl_print(" tests)\n"); stdimpl_print(" tests)\n");
} }
} }

View File

@ -32,10 +32,10 @@
* *
* $Id: TestRunner.h,v 1.6 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestRunner.h,v 1.6 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTRUNNER_H__ #ifndef __TESTRUNNER_H__
#define __TESTRUNNER_H__ #define __TESTRUNNER_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -45,7 +45,7 @@ void TestRunner_end(void);
extern int TestRunnerHadErrors; extern int TestRunnerHadErrors;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -37,33 +37,33 @@
char* TestSuite_name(TestSuite* self) char* TestSuite_name(TestSuite* self)
{ {
return self->name; return self->name;
} }
void TestSuite_run(TestSuite* self,TestResult* result) void TestSuite_run(TestSuite* self,TestResult* result)
{ {
if (self->tests) { if (self->tests) {
for (int i = 0; i < self->numberOfTests; i++) { for (int i = 0; i < self->numberOfTests; i++) {
Test* test = self->tests[i]; Test* test = self->tests[i];
Test_run(test, result); Test_run(test, result);
} }
} }
} }
int TestSuite_countTestCases(TestSuite* self) int TestSuite_countTestCases(TestSuite* self)
{ {
int count = 0; int count = 0;
if (self->tests) { if (self->tests) {
for (int i = 0; i < self->numberOfTests; i++) { for (int i = 0; i < self->numberOfTests; i++) {
Test* test = self->tests[i]; Test* test = self->tests[i];
count += Test_countTestCases(test); count += Test_countTestCases(test);
} }
} }
return count; return count;
} }
const TestImplement TestSuiteImplement = { const TestImplement TestSuiteImplement = {
(TestNameFunction) TestSuite_name, (TestNameFunction) TestSuite_name,
(TestRunFunction) TestSuite_run, (TestRunFunction) TestSuite_run,
(TestCountTestCasesFunction)TestSuite_countTestCases, (TestCountTestCasesFunction)TestSuite_countTestCases,
}; };

View File

@ -32,27 +32,27 @@
* *
* $Id: TestSuite.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ * $Id: TestSuite.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/ */
#ifndef __TESTSUITE_H__ #ifndef __TESTSUITE_H__
#define __TESTSUITE_H__ #define __TESTSUITE_H__
typedef struct __TestSuite TestSuite; typedef struct __TestSuite TestSuite;
typedef struct __TestSuite* TestSuiteRef;/*downward compatible*/ typedef struct __TestSuite* TestSuiteRef;/*downward compatible*/
struct __TestSuite { struct __TestSuite {
TestImplement* isa; TestImplement* isa;
char *name; char *name;
int numberOfTests; int numberOfTests;
Test** tests; Test** tests;
}; };
extern const TestImplement TestSuiteImplement; extern const TestImplement TestSuiteImplement;
#define new_TestSuite(name,tests,numberOfTests)\ #define new_TestSuite(name,tests,numberOfTests)\
{\ {\
(TestImplement*)&TestSuiteImplement,\ (TestImplement*)&TestSuiteImplement,\
name,\ name,\
numberOfTests,\ numberOfTests,\
tests,\ tests,\
} }
#endif/*__TESTSUITE_H__*/ #endif/*__TESTSUITE_H__*/

View File

@ -35,14 +35,14 @@
#ifndef __CONFIG_H__ #ifndef __CONFIG_H__
#define __CONFIG_H__ #define __CONFIG_H__
/* #define NO_STDIO_PRINTF*/ /* #define NO_STDIO_PRINTF*/
#ifdef NO_STDIO_PRINTF #ifdef NO_STDIO_PRINTF
extern void stdimpl_print(const char *string); extern void stdimpl_print(const char *string);
#else #else
#include<stdio.h> #include<stdio.h>
#define stdimpl_print(s) printf("%s", s); #define stdimpl_print(s) printf("%s", s);
#endif #endif
#define ASSERT_STRING_BUFFER_MAX 64 #define ASSERT_STRING_BUFFER_MAX 64
#endif/*__CONFIG_H__*/ #endif/*__CONFIG_H__*/

View File

@ -32,8 +32,8 @@
* *
* $Id: embUnit.h,v 1.4 2004/02/10 16:16:19 arms22 Exp $ * $Id: embUnit.h,v 1.4 2004/02/10 16:16:19 arms22 Exp $
*/ */
#ifndef __EMBUNIT_H__ #ifndef __EMBUNIT_H__
#define __EMBUNIT_H__ #define __EMBUNIT_H__
#include <embUnit/Test.h> #include <embUnit/Test.h>
#include <embUnit/TestCase.h> #include <embUnit/TestCase.h>

View File

@ -36,106 +36,106 @@
char* stdimpl_strcpy(char *dst, const char *src) char* stdimpl_strcpy(char *dst, const char *src)
{ {
char *start = dst; char *start = dst;
char c; char c;
do { do {
c = *src; c = *src;
*dst = c; *dst = c;
src++; src++;
dst++; dst++;
} while (c); } while (c);
return start; return start;
} }
char* stdimpl_strcat(char *dst, const char *src) char* stdimpl_strcat(char *dst, const char *src)
{ {
char *start = dst; char *start = dst;
char c; char c;
do { do {
c = *dst; c = *dst;
dst++; dst++;
} while (c); } while (c);
dst--; dst--;
do { do {
c = *src; c = *src;
*dst = c; *dst = c;
src++; src++;
dst++; dst++;
} while (c); } while (c);
return start; return start;
} }
char* stdimpl_strncat(char *dst, const char *src,unsigned int count) char* stdimpl_strncat(char *dst, const char *src,unsigned int count)
{ {
char *start = dst; char *start = dst;
char c; char c;
do { do {
c = *dst; c = *dst;
dst++; dst++;
} while (c); } while (c);
dst--; dst--;
if (count) { if (count) {
do { do {
c = *src; c = *src;
*dst = c; *dst = c;
src++; src++;
dst++; dst++;
count--; count--;
} while (c && count); } while (c && count);
*dst = '\0'; *dst = '\0';
} }
return start; return start;
} }
int stdimpl_strlen(const char *str) int stdimpl_strlen(const char *str)
{ {
const char *estr = str; const char *estr = str;
char c; char c;
do { do {
c = *estr; c = *estr;
estr++; estr++;
} while (c); } while (c);
return ((int)(estr - str - 1)); return ((int)(estr - str - 1));
} }
int stdimpl_strcmp(const char *s1, const char *s2) int stdimpl_strcmp(const char *s1, const char *s2)
{ {
char c1,c2; char c1,c2;
do { do {
c1 = *s1++; c1 = *s1++;
c2 = *s2++; c2 = *s2++;
} while ((c1) && (c2) && (c1==c2)); } while ((c1) && (c2) && (c1==c2));
return c1 - c2; return c1 - c2;
} }
static char* _xtoa(unsigned long v,char *string, int r, int is_neg) static char* _xtoa(unsigned long v,char *string, int r, int is_neg)
{ {
char *start = string; char *start = string;
char buf[33],*p; char buf[33],*p;
p = buf; p = buf;
do { do {
*p++ = "0123456789abcdef"[(v % r) & 0xf]; *p++ = "0123456789abcdef"[(v % r) & 0xf];
} while (v /= r); } while (v /= r);
if (is_neg) { if (is_neg) {
*p++ = '-'; *p++ = '-';
} }
do { do {
*string++ = *--p; *string++ = *--p;
} while (buf != p); } while (buf != p);
*string = '\0'; *string = '\0';
return start; return start;
} }
char* stdimpl_itoa(int v,char *string,int r) char* stdimpl_itoa(int v,char *string,int r)
{ {
if ((r == 10) && (v < 0)) { if ((r == 10) && (v < 0)) {
return _xtoa((unsigned long)(-v), string, r, 1); return _xtoa((unsigned long)(-v), string, r, 1);
} }
return _xtoa((unsigned long)(v), string, r, 0); return _xtoa((unsigned long)(v), string, r, 0);
} }

View File

@ -32,15 +32,15 @@
* *
* $Id: stdImpl.h,v 1.4 2004/02/10 16:15:25 arms22 Exp $ * $Id: stdImpl.h,v 1.4 2004/02/10 16:15:25 arms22 Exp $
*/ */
#ifndef __STDIMPL_H__ #ifndef __STDIMPL_H__
#define __STDIMPL_H__ #define __STDIMPL_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
char* stdimpl_strcpy(char *s1, const char *s2); char* stdimpl_strcpy(char *s1, const char *s2);
@ -50,7 +50,7 @@ int stdimpl_strlen(const char *str);
int stdimpl_strcmp(const char *s1, const char *s2); int stdimpl_strcmp(const char *s1, const char *s2);
char* stdimpl_itoa(int v,char *string,int r); char* stdimpl_itoa(int v,char *string,int r);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -64,7 +64,7 @@ static void CompilerOutputter_printFailure(OutputterRef self,TestRef test,char *
{ {
(void)self; (void)self;
(void)runCount; (void)runCount;
fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg); fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg);
} }
static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result) static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result)
@ -74,19 +74,19 @@ static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef re
} }
static const OutputterImplement CompilerOutputterImplement = { static const OutputterImplement CompilerOutputterImplement = {
(OutputterPrintHeaderFunction) CompilerOutputter_printHeader, (OutputterPrintHeaderFunction) CompilerOutputter_printHeader,
(OutputterPrintStartTestFunction) CompilerOutputter_printStartTest, (OutputterPrintStartTestFunction) CompilerOutputter_printStartTest,
(OutputterPrintEndTestFunction) CompilerOutputter_printEndTest, (OutputterPrintEndTestFunction) CompilerOutputter_printEndTest,
(OutputterPrintSuccessfulFunction) CompilerOutputter_printSuccessful, (OutputterPrintSuccessfulFunction) CompilerOutputter_printSuccessful,
(OutputterPrintFailureFunction) CompilerOutputter_printFailure, (OutputterPrintFailureFunction) CompilerOutputter_printFailure,
(OutputterPrintStatisticsFunction) CompilerOutputter_printStatistics, (OutputterPrintStatisticsFunction) CompilerOutputter_printStatistics,
}; };
static const Outputter CompilerOutputter = { static const Outputter CompilerOutputter = {
(OutputterImplementRef)&CompilerOutputterImplement, (OutputterImplementRef)&CompilerOutputterImplement,
}; };
OutputterRef CompilerOutputter_outputter(void) OutputterRef CompilerOutputter_outputter(void)
{ {
return (OutputterRef)&CompilerOutputter; return (OutputterRef)&CompilerOutputter;
} }

View File

@ -32,8 +32,8 @@
* *
* $Id: CompilerOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ * $Id: CompilerOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
*/ */
#ifndef __COMPILEROUTPUTTER_H__ #ifndef __COMPILEROUTPUTTER_H__
#define __COMPILEROUTPUTTER_H__ #define __COMPILEROUTPUTTER_H__
#include "Outputter.h" #include "Outputter.h"

View File

@ -32,13 +32,13 @@
* *
* $Id: Outputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ * $Id: Outputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
*/ */
#ifndef __OUTPUTTER_H__ #ifndef __OUTPUTTER_H__
#define __OUTPUTTER_H__ #define __OUTPUTTER_H__
#include <embUnit/embUnit.h> #include <embUnit/embUnit.h>
typedef struct __OutputterImplement OutputterImplement; typedef struct __OutputterImplement OutputterImplement;
typedef struct __OutputterImplement* OutputterImplementRef; typedef struct __OutputterImplement* OutputterImplementRef;
typedef void(*OutputterPrintHeaderFunction)(void*); typedef void(*OutputterPrintHeaderFunction)(void*);
typedef void(*OutputterPrintStartTestFunction)(void*,TestRef); typedef void(*OutputterPrintStartTestFunction)(void*,TestRef);
@ -49,26 +49,26 @@ typedef void(*OutputterPrintStatisticsFunction)(void*,TestResultRef);
struct __OutputterImplement { struct __OutputterImplement {
OutputterPrintHeaderFunction printHeader; OutputterPrintHeaderFunction printHeader;
OutputterPrintStartTestFunction printStartTest; OutputterPrintStartTestFunction printStartTest;
OutputterPrintEndTestFunction printEndTest; OutputterPrintEndTestFunction printEndTest;
OutputterPrintSuccessfulFunction printSuccessful; OutputterPrintSuccessfulFunction printSuccessful;
OutputterPrintFailureFunction printFailure; OutputterPrintFailureFunction printFailure;
OutputterPrintStatisticsFunction printStatistics; OutputterPrintStatisticsFunction printStatistics;
}; };
typedef struct __Outputter Outputter; typedef struct __Outputter Outputter;
typedef struct __Outputter* OutputterRef; typedef struct __Outputter* OutputterRef;
struct __Outputter { struct __Outputter {
OutputterImplementRef isa; OutputterImplementRef isa;
}; };
#define Outputter_printHeader(o) (o)->isa->printHeader(o) #define Outputter_printHeader(o) (o)->isa->printHeader(o)
#define Outputter_printStartTest(o,t) (o)->isa->printStartTest(o,t) #define Outputter_printStartTest(o,t) (o)->isa->printStartTest(o,t)
#define Outputter_printEndTest(o,t) (o)->isa->printEndTest(o,t) #define Outputter_printEndTest(o,t) (o)->isa->printEndTest(o,t)
#define Outputter_printSuccessful(o,t,c) (o)->isa->printSuccessful(o,t,c) #define Outputter_printSuccessful(o,t,c) (o)->isa->printSuccessful(o,t,c)
#define Outputter_printFailure(o,t,m,l,f,c) (o)->isa->printFailure(o,t,m,l,f,c) #define Outputter_printFailure(o,t,m,l,f,c) (o)->isa->printFailure(o,t,m,l,f,c)
#define Outputter_printStatistics(o,r) (o)->isa->printStatistics(o,r) #define Outputter_printStatistics(o,r) (o)->isa->printStatistics(o,r)
#endif/*__OUTPUTTER_H__*/ #endif/*__OUTPUTTER_H__*/

View File

@ -43,7 +43,7 @@ static void TextOutputter_printHeader(OutputterRef self)
static void TextOutputter_printStartTest(OutputterRef self,TestRef test) static void TextOutputter_printStartTest(OutputterRef self,TestRef test)
{ {
(void)self; (void)self;
fprintf(stdout,"- %s\n",Test_name(test)); fprintf(stdout,"- %s\n",Test_name(test));
} }
static void TextOutputter_printEndTest(OutputterRef self,TestRef test) static void TextOutputter_printEndTest(OutputterRef self,TestRef test)
@ -55,39 +55,39 @@ static void TextOutputter_printEndTest(OutputterRef self,TestRef test)
static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount)
{ {
(void)self; (void)self;
fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test)); fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test));
} }
static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount)
{ {
(void)self; (void)self;
fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg); fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg);
} }
static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result) static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result)
{ {
(void)self; (void)self;
if (result->failureCount) { if (result->failureCount) {
fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount); fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount);
} else { } else {
fprintf(stdout,"\nOK (%d tests)\n",result->runCount); fprintf(stdout,"\nOK (%d tests)\n",result->runCount);
} }
} }
static const OutputterImplement TextOutputterImplement = { static const OutputterImplement TextOutputterImplement = {
(OutputterPrintHeaderFunction) TextOutputter_printHeader, (OutputterPrintHeaderFunction) TextOutputter_printHeader,
(OutputterPrintStartTestFunction) TextOutputter_printStartTest, (OutputterPrintStartTestFunction) TextOutputter_printStartTest,
(OutputterPrintEndTestFunction) TextOutputter_printEndTest, (OutputterPrintEndTestFunction) TextOutputter_printEndTest,
(OutputterPrintSuccessfulFunction) TextOutputter_printSuccessful, (OutputterPrintSuccessfulFunction) TextOutputter_printSuccessful,
(OutputterPrintFailureFunction) TextOutputter_printFailure, (OutputterPrintFailureFunction) TextOutputter_printFailure,
(OutputterPrintStatisticsFunction) TextOutputter_printStatistics, (OutputterPrintStatisticsFunction) TextOutputter_printStatistics,
}; };
static const Outputter TextOutputter = { static const Outputter TextOutputter = {
(OutputterImplementRef)&TextOutputterImplement, (OutputterImplementRef)&TextOutputterImplement,
}; };
OutputterRef TextOutputter_outputter(void) OutputterRef TextOutputter_outputter(void)
{ {
return (OutputterRef)&TextOutputter; return (OutputterRef)&TextOutputter;
} }

View File

@ -32,8 +32,8 @@
* *
* $Id: TextOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ * $Id: TextOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
*/ */
#ifndef __TEXTOUTPUTTER_H__ #ifndef __TEXTOUTPUTTER_H__
#define __TEXTOUTPUTTER_H__ #define __TEXTOUTPUTTER_H__
#include "Outputter.h" #include "Outputter.h"

View File

@ -35,7 +35,7 @@
#include "TextOutputter.h" #include "TextOutputter.h"
#include "TextUIRunner.h" #include "TextUIRunner.h"
/* Private /* Private
*/ */
static TestResult result_; static TestResult result_;
static OutputterRef outputterRef_ = 0; static OutputterRef outputterRef_ = 0;
@ -45,63 +45,63 @@ static void TextUIRunner_startTest(TestListnerRef self,TestRef test)
{ {
(void)self; (void)self;
(void)test; (void)test;
wasfailure_ = 0; wasfailure_ = 0;
} }
static void TextUIRunner_endTest(TestListnerRef self,TestRef test) static void TextUIRunner_endTest(TestListnerRef self,TestRef test)
{ {
(void)self; (void)self;
if (!wasfailure_) if (!wasfailure_)
Outputter_printSuccessful(outputterRef_,test,result_.runCount); Outputter_printSuccessful(outputterRef_,test,result_.runCount);
} }
static void TextUIRunner_addFailure(TestListnerRef self,TestRef test,char *msg,int line,char *file) static void TextUIRunner_addFailure(TestListnerRef self,TestRef test,char *msg,int line,char *file)
{ {
(void)self; (void)self;
wasfailure_ = 1; wasfailure_ = 1;
Outputter_printFailure(outputterRef_,test,msg,line,file,result_.runCount); Outputter_printFailure(outputterRef_,test,msg,line,file,result_.runCount);
} }
static const TestListnerImplement TextUIRunnerImplement = { static const TestListnerImplement TextUIRunnerImplement = {
(TestListnerStartTestCallBack) TextUIRunner_startTest, (TestListnerStartTestCallBack) TextUIRunner_startTest,
(TestListnerEndTestCallBack) TextUIRunner_endTest, (TestListnerEndTestCallBack) TextUIRunner_endTest,
(TestListnerAddFailureCallBack) TextUIRunner_addFailure, (TestListnerAddFailureCallBack) TextUIRunner_addFailure,
}; };
static const TestListner testuirunner_ = { static const TestListner testuirunner_ = {
(TestListnerImplement*)&TextUIRunnerImplement, (TestListnerImplement*)&TextUIRunnerImplement,
}; };
/* Public /* Public
*/ */
void TextUIRunner_setOutputter(OutputterRef outputter) void TextUIRunner_setOutputter(OutputterRef outputter)
{ {
outputterRef_ = outputter; outputterRef_ = outputter;
} }
void TextUIRunner_startWithOutputter(OutputterRef outputter) void TextUIRunner_startWithOutputter(OutputterRef outputter)
{ {
TestResult_init(&result_, (TestListnerRef)&testuirunner_); TestResult_init(&result_, (TestListnerRef)&testuirunner_);
TextUIRunner_setOutputter(outputter); TextUIRunner_setOutputter(outputter);
Outputter_printHeader(outputter); Outputter_printHeader(outputter);
} }
void TextUIRunner_start(void) void TextUIRunner_start(void)
{ {
if (!outputterRef_) if (!outputterRef_)
outputterRef_ = TextOutputter_outputter(); outputterRef_ = TextOutputter_outputter();
TextUIRunner_startWithOutputter(outputterRef_); TextUIRunner_startWithOutputter(outputterRef_);
} }
void TextUIRunner_runTest(TestRef test) void TextUIRunner_runTest(TestRef test)
{ {
Outputter_printStartTest(outputterRef_,test); Outputter_printStartTest(outputterRef_,test);
Test_run(test, &result_); Test_run(test, &result_);
Outputter_printEndTest(outputterRef_,test); Outputter_printEndTest(outputterRef_,test);
} }
void TextUIRunner_end(void) void TextUIRunner_end(void)
{ {
Outputter_printStatistics(outputterRef_,&result_); Outputter_printStatistics(outputterRef_,&result_);
} }

View File

@ -32,8 +32,8 @@
* *
* $Id: TextUIRunner.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $ * $Id: TextUIRunner.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $
*/ */
#ifndef __TEXTUIRUNNER_H__ #ifndef __TEXTUIRUNNER_H__
#define __TEXTUIRUNNER_H__ #define __TEXTUIRUNNER_H__
#include "Outputter.h" #include "Outputter.h"

View File

@ -40,76 +40,76 @@ static char *stylesheet_;
static void XMLOutputter_printHeader(OutputterRef self) static void XMLOutputter_printHeader(OutputterRef self)
{ {
(void)self; (void)self;
fprintf(stdout,"<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n"); fprintf(stdout,"<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n");
if (stylesheet_) if (stylesheet_)
fprintf(stdout,"<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_); fprintf(stdout,"<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_);
fprintf(stdout,"<TestRun>\n"); fprintf(stdout,"<TestRun>\n");
} }
static void XMLOutputter_printStartTest(OutputterRef self,TestRef test) static void XMLOutputter_printStartTest(OutputterRef self,TestRef test)
{ {
(void)self; (void)self;
fprintf(stdout,"<%s>\n",Test_name(test)); fprintf(stdout,"<%s>\n",Test_name(test));
} }
static void XMLOutputter_printEndTest(OutputterRef self,TestRef test) static void XMLOutputter_printEndTest(OutputterRef self,TestRef test)
{ {
(void)self; (void)self;
fprintf(stdout,"</%s>\n",Test_name(test)); fprintf(stdout,"</%s>\n",Test_name(test));
} }
static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount)
{ {
(void)self; (void)self;
fprintf(stdout,"<Test id=\"%d\">\n",runCount); fprintf(stdout,"<Test id=\"%d\">\n",runCount);
fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); fprintf(stdout,"<Name>%s</Name>\n",Test_name(test));
fprintf(stdout,"</Test>\n"); fprintf(stdout,"</Test>\n");
} }
static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount)
{ {
(void)self; (void)self;
fprintf(stdout,"<FailedTest id=\"%d\">\n",runCount); fprintf(stdout,"<FailedTest id=\"%d\">\n",runCount);
fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); fprintf(stdout,"<Name>%s</Name>\n",Test_name(test));
fprintf(stdout,"<Location>\n"); fprintf(stdout,"<Location>\n");
fprintf(stdout,"<File>%s</File>\n",file); fprintf(stdout,"<File>%s</File>\n",file);
fprintf(stdout,"<Line>%d</Line>\n",line); fprintf(stdout,"<Line>%d</Line>\n",line);
fprintf(stdout,"</Location>\n"); fprintf(stdout,"</Location>\n");
fprintf(stdout,"<Message>%s</Message>\n",msg); fprintf(stdout,"<Message>%s</Message>\n",msg);
fprintf(stdout,"</FailedTest>\n"); fprintf(stdout,"</FailedTest>\n");
} }
static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result) static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result)
{ {
(void)self; (void)self;
fprintf(stdout,"<Statistics>\n"); fprintf(stdout,"<Statistics>\n");
fprintf(stdout,"<Tests>%d</Tests>\n",result->runCount); fprintf(stdout,"<Tests>%d</Tests>\n",result->runCount);
if (result->failureCount) { if (result->failureCount) {
fprintf(stdout,"<Failures>%d</Failures>\n",result->failureCount); fprintf(stdout,"<Failures>%d</Failures>\n",result->failureCount);
} }
fprintf(stdout,"</Statistics>\n"); fprintf(stdout,"</Statistics>\n");
fprintf(stdout,"</TestRun>\n"); fprintf(stdout,"</TestRun>\n");
} }
static const OutputterImplement XMLOutputterImplement = { static const OutputterImplement XMLOutputterImplement = {
(OutputterPrintHeaderFunction) XMLOutputter_printHeader, (OutputterPrintHeaderFunction) XMLOutputter_printHeader,
(OutputterPrintStartTestFunction) XMLOutputter_printStartTest, (OutputterPrintStartTestFunction) XMLOutputter_printStartTest,
(OutputterPrintEndTestFunction) XMLOutputter_printEndTest, (OutputterPrintEndTestFunction) XMLOutputter_printEndTest,
(OutputterPrintSuccessfulFunction) XMLOutputter_printSuccessful, (OutputterPrintSuccessfulFunction) XMLOutputter_printSuccessful,
(OutputterPrintFailureFunction) XMLOutputter_printFailure, (OutputterPrintFailureFunction) XMLOutputter_printFailure,
(OutputterPrintStatisticsFunction) XMLOutputter_printStatistics, (OutputterPrintStatisticsFunction) XMLOutputter_printStatistics,
}; };
static const Outputter XMLOutputter = { static const Outputter XMLOutputter = {
(OutputterImplementRef)&XMLOutputterImplement, (OutputterImplementRef)&XMLOutputterImplement,
}; };
void XMLOutputter_setStyleSheet(char *style) void XMLOutputter_setStyleSheet(char *style)
{ {
stylesheet_ = style; stylesheet_ = style;
} }
OutputterRef XMLOutputter_outputter(void) OutputterRef XMLOutputter_outputter(void)
{ {
return (OutputterRef)&XMLOutputter; return (OutputterRef)&XMLOutputter;
} }

View File

@ -32,8 +32,8 @@
* *
* $Id: XMLOutputter.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $ * $Id: XMLOutputter.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $
*/ */
#ifndef __XMLOUTPUTTER_H__ #ifndef __XMLOUTPUTTER_H__
#define __XMLOUTPUTTER_H__ #define __XMLOUTPUTTER_H__
#include "Outputter.h" #include "Outputter.h"