Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:bbc0d658b7eb, committed 2011-01-18
- Comitter:
- sillevl
- Date:
- Tue Jan 18 16:39:49 2011 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r bbc0d658b7eb AssertImpl.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/AssertImpl.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,100 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: AssertImpl.c,v 1.5 2004/02/10 16:15:25 arms22 Exp $
+ */
+#include "config.h"
+#include "stdImpl.h"
+#include "AssertImpl.h"
+
+void assertImplementationInt(int expected,int actual, long line, const char *file)
+{
+ char buffer[32]; /*"exp -2147483647 was -2147483647"*/
+ char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/
+
+ stdimpl_strcpy(buffer, "exp ");
+
+ { stdimpl_itoa(expected, numbuf, 10);
+ stdimpl_strncat(buffer, numbuf, 11); }
+
+ stdimpl_strcat(buffer, " was ");
+
+ { stdimpl_itoa(actual, numbuf, 10);
+ stdimpl_strncat(buffer, numbuf, 11); }
+
+ addFailure(buffer, line, file);
+}
+
+void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file)
+{
+ char buffer[ASSERT_STRING_BUFFER_MAX];
+ #define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */
+ int el;
+ int al;
+
+ if (expected) {
+ el = stdimpl_strlen(expected);
+ } else {
+ el = 4;
+ expected = "null";
+ }
+
+ if (actual) {
+ al = stdimpl_strlen(actual);
+ } else {
+ al = 4;
+ actual = "null";
+ }
+ if (el > exp_act_limit) {
+ if (al > exp_act_limit) {
+ al = exp_act_limit;
+ el = exp_act_limit;
+ } else {
+ int w = exp_act_limit + (exp_act_limit - al);
+ if (el > w) {
+ el = w;
+ }
+ }
+ } else {
+ int w = exp_act_limit + (exp_act_limit - el);
+ if (al > w) {
+ al = w;
+ }
+ }
+ stdimpl_strcpy(buffer, "exp \"");
+ stdimpl_strncat(buffer, expected, el);
+ stdimpl_strcat(buffer, "\" was \"");
+ stdimpl_strncat(buffer, actual, al);
+ stdimpl_strcat(buffer, "\"");
+
+ addFailure(buffer, line, file);
+}
diff -r 000000000000 -r bbc0d658b7eb AssertImpl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/AssertImpl.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,72 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $
+ */
+#ifndef __ASSERTIMPL_H__
+#define __ASSERTIMPL_H__
+
+#ifdef __cplusplus
+//extern "C" {
+#endif
+
+void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/
+
+void assertImplementationInt(int expected,int 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)\
+ if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;}
+
+#define TEST_ASSERT_EQUAL_INT(expected,actual)\
+ if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;}
+
+#define TEST_ASSERT_NULL(pointer)\
+ TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.")
+
+#define TEST_ASSERT_NOT_NULL(pointer)\
+ TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.")
+
+#define TEST_ASSERT_MESSAGE(condition, message)\
+ if (condition) {} else {TEST_FAIL(message);}
+
+#define TEST_ASSERT(condition)\
+ if (condition) {} else {TEST_FAIL(#condition);}
+
+#define TEST_FAIL(message)\
+ if (0) {} else {addFailure(message,__LINE__,__FILE__);return;}
+
+#ifdef __cplusplus
+
+#endif
+
+#endif/*__ASSERTIMPL_H__*/
diff -r 000000000000 -r bbc0d658b7eb HelperMacro.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HelperMacro.h Tue Jan 18 16:39:49 2011 +0000 @@ -0,0 +1,59 @@ +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $ + */ +#ifndef __HELPERMACRO_H__ +#define __HELPERMACRO_H__ + +#define EMB_UNIT_TESTCASE(ca,name,sup,tdw,run) \ + static const TestCase ca = new_TestCase(name,sup,tdw,run) + +#define EMB_UNIT_TESTSUITE(su,name,array) \ + static const TestSuite su = new_TestSuite(name,(Test**)array,sizeof(array)/sizeof(array[0])) + +#define EMB_UNIT_TESTREFS(tests) \ + static Test* const tests[] = + +#define EMB_UNIT_ADD_TESTREF(testref) \ + (Test*) testref + +#define EMB_UNIT_TESTCALLER(caller,name,sup,tdw,fixtures) \ + static const TestCaller caller = new_TestCaller(name,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures) + +#define EMB_UNIT_TESTFIXTURES(fixtures) \ + static const TestFixture fixtures[] = + +#define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \ + static const RepeatedTest repeater = new_RepeatedTest(test,tmrp) + +#endif/*__HELPERMACRO_H__*/
diff -r 000000000000 -r bbc0d658b7eb RepeatedTest.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RepeatedTest.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,61 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: RepeatedTest.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "Test.h"
+#include "RepeatedTest.h"
+
+char* RepeatedTest_name(RepeatedTest* self)
+{
+ return Test_name(self->test);
+}
+
+void RepeatedTest_run(RepeatedTest* self,TestResult* result)
+{
+ int i;
+ Test* test = self->test;
+ for (i=0; i<self->timesRepeat; i++) {
+ Test_run(test, result);
+ }
+}
+
+int RepeatedTest_countTestCases(RepeatedTest* self)
+{
+ return Test_countTestCases(self->test) * self->timesRepeat;
+}
+
+const TestImplement RepeatedTestImplement = {
+ (TestNameFunction) RepeatedTest_name,
+ (TestRunFunction) RepeatedTest_run,
+ (TestCountTestCasesFunction)RepeatedTest_countTestCases,
+};
diff -r 000000000000 -r bbc0d658b7eb RepeatedTest.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RepeatedTest.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,56 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __REPEATEDTEST_H__
+#define __REPEATEDTEST_H__
+
+typedef struct __RepeatedTest RepeatedTest;
+typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/
+
+struct __RepeatedTest {
+ TestImplement* isa;
+ Test* test;
+ int timesRepeat;
+};
+
+extern const TestImplement RepeatedTestImplement;
+
+#define new_RepeatedTest(test,tmrp)\
+ {\
+ (TestImplement*)&RepeatedTestImplement,\
+ (Test*)test,\
+ tmrp,\
+ }
+
+#endif/*__REPEATEDTEST_H__*/
diff -r 000000000000 -r bbc0d658b7eb Test.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Test.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,65 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TEST_H__
+#define __TEST_H__
+
+typedef struct __TestResult TestResult;
+typedef struct __TestResult* TestResultRef;/*downward compatible*/
+
+typedef struct __TestImplement TestImplement;
+typedef struct __TestImplement* TestImplementRef;/*downward compatible*/
+
+typedef char*(*TestNameFunction)(void*);
+typedef void(*TestRunFunction)(void*,TestResult*);
+typedef int(*TestCountTestCasesFunction)(void*);
+
+struct __TestImplement {
+ TestNameFunction name;
+ TestRunFunction run;
+ TestCountTestCasesFunction countTestCases;
+};
+
+typedef struct __Test Test;
+typedef struct __Test* TestRef;/*downward compatible*/
+
+struct __Test {
+ TestImplement* isa;
+};
+
+#define Test_name(s) ((Test*)s)->isa->name(s)
+#define Test_run(s,r) ((Test*)s)->isa->run(s,r)
+#define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s)
+
+#endif/*__TEST_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestCaller.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestCaller.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,67 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestCaller.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "Test.h"
+#include "TestCase.h"
+#include "TestCaller.h"
+
+char* TestCaller_name(TestCaller* self)
+{
+ return self->name;
+}
+
+void TestCaller_run(TestCaller* self,TestResult* result)
+{
+ TestCase cs = new_TestCase(0,0,0,0);
+ int i;
+ cs.setUp= self->setUp;
+ cs.tearDown = self->tearDown;
+ for (i=0; i<self->numberOfFixtuers; i++) {
+ cs.name = self->fixtuers[i].name;
+ cs.runTest = self->fixtuers[i].test;
+ /*run test*/
+ Test_run(&cs,result);
+ }
+}
+
+int TestCaller_countTestCases(TestCaller* self)
+{
+ return self->numberOfFixtuers;
+}
+
+const TestImplement TestCallerImplement = {
+ (TestNameFunction) TestCaller_name,
+ (TestRunFunction) TestCaller_run,
+ (TestCountTestCasesFunction)TestCaller_countTestCases,
+};
diff -r 000000000000 -r bbc0d658b7eb TestCaller.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestCaller.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,76 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestCaller.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTCALLER_H__
+#define __TESTCALLER_H__
+
+typedef struct __TestFixture TestFixture;
+typedef struct __TestFixture* TestFixtureRef;/*downward compatible*/
+
+struct __TestFixture {
+ char *name;
+ void(*test)(void);
+};
+
+#define new_TestFixture(name,test)\
+ {\
+ name,\
+ test,\
+ }
+
+typedef struct __TestCaller TestCaller;
+typedef struct __TestCaller* TestCallerRef;/*downward compatible*/
+
+struct __TestCaller {
+ TestImplement* isa;
+ char *name;
+ void(*setUp)(void);
+ void(*tearDown)(void);
+ int numberOfFixtuers;
+ TestFixture *fixtuers;
+};
+
+extern const TestImplement TestCallerImplement;
+
+#define new_TestCaller(name,sup,tdw,numberOfFixtuers,fixtuers)\
+ {\
+ (TestImplement*)&TestCallerImplement,\
+ name,\
+ sup,\
+ tdw,\
+ numberOfFixtuers,\
+ fixtuers,\
+ }
+
+#endif/*__TESTCALLER_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestCase.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestCase.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,82 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestCase.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "Test.h"
+#include "TestCase.h"
+#include "TestResult.h"
+
+static TestResult* result_;
+static TestCase* self_;
+
+char* TestCase_name(TestCase* self)
+{
+ return self->name;
+}
+
+void TestCase_run(TestCase* self,TestResult* result)
+{
+ TestResult_startTest(result, (Test*)self);
+ if (self->setUp) {
+ self->setUp();
+ }
+ if (self->runTest) {
+ TestResult* wr =result_; /*push*/
+ TestCase* ws = self_; /*push*/
+ result_ = result;
+ self_ = self;
+ self->runTest();
+ result_ = wr; /*pop*/
+ self_ = ws; /*pop*/
+ }
+ if (self->tearDown) {
+ self->tearDown();
+ }
+ TestResult_endTest(result, (Test*)self);
+}
+
+int TestCase_countTestCases(TestCase* self)
+{
+ return 1;
+}
+
+const TestImplement TestCaseImplement = {
+ (TestNameFunction) TestCase_name,
+ (TestRunFunction) TestCase_run,
+ (TestCountTestCasesFunction)TestCase_countTestCases,
+};
+
+void addFailure(const char *msg, long line, const char *file)
+{
+ TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file);
+}
diff -r 000000000000 -r bbc0d658b7eb TestCase.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestCase.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,60 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestCase.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTCASE_H__
+#define __TESTCASE_H__
+
+typedef struct __TestCase TestCase;
+typedef struct __TestCase* TestCaseRef;/*compatible embUnit1.0*/
+
+struct __TestCase {
+ TestImplement* isa;
+ char *name;
+ void(*setUp)(void);
+ void(*tearDown)(void);
+ void(*runTest)(void);
+};
+
+extern const TestImplement TestCaseImplement;
+
+#define new_TestCase(name,setUp,tearDown,runTest)\
+ {\
+ (TestImplement*)&TestCaseImplement,\
+ name,\
+ setUp,\
+ tearDown,\
+ runTest,\
+ }
+
+#endif/*__TESTCASE_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestListener.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestListener.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,62 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestListener.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTLISTENER_H__
+#define __TESTLISTENER_H__
+
+typedef struct __TestListnerImplement TestListnerImplement;
+typedef struct __TestListnerImplement* TestListnerImplementRef;/*downward compatible*/
+
+typedef void(*TestListnerStartTestCallBack)(void*,void*);
+typedef void(*TestListnerEndTestCallBack)(void*,void*);
+typedef void(*TestListnerAddFailureCallBack)(void*,void*,const char*,int,const char*);
+
+struct __TestListnerImplement {
+ TestListnerStartTestCallBack startTest;
+ TestListnerEndTestCallBack endTest;
+ TestListnerAddFailureCallBack addFailure;
+};
+
+/*typedef struct __TestListner TestListner;*/ /*->TestResult.h*/
+/*typedef struct __TestListner* TestListnerRef;*/ /*->TestResult.h*/
+
+struct __TestListner {
+ TestListnerImplement* isa;
+};
+
+#define TestListner_startTest(s,t) ((TestListner*)s)->isa->startTest(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)
+
+#endif/*__TESTLISTENER_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestResult.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestResult.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,67 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestResult.c,v 1.4 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "Test.h"
+#include "TestListener.h"
+#include "TestResult.h"
+
+void TestResult_init(TestResult* self,TestListner* listner)
+{
+ self->runCount = 0;
+ self->failureCount = 0;
+ self->listener = listner;
+}
+
+void TestResult_startTest(TestResult* self,Test* test)
+{
+ self->runCount++;
+ if (self->listener) {
+ TestListner_startTest(self->listener, test);
+ }
+}
+
+void TestResult_endTest(TestResult* self,Test* test)
+{
+ if (self->listener) {
+ TestListner_endTest(self->listener, test);
+ }
+}
+
+void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file)
+{
+ self->failureCount++;
+ if (self->listener) {
+ TestListner_addFailure(self->listener, test, msg, line, file);
+ }
+}
diff -r 000000000000 -r bbc0d658b7eb TestResult.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestResult.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,70 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestResult.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTRESULT_H__
+#define __TESTRESULT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*typedef struct __TestResult TestResult;*//* -> Test.h*/
+/*typedef struct __TestResult* TestResultRef;*//* -> Test.h*/
+
+typedef struct __TestListner TestListner;
+typedef struct __TestListner* TestListnerRef;/*downward compatible*/
+
+struct __TestResult {
+ unsigned short runCount;
+ unsigned short failureCount;
+ TestListner* listener;
+};
+
+#define new_TestResult(listener)\
+ {\
+ 0,\
+ 0,\
+ (TestListner*)listener,\
+ }
+
+void TestResult_init(TestResult* self,TestListner* listner);
+void TestResult_startTest(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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif/*__TESTRESULT_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestRunner.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestRunner.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,112 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestRunner.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "config.h"
+#include "stdImpl.h"
+#include "Test.h"
+#include "TestListener.h"
+#include "TestResult.h"
+#include "TestRunner.h"
+
+static TestResult result_;
+static Test* root_;
+
+static void TestRunner_startTest(TestListner* self,Test* test)
+{
+ stdimpl_print(".");
+}
+
+static void TestRunner_endTest(TestListner* self,Test* test)
+{
+}
+
+static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file)
+{
+ stdimpl_print("\r\n");
+ stdimpl_print(Test_name(root_));
+ stdimpl_print(".");
+ stdimpl_print(Test_name(test));
+ {
+ char buf[16];
+ stdimpl_print(" (");
+ stdimpl_print(file);
+ stdimpl_print(" ");
+ stdimpl_itoa(line, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print(") ");
+ }
+ stdimpl_print(msg);
+ stdimpl_print("\r\n");
+}
+
+static const TestListnerImplement TestRunnerImplement = {
+ (TestListnerStartTestCallBack) TestRunner_startTest,
+ (TestListnerEndTestCallBack) TestRunner_endTest,
+ (TestListnerAddFailureCallBack) TestRunner_addFailure,
+};
+
+static const TestListner testrunner_ = {
+ (TestListnerImplement*)&TestRunnerImplement,
+};
+
+void TestRunner_start(void)
+{
+ stdimpl_print("---Start EmbUnit---\r\n");
+ TestResult_init(&result_, (TestListner*)&testrunner_);
+}
+
+void TestRunner_runTest(Test* test)
+{
+ root_ = test;
+ Test_run(test, &result_);
+}
+
+void TestRunner_end(void)
+{
+ char buf[16];
+ if (result_.failureCount) {
+ stdimpl_print("\r\nrun ");
+ stdimpl_itoa(result_.runCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print(" failures ");
+ stdimpl_itoa(result_.failureCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print("\r\n");
+ } else {
+ stdimpl_print("\r\nOK (");
+ stdimpl_itoa(result_.runCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print(" tests)\r\n");
+ }
+}
diff -r 000000000000 -r bbc0d658b7eb TestRunner.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestRunner.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,50 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestRunner.h,v 1.6 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTRUNNER_H__
+#define __TESTRUNNER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void TestRunner_start(void);
+void TestRunner_runTest(Test* test);
+void TestRunner_end(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif/*__TESTRUNNER_H__*/
diff -r 000000000000 -r bbc0d658b7eb TestSuite.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestSuite.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,73 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestSuite.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $
+ */
+#include "Test.h"
+#include "TestSuite.h"
+
+char* TestSuite_name(TestSuite* self)
+{
+ return self->name;
+}
+
+void TestSuite_run(TestSuite* self,TestResult* result)
+{
+ int i;
+ Test* test;
+ if (self->tests) {
+ for (i=0; i<self->numberOfTests; i++) {
+ test = self->tests[i];
+ Test_run(test, result);
+ }
+ }
+}
+
+int TestSuite_countTestCases(TestSuite* self)
+{
+ int count = 0;
+ int i;
+ Test* test;
+ if (self->tests) {
+ for (i=0; i<self->numberOfTests; i++) {
+ test = self->tests[i];
+ count += Test_countTestCases(test);
+ }
+ }
+ return count;
+}
+
+const TestImplement TestSuiteImplement = {
+ (TestNameFunction) TestSuite_name,
+ (TestRunFunction) TestSuite_run,
+ (TestCountTestCasesFunction)TestSuite_countTestCases,
+};
diff -r 000000000000 -r bbc0d658b7eb TestSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestSuite.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,58 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: TestSuite.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
+ */
+#ifndef __TESTSUITE_H__
+#define __TESTSUITE_H__
+
+typedef struct __TestSuite TestSuite;
+typedef struct __TestSuite* TestSuiteRef;/*downward compatible*/
+
+struct __TestSuite {
+ TestImplement* isa;
+ char *name;
+ int numberOfTests;
+ Test** tests;
+};
+
+extern const TestImplement TestSuiteImplement;
+
+#define new_TestSuite(name,tests,numberOfTests)\
+ {\
+ (TestImplement*)&TestSuiteImplement,\
+ name,\
+ numberOfTests,\
+ tests,\
+ }
+
+#endif/*__TESTSUITE_H__*/
diff -r 000000000000 -r bbc0d658b7eb config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config.h Tue Jan 18 16:39:49 2011 +0000 @@ -0,0 +1,49 @@ +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: config.h,v 1.7 2004/02/10 16:17:07 arms22 Exp $ + */ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + + +#include "mbed.h" + + + extern Serial testUart; + + #define stdimpl_print testUart.printf + + + #define ASSERT_STRING_BUFFER_MAX 64 + +#endif/*__CONFIG_H__*/
diff -r 000000000000 -r bbc0d658b7eb embUnit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/embUnit.h Tue Jan 18 16:39:49 2011 +0000 @@ -0,0 +1,50 @@ +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: embUnit.h,v 1.4 2004/02/10 16:16:19 arms22 Exp $ + */ +#ifndef __EMBUNIT_H__ +#define __EMBUNIT_H__ + +#include "Test.h" +#include "TestCase.h" +#include "TestListener.h" +#include "TestResult.h" +#include "TestSuite.h" +#include "TestRunner.h" +#include "TestCaller.h" +#include "RepeatedTest.h" +#include "stdImpl.h" +#include "AssertImpl.h" +#include "HelperMacro.h" + +#endif/*__EMBUNIT_H__*/
diff -r 000000000000 -r bbc0d658b7eb stdImpl.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stdImpl.cpp Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,141 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: stdImpl.c,v 1.3 2004/02/10 16:15:25 arms22 Exp $
+ */
+#include "stdImpl.h"
+
+char* stdimpl_strcpy(char *dst, const char *src)
+{
+ char *start = dst;
+ char c;
+ do {
+ c = *src;
+ *dst = c;
+ src++;
+ dst++;
+ } while (c);
+ return start;
+}
+
+char* stdimpl_strcat(char *dst, const char *src)
+{
+ char *start = dst;
+ char c;
+ do {
+ c = *dst;
+ dst++;
+ } while (c);
+ dst--;
+ do {
+ c = *src;
+ *dst = c;
+ src++;
+ dst++;
+ } while (c);
+ return start;
+}
+
+char* stdimpl_strncat(char *dst, const char *src,unsigned int count)
+{
+ char *start = dst;
+ char c;
+ do {
+ c = *dst;
+ dst++;
+ } while (c);
+ dst--;
+ if (count) {
+ do {
+ c = *src;
+ *dst = c;
+ src++;
+ dst++;
+ count--;
+ } while (c && count);
+ *dst = '\0';
+ }
+ return start;
+}
+
+int stdimpl_strlen(const char *str)
+{
+ const char *estr = str;
+ char c;
+ do {
+ c = *estr;
+ estr++;
+ } while (c);
+ return ((int)(estr - str - 1));
+}
+
+int stdimpl_strcmp(const char *s1, const char *s2)
+{
+ char c1,c2;
+ do {
+ c1 = *s1++;
+ c2 = *s2++;
+ } while ((c1) && (c2) && (c1==c2));
+ return c1 - c2;
+}
+
+static char* _xtoa(unsigned long v,char *string, int r, int is_neg)
+{
+ char *start = string;
+ char buf[33],*p;
+
+ p = buf;
+
+ do {
+ *p++ = "0123456789abcdef"[(v % r) & 0xf];
+ } while (v /= r);
+
+ if (is_neg) {
+ *p++ = '-';
+ }
+
+ do {
+ *string++ = *--p;
+ } while (buf != p);
+
+ *string = '\0';
+
+ return start;
+}
+
+char* stdimpl_itoa(int v,char *string,int r)
+{
+ if ((r == 10) && (v < 0)) {
+ return _xtoa((unsigned long)(-v), string, r, 1);
+ }
+ return _xtoa((unsigned long)(v), string, r, 0);
+}
diff -r 000000000000 -r bbc0d658b7eb stdImpl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stdImpl.h Tue Jan 18 16:39:49 2011 +0000
@@ -0,0 +1,57 @@
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (c) 2003 Embedded Unit Project
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies
+ * of the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+ * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization of the copyright holder.
+ *
+ * $Id: stdImpl.h,v 1.4 2004/02/10 16:15:25 arms22 Exp $
+ */
+#ifndef __STDIMPL_H__
+#define __STDIMPL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+char* stdimpl_strcpy(char *s1, const char *s2);
+char* stdimpl_strcat(char *dst, const char *src);
+char* stdimpl_strncat(char *dst, const char *src,unsigned int count);
+int stdimpl_strlen(const char *str);
+int stdimpl_strcmp(const char *s1, const char *s2);
+char* stdimpl_itoa(int v,char *string,int r);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif/*__STDIMPL_H__*/