summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:04:17 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:04:17 -0800
commit225a86217dd274aea51b1e442568e7aec43a74e9 (patch)
treec9f262aab4d996452947fc9e8a1e4d452b9bf84d
downloadembunit-225a86217dd274aea51b1e442568e7aec43a74e9.tar.gz
Code drop from //branches/cupcake/...@124589
-rw-r--r--Android.mk24
-rw-r--r--MODULE_LICENSE_BSD_LIKE0
-rw-r--r--inc/AssertImpl.h72
-rw-r--r--inc/HelperMacro.h59
-rw-r--r--inc/RepeatedTest.h56
-rw-r--r--inc/Test.h65
-rw-r--r--inc/TestCaller.h76
-rw-r--r--inc/TestCase.h60
-rw-r--r--inc/TestListener.h62
-rw-r--r--inc/TestResult.h70
-rw-r--r--inc/TestRunner.h50
-rw-r--r--inc/TestSuite.h58
-rw-r--r--inc/config.h48
-rw-r--r--inc/embUnit.h50
-rw-r--r--inc/stdImpl.h57
-rw-r--r--src/AssertImpl.c100
-rw-r--r--src/NOTICE24
-rw-r--r--src/RepeatedTest.c61
-rw-r--r--src/TestCaller.c67
-rw-r--r--src/TestCase.c82
-rw-r--r--src/TestResult.c67
-rw-r--r--src/TestRunner.c111
-rw-r--r--src/TestSuite.c73
-rw-r--r--src/stdImpl.c141
24 files changed, 1533 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..ac4e9f5
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,24 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# embUnit test framework source files
+LOCAL_SRC_FILES := \
+ src/AssertImpl.c \
+ src/RepeatedTest.c \
+ src/stdImpl.c \
+ src/TestCaller.c \
+ src/TestCase.c \
+ src/TestResult.c \
+ src/TestRunner.c \
+ src/TestSuite.c
+
+# Header files path
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/inc
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libembunit
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/MODULE_LICENSE_BSD_LIKE b/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_BSD_LIKE
diff --git a/inc/AssertImpl.h b/inc/AssertImpl.h
new file mode 100644
index 0000000..de76b21
--- /dev/null
+++ b/inc/AssertImpl.h
@@ -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 --git a/inc/HelperMacro.h b/inc/HelperMacro.h
new file mode 100644
index 0000000..533e1be
--- /dev/null
+++ b/inc/HelperMacro.h
@@ -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 --git a/inc/RepeatedTest.h b/inc/RepeatedTest.h
new file mode 100644
index 0000000..c6b7335
--- /dev/null
+++ b/inc/RepeatedTest.h
@@ -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 --git a/inc/Test.h b/inc/Test.h
new file mode 100644
index 0000000..5705a1c
--- /dev/null
+++ b/inc/Test.h
@@ -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 --git a/inc/TestCaller.h b/inc/TestCaller.h
new file mode 100644
index 0000000..22166b8
--- /dev/null
+++ b/inc/TestCaller.h
@@ -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 --git a/inc/TestCase.h b/inc/TestCase.h
new file mode 100644
index 0000000..bbbd59f
--- /dev/null
+++ b/inc/TestCase.h
@@ -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 --git a/inc/TestListener.h b/inc/TestListener.h
new file mode 100644
index 0000000..404a971
--- /dev/null
+++ b/inc/TestListener.h
@@ -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 --git a/inc/TestResult.h b/inc/TestResult.h
new file mode 100644
index 0000000..7ebfb28
--- /dev/null
+++ b/inc/TestResult.h
@@ -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 --git a/inc/TestRunner.h b/inc/TestRunner.h
new file mode 100644
index 0000000..f709f74
--- /dev/null
+++ b/inc/TestRunner.h
@@ -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 --git a/inc/TestSuite.h b/inc/TestSuite.h
new file mode 100644
index 0000000..ae100ed
--- /dev/null
+++ b/inc/TestSuite.h
@@ -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 --git a/inc/config.h b/inc/config.h
new file mode 100644
index 0000000..2328d3a
--- /dev/null
+++ b/inc/config.h
@@ -0,0 +1,48 @@
+/*
+ * 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__
+
+/* #define NO_STDIO_PRINTF*/
+ #ifdef NO_STDIO_PRINTF
+ extern void stdimpl_print(const char *string);
+ #else
+ #include<stdio.h>
+ #define stdimpl_print printf
+ #endif
+
+ #define ASSERT_STRING_BUFFER_MAX 64
+
+#endif/*__CONFIG_H__*/
diff --git a/inc/embUnit.h b/inc/embUnit.h
new file mode 100644
index 0000000..2cb4d47
--- /dev/null
+++ b/inc/embUnit.h
@@ -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 --git a/inc/stdImpl.h b/inc/stdImpl.h
new file mode 100644
index 0000000..f6ce267
--- /dev/null
+++ b/inc/stdImpl.h
@@ -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__*/
diff --git a/src/AssertImpl.c b/src/AssertImpl.c
new file mode 100644
index 0000000..4698d83
--- /dev/null
+++ b/src/AssertImpl.c
@@ -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 --git a/src/NOTICE b/src/NOTICE
new file mode 100644
index 0000000..29defa8
--- /dev/null
+++ b/src/NOTICE
@@ -0,0 +1,24 @@
+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.
diff --git a/src/RepeatedTest.c b/src/RepeatedTest.c
new file mode 100644
index 0000000..d8b09b8
--- /dev/null
+++ b/src/RepeatedTest.c
@@ -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 --git a/src/TestCaller.c b/src/TestCaller.c
new file mode 100644
index 0000000..5ecec9f
--- /dev/null
+++ b/src/TestCaller.c
@@ -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 --git a/src/TestCase.c b/src/TestCase.c
new file mode 100644
index 0000000..6688ca6
--- /dev/null
+++ b/src/TestCase.c
@@ -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 --git a/src/TestResult.c b/src/TestResult.c
new file mode 100644
index 0000000..6006df8
--- /dev/null
+++ b/src/TestResult.c
@@ -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 --git a/src/TestRunner.c b/src/TestRunner.c
new file mode 100644
index 0000000..a6388d0
--- /dev/null
+++ b/src/TestRunner.c
@@ -0,0 +1,111 @@
+/*
+ * 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("\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("\n");
+}
+
+static const TestListnerImplement TestRunnerImplement = {
+ (TestListnerStartTestCallBack) TestRunner_startTest,
+ (TestListnerEndTestCallBack) TestRunner_endTest,
+ (TestListnerAddFailureCallBack) TestRunner_addFailure,
+};
+
+static const TestListner testrunner_ = {
+ (TestListnerImplement*)&TestRunnerImplement,
+};
+
+void TestRunner_start(void)
+{
+ 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("\nrun ");
+ stdimpl_itoa(result_.runCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print(" failures ");
+ stdimpl_itoa(result_.failureCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print("\n");
+ } else {
+ stdimpl_print("\nOK (");
+ stdimpl_itoa(result_.runCount, buf, 10);
+ stdimpl_print(buf);
+ stdimpl_print(" tests)\n");
+ }
+}
diff --git a/src/TestSuite.c b/src/TestSuite.c
new file mode 100644
index 0000000..a8899e2
--- /dev/null
+++ b/src/TestSuite.c
@@ -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 --git a/src/stdImpl.c b/src/stdImpl.c
new file mode 100644
index 0000000..082ebc1
--- /dev/null
+++ b/src/stdImpl.c
@@ -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);
+}