├── .gitignore ├── AUTHORS.md ├── Example ├── AllTests.c ├── Example.cppproj ├── counter.c ├── counter.h ├── counterTest.c ├── person.c ├── person.h └── personTest.c ├── LICENSE.md ├── README.md ├── Tests ├── AllTests.c ├── MockTestCase.c ├── MockTestCase.h ├── RepeatedTestTest.c ├── TestCallerTest.c ├── TestCaseTest.c ├── TestResultTest.c ├── Tests.cppproj ├── assertTest.c └── stdImplTest.c ├── TextUI ├── CompilerOutputter.c ├── CompilerOutputter.h ├── Outputter.h ├── TextOutputter.c ├── TextOutputter.h ├── TextUI.cproj ├── TextUIRunner.c ├── TextUIRunner.h ├── XMLOutputter.c └── XMLOutputter.h ├── embUnit.atsln └── embUnit ├── AssertImpl.c ├── AssertImpl.h ├── HelperMacro.h ├── RepeatedTest.c ├── RepeatedTest.h ├── Test.h ├── TestCaller.c ├── TestCaller.h ├── TestCase.c ├── TestCase.h ├── TestListener.h ├── TestResult.c ├── TestResult.h ├── TestRunner.c ├── TestRunner.h ├── TestSuite.c ├── TestSuite.h ├── config.h ├── embUnit.cproj ├── embUnit.h ├── stdImpl.c └── stdImpl.h /.gitignore: -------------------------------------------------------------------------------- 1 | embUnit/Debug/ 2 | embUnit/Release/ 3 | TextUI/Debug/ 4 | TextUI/Release/ 5 | Tests/Debug/ 6 | Tests/Release/ 7 | Example/Debug/ 8 | Example/Release/ 9 | embUnit.atsuo -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | arms22 2 | -------------------------------------------------------------------------------- /Example/AllTests.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | TestRef CounterTest_tests(void); 4 | TestRef PersonTest_tests(void); 5 | 6 | int main (int argc, const char* argv[]) 7 | { 8 | TestRunner_start(); 9 | TestRunner_runTest(CounterTest_tests()); 10 | TestRunner_runTest(PersonTest_tests()); 11 | TestRunner_end(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /Example/Example.cppproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 6.0 6 | com.Atmel.AVRGCC8 7 | {4a4ac5c5-dab1-4459-af31-90ae023cc9e1} 8 | ATmega328P 9 | none 10 | Executable 11 | CPP 12 | $(MSBuildProjectName) 13 | .elf 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | Example 16 | Example 17 | Example 18 | Native 19 | 20 | com.atmel.avrdbg.tool.simulator 21 | 22 | com.atmel.avrdbg.tool.simulator 23 | AVR Simulator 24 | 25 | 26 | true 27 | false 28 | 29 | 30 | 31 | 127.0.0.1 32 | 49544 33 | False 34 | 35 | 36 | 3.1.3 37 | 38 | 39 | 40 | 41 | True 42 | True 43 | True 44 | True 45 | True 46 | Optimize for size (-Os) 47 | True 48 | True 49 | True 50 | True 51 | True 52 | Optimize for size (-Os) 53 | True 54 | True 55 | True 56 | 57 | 58 | m 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | True 68 | True 69 | True 70 | True 71 | True 72 | 73 | 74 | ../.. 75 | 76 | 77 | Optimize (-O1) 78 | True 79 | True 80 | True 81 | Default (-g2) 82 | True 83 | True 84 | True 85 | 86 | 87 | ../.. 88 | 89 | 90 | Optimize (-O1) 91 | True 92 | True 93 | True 94 | Default (-g2) 95 | True 96 | 97 | 98 | m 99 | embUnit 100 | 101 | 102 | 103 | 104 | ../../embUnit/Debug 105 | 106 | 107 | Default (-Wa,-g) 108 | 109 | 110 | 111 | 112 | 113 | compile 114 | 115 | 116 | compile 117 | 118 | 119 | compile 120 | 121 | 122 | compile 123 | 124 | 125 | compile 126 | 127 | 128 | compile 129 | 130 | 131 | compile 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /Example/counter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "counter.h" 3 | 4 | CounterRef Counter_alloc(void) 5 | { 6 | return (CounterRef)malloc(sizeof(Counter)); 7 | } 8 | 9 | void Counter_dealloc(CounterRef self) 10 | { 11 | free(self); 12 | } 13 | 14 | CounterRef Counter_init(CounterRef self) 15 | { 16 | self->value = 0; 17 | return self; 18 | } 19 | 20 | CounterRef Counter_counter(void) 21 | { 22 | return Counter_init(Counter_alloc()); 23 | } 24 | 25 | int Counter_value(CounterRef self) 26 | { 27 | return self->value; 28 | } 29 | 30 | void Counter_setValue(CounterRef self,int value) 31 | { 32 | self->value = value; 33 | } 34 | 35 | int Counter_inc(CounterRef self) 36 | { 37 | self->value++; 38 | return self->value; 39 | } 40 | 41 | int Counter_dec(CounterRef self) 42 | { 43 | self->value--; 44 | return self->value; 45 | } 46 | 47 | void Counter_clr(CounterRef self) 48 | { 49 | self->value = 0; 50 | } 51 | -------------------------------------------------------------------------------- /Example/counter.h: -------------------------------------------------------------------------------- 1 | #ifndef __COUNTER_H__ 2 | #define __COUNTER_H__ 3 | 4 | typedef struct __Counter Counter; 5 | typedef struct __Counter* CounterRef; 6 | 7 | struct __Counter { 8 | int value; 9 | }; 10 | 11 | CounterRef Counter_alloc(void); 12 | void Counter_dealloc(CounterRef); 13 | CounterRef Counter_init(CounterRef); 14 | CounterRef Counter_counter(void); 15 | int Counter_value(CounterRef); 16 | void Counter_setValue(CounterRef,int); 17 | int Counter_inc(CounterRef); 18 | int Counter_dec(CounterRef); 19 | void Counter_clr(CounterRef); 20 | 21 | #endif/*__COUNTER_H__*/ 22 | -------------------------------------------------------------------------------- /Example/counterTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "counter.h" 3 | 4 | CounterRef counterRef; 5 | 6 | static void setUp(void) 7 | { 8 | counterRef = Counter_counter(); 9 | } 10 | 11 | static void tearDown(void) 12 | { 13 | Counter_dealloc(counterRef); 14 | } 15 | 16 | static void testInit(void) 17 | { 18 | TEST_ASSERT_EQUAL_INT(0, Counter_value(counterRef)); 19 | } 20 | 21 | static void testSetValue(void) 22 | { 23 | Counter_setValue(counterRef,1); 24 | TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); 25 | 26 | Counter_setValue(counterRef,-1); 27 | TEST_ASSERT_EQUAL_INT(-1, Counter_value(counterRef)); 28 | } 29 | 30 | static void testInc(void) 31 | { 32 | Counter_inc(counterRef); 33 | TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); 34 | 35 | Counter_inc(counterRef); 36 | TEST_ASSERT_EQUAL_INT(2, Counter_value(counterRef)); 37 | } 38 | 39 | static void testDec(void) 40 | { 41 | Counter_dec(counterRef); 42 | TEST_ASSERT_EQUAL_INT(-1, Counter_value(counterRef)); 43 | 44 | Counter_dec(counterRef); 45 | TEST_ASSERT_EQUAL_INT(-2, Counter_value(counterRef)); 46 | } 47 | 48 | static void testClr(void) 49 | { 50 | Counter_inc(counterRef); 51 | TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); 52 | 53 | Counter_clr(counterRef); 54 | TEST_ASSERT_EQUAL_INT(0, Counter_value(counterRef)); 55 | } 56 | 57 | TestRef CounterTest_tests(void) 58 | { 59 | EMB_UNIT_TESTFIXTURES(fixtures) { 60 | new_TestFixture("testInit",testInit), 61 | new_TestFixture("testSetValue",testSetValue), 62 | new_TestFixture("testInc",testInc), 63 | new_TestFixture("testDec",testDec), 64 | new_TestFixture("testClr",testClr), 65 | }; 66 | EMB_UNIT_TESTCALLER(CounterTest,"CounterTest",setUp,tearDown,fixtures); 67 | 68 | return (TestRef)&CounterTest; 69 | } 70 | -------------------------------------------------------------------------------- /Example/person.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "person.h" 5 | 6 | PersonRef Person_alloc(void) 7 | { 8 | return (PersonRef)malloc(sizeof(Person)); 9 | } 10 | 11 | PersonRef Person_init(PersonRef self) 12 | { 13 | return Person_initWithName(self, NULL); 14 | } 15 | 16 | PersonRef Person_initWithName(PersonRef self,char *fullname) 17 | { 18 | self->fullname = NULL; 19 | self->firstname = NULL; 20 | self->lastname = NULL; 21 | Person_setFullName(self,fullname); 22 | return self; 23 | } 24 | 25 | PersonRef Person_personWithName(char *fullname) 26 | { 27 | return Person_initWithName(Person_alloc(),fullname); 28 | } 29 | 30 | void Person_dealloc(PersonRef self) 31 | { 32 | if (self) { 33 | free(self->fullname); 34 | free(self->firstname); 35 | free(self->lastname); 36 | free(self); 37 | } 38 | } 39 | 40 | static void setfullname(PersonRef self,char *fullname) 41 | { 42 | free(self->fullname); 43 | self->fullname = NULL; 44 | if (fullname) { 45 | self->fullname = (char*)malloc(strlen(fullname)+1); 46 | strcpy(self->fullname,fullname); 47 | } 48 | } 49 | 50 | static void setfirstname(PersonRef self,char *firstname) 51 | { 52 | free(self->firstname); 53 | self->firstname = NULL; 54 | if (firstname) { 55 | self->firstname = (char*)malloc(strlen(firstname)+1); 56 | strcpy(self->firstname,firstname); 57 | } 58 | } 59 | 60 | static void setlastname(PersonRef self,char *lastname) 61 | { 62 | free(self->lastname); 63 | self->lastname = NULL; 64 | if (lastname) { 65 | self->lastname = (char*)malloc(strlen(lastname)+1); 66 | strcpy(self->lastname,lastname); 67 | } 68 | } 69 | 70 | static void makefullname(PersonRef self) 71 | { 72 | size_t fl,ll,fulllen,pos; 73 | fl = ll = fulllen = pos = 0; 74 | if (self->firstname) { 75 | fl = strlen(self->firstname); 76 | } 77 | if (self->lastname) { 78 | ll = strlen(self->lastname); 79 | } 80 | if (fl) { 81 | fulllen = fl + 1; /* + space */ 82 | } 83 | if (ll) { 84 | fulllen = fulllen + ll + 1; /* + null */ 85 | } 86 | if (fulllen) { 87 | self->fullname = (char*)malloc(fulllen); 88 | if (fl && ll) { 89 | sprintf(self->fullname,"%s %s",self->firstname,self->lastname); 90 | } else { 91 | if (fl) { 92 | strcpy(self->fullname,self->firstname); 93 | } 94 | if (ll) { 95 | strcpy(self->fullname,self->lastname); 96 | } 97 | } 98 | } 99 | } 100 | 101 | static void makefirstname(PersonRef self) 102 | { 103 | if (self->fullname) { 104 | char *p; 105 | int len; 106 | p = strchr(self->fullname, ' '); 107 | if (p) { 108 | len = (int)(p - self->fullname); 109 | p = (char*)malloc(len + 1); 110 | strncpy(p,self->fullname,len); 111 | p[len] = '\0'; 112 | setfirstname(self,p); 113 | free(p); 114 | } else { 115 | setfirstname(self,self->fullname); 116 | } 117 | } 118 | } 119 | 120 | static void makelastname(PersonRef self) 121 | { 122 | if (self->fullname) { 123 | char *p = strchr(self->fullname, ' '); 124 | if (p) { 125 | setlastname(self,p+1); 126 | } else { 127 | setlastname(self,""); 128 | } 129 | } 130 | } 131 | 132 | char* Person_fullName(PersonRef self) 133 | { 134 | if (self->fullname == NULL) { 135 | makefullname(self); 136 | } 137 | return self->fullname; 138 | } 139 | 140 | char* Person_firstName(PersonRef self) 141 | { 142 | if (self->firstname == NULL) { 143 | makefirstname(self); 144 | } 145 | return self->firstname; 146 | } 147 | 148 | char* Person_lastName(PersonRef self) 149 | { 150 | if (self->lastname == NULL) { 151 | makelastname(self); 152 | } 153 | return self->lastname; 154 | } 155 | 156 | void Person_setFullName(PersonRef self,char *fullname) 157 | { 158 | setfullname(self,fullname); 159 | setfirstname(self,NULL); 160 | setlastname(self,NULL); 161 | } 162 | 163 | void Person_setFirstName(PersonRef self,char *firstname) 164 | { 165 | if (self->lastname == NULL) { 166 | makelastname(self); 167 | } 168 | setfirstname(self,firstname); 169 | setfullname(self,NULL); 170 | } 171 | 172 | void Person_setLastName(PersonRef self,char *lastname) 173 | { 174 | if (self->firstname == NULL) { 175 | makefirstname(self); 176 | } 177 | setlastname(self,lastname); 178 | setfullname(self,NULL); 179 | } 180 | -------------------------------------------------------------------------------- /Example/person.h: -------------------------------------------------------------------------------- 1 | #ifndef __PERSON_H__ 2 | #define __PERSON_H__ 3 | 4 | typedef struct __Person Person; 5 | typedef struct __Person* PersonRef; 6 | 7 | struct __Person { 8 | char *fullname; 9 | char *firstname; 10 | char *lastname; 11 | }; 12 | 13 | PersonRef Person_alloc(void); 14 | PersonRef Person_init(PersonRef); 15 | PersonRef Person_initWithName(PersonRef,char*); 16 | PersonRef Person_personWithName(char*); 17 | void Person_dealloc(PersonRef); 18 | char* Person_fullName(PersonRef); 19 | char* Person_firstName(PersonRef); 20 | char* Person_lastName(PersonRef); 21 | void Person_setFullName(PersonRef,char*); 22 | void Person_setFirstName(PersonRef,char*); 23 | void Person_setLastName(PersonRef,char*); 24 | 25 | #endif/*__PERSON_H__*/ 26 | -------------------------------------------------------------------------------- /Example/personTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "person.h" 3 | 4 | PersonRef personRef; 5 | 6 | static void setUp(void) 7 | { 8 | personRef = Person_personWithName("test tarou"); 9 | } 10 | 11 | static void tearDown(void) 12 | { 13 | Person_dealloc(personRef); 14 | } 15 | 16 | static void testfullname(void) 17 | { 18 | TEST_ASSERT_EQUAL_STRING("test tarou", Person_fullName(personRef)); 19 | } 20 | 21 | static void testfirstname(void) 22 | { 23 | TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); 24 | } 25 | 26 | static void testlastname(void) 27 | { 28 | TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); 29 | } 30 | 31 | static void testsetfullname(void) 32 | { 33 | Person_setFullName(personRef, "sample hanako"); 34 | 35 | TEST_ASSERT_EQUAL_STRING("sample hanako", Person_fullName(personRef)); 36 | TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); 37 | TEST_ASSERT_EQUAL_STRING("hanako", Person_lastName(personRef)); 38 | } 39 | 40 | static void testsetfirstname(void) 41 | { 42 | Person_setFirstName(personRef, "sample"); 43 | 44 | TEST_ASSERT_EQUAL_STRING("sample tarou", Person_fullName(personRef)); 45 | TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); 46 | TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); 47 | } 48 | 49 | static void testsetlastname(void) 50 | { 51 | Person_setLastName(personRef, "hanako"); 52 | 53 | TEST_ASSERT_EQUAL_STRING("test hanako", Person_fullName(personRef)); 54 | TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); 55 | TEST_ASSERT_EQUAL_STRING("hanako", Person_lastName(personRef)); 56 | } 57 | 58 | static void testnullcharfullname(void) 59 | { 60 | Person_setFullName(personRef, ""); 61 | 62 | TEST_ASSERT_EQUAL_STRING("", Person_fullName(personRef)); 63 | TEST_ASSERT_EQUAL_STRING("", Person_firstName(personRef)); 64 | TEST_ASSERT_EQUAL_STRING("", Person_lastName(personRef)); 65 | } 66 | 67 | static void testnullpointerfullname(void) 68 | { 69 | Person_setFullName(personRef, NULL); 70 | 71 | TEST_ASSERT_NULL(Person_fullName(personRef)); 72 | TEST_ASSERT_NULL(Person_firstName(personRef)); 73 | TEST_ASSERT_NULL(Person_lastName(personRef)); 74 | } 75 | 76 | static void testnosepfullname(void) 77 | { 78 | Person_setFullName(personRef, "sample"); 79 | 80 | TEST_ASSERT_EQUAL_STRING("sample", Person_fullName(personRef)); 81 | TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); 82 | TEST_ASSERT_EQUAL_STRING("", Person_lastName(personRef)); 83 | 84 | Person_setLastName(personRef, "tarou"); 85 | TEST_ASSERT_EQUAL_STRING("sample tarou", Person_fullName(personRef)); 86 | TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); 87 | TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); 88 | 89 | Person_setFirstName(personRef, "test"); 90 | TEST_ASSERT_EQUAL_STRING("test tarou", Person_fullName(personRef)); 91 | TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); 92 | TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); 93 | } 94 | 95 | TestRef PersonTest_tests(void) 96 | { 97 | EMB_UNIT_TESTFIXTURES(fixtures) { 98 | new_TestFixture("testfullname",testfullname), 99 | new_TestFixture("testfirstname",testfirstname), 100 | new_TestFixture("testlastname",testlastname), 101 | new_TestFixture("testsetfullname",testsetfullname), 102 | new_TestFixture("testsetfirstname",testsetfirstname), 103 | new_TestFixture("testsetlastname",testsetlastname), 104 | new_TestFixture("testnullcharfullname",testnullcharfullname), 105 | new_TestFixture("testnullpointerfullname",testnullpointerfullname), 106 | new_TestFixture("testnosepfullname",testnosepfullname), 107 | }; 108 | EMB_UNIT_TESTCALLER(PersonTest,"PersonTest",setUp,tearDown,fixtures); 109 | 110 | return (TestRef)&PersonTest; 111 | } 112 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | COPYRIGHT AND PERMISSION NOTICE 2 | =============================== 3 | 4 | Copyright (c) 2003 Embedded Unit Project 5 | 6 | All rights reserved. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | "Software"), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, and/or sell copies of the Software, and to permit persons 13 | to whom the Software is furnished to do so, provided that the above 14 | copyright notice(s) and this permission notice appear in all copies 15 | of the Software and that both the above copyright notice(s) and this 16 | permission notice appear in supporting documentation. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | 28 | Except as contained in this notice, the name of a copyright holder 29 | shall not be used in advertising or otherwise to promote the sale, 30 | use or other dealings in this Software without prior written 31 | authorization of the copyright holder. 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Embedded Unit 2 | ============= 3 | 4 | Clone of [Embedded Unit](https://sourceforge.net/projects/embunit/) project. 5 | 6 | Embedded Unit is unit testing framework for Embedded C System. It's design was 7 | copied from JUnit and CUnit and more, and then adapted somewhat for Embedded C 8 | System. Embedded Unit does not require std C libs. All objects are allocated 9 | to const area. 10 | 11 | Development environment and Execution environment 12 | ------------------------------------------------- 13 | 14 | Required execution environment 15 | 16 | - The ROM more than 2KB 17 | - The Stack more than 128b 18 | 19 | Required development environment 20 | 21 | - C Compiler 22 | 23 | Development of Embedded Unit is performed in the following environment 24 | 25 | - Microsoft Windows XP Professional 26 | - VC++.NET or cygwin 1.3.22 + gcc 3.2 27 | - Microsoft Windows 98 28 | - VC++6.0 29 | - Apple Computer MacOS X 10.1.5 30 | - Project Builder 1.1.1 (gcc 2.95.2) 31 | 32 | Compile 33 | ------- 34 | 35 | Embedded Unit is using stdio print function for the output of a test 36 | result message. Implement the following function, if you do not want 37 | to use stdio print function. 38 | 39 | void stdimpl_print(const char *string) 40 | // * this function does not output a new-line in the end of a string. 41 | 42 | And then add compile-option `'-DNO_STDIO_PRINTF'`, or release the following 43 | comments of a `embUnit/config.h`. 44 | 45 | /*#define NO_STDIO_PRINTF*/ 46 | 47 | License 48 | ------- 49 | 50 | Licensed under original project MIT/X Consortium License. -------------------------------------------------------------------------------- /Tests/AllTests.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern TestRef assertTest_tests(void); 4 | extern TestRef stdImplTest_tests(void); 5 | extern TestRef TestCaseTest_tests(void); 6 | extern TestRef TestCallerTest_tests(void); 7 | extern TestRef TestResultTest_tests(void); 8 | extern TestRef RepeatedTestTest_tests(void); 9 | 10 | int main (int argc, const char* argv[]) 11 | { 12 | TestRunner_start(); 13 | TestRunner_runTest(assertTest_tests()); 14 | TestRunner_runTest(stdImplTest_tests()); 15 | TestRunner_runTest(TestCaseTest_tests()); 16 | TestRunner_runTest(TestCallerTest_tests()); 17 | TestRunner_runTest(TestResultTest_tests()); 18 | TestRunner_runTest(RepeatedTestTest_tests()); 19 | TestRunner_end(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Tests/MockTestCase.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MockTestCase.h" 3 | 4 | static void runTest(void) 5 | { 6 | } 7 | 8 | TestCaseRef MockTestCase_case(void) 9 | { 10 | EMB_UNIT_TESTCASE(MockTestCase,"MockTestCase",NULL,NULL,runTest); 11 | return (TestCaseRef)&MockTestCase; 12 | } 13 | -------------------------------------------------------------------------------- /Tests/MockTestCase.h: -------------------------------------------------------------------------------- 1 | #ifndef __MOCKTESTCASE_H__ 2 | #define __MOCKTESTCASE_H__ 3 | 4 | TestCaseRef MockTestCase_case(void); 5 | 6 | #endif/*__MOCKTESTCASE_H__*/ 7 | -------------------------------------------------------------------------------- /Tests/RepeatedTestTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MockTestCase.h" 3 | 4 | static void setUp(void) 5 | { 6 | } 7 | 8 | static void tearDown(void) 9 | { 10 | } 11 | 12 | static void testRepeatedOnce(void) 13 | { 14 | RepeatedTest test = new_RepeatedTest(MockTestCase_case(),1); 15 | TestResult result = new_TestResult(NULL); 16 | 17 | test.isa->run(&test,&result); 18 | 19 | TEST_ASSERT_EQUAL_INT(1, result.runCount); 20 | TEST_ASSERT_EQUAL_INT(1, test.isa->countTestCases(&test)); 21 | } 22 | 23 | static void testRepeatedMoreThanOnce(void) 24 | { 25 | RepeatedTest test = new_RepeatedTest(MockTestCase_case(),100); 26 | TestResult result = new_TestResult(NULL); 27 | 28 | test.isa->run(&test,&result); 29 | 30 | 31 | TEST_ASSERT_EQUAL_INT(100, result.runCount); 32 | TEST_ASSERT_EQUAL_INT(100, test.isa->countTestCases(&test)); 33 | } 34 | 35 | static void testRepeatedZero(void) 36 | { 37 | RepeatedTest test = new_RepeatedTest(MockTestCase_case(),0); 38 | TestResult result = new_TestResult(NULL); 39 | 40 | test.isa->run(&test,&result); 41 | 42 | 43 | TEST_ASSERT_EQUAL_INT(0, result.runCount); 44 | TEST_ASSERT_EQUAL_INT(0, test.isa->countTestCases(&test)); 45 | } 46 | 47 | TestRef RepeatedTestTest_tests(void) 48 | { 49 | EMB_UNIT_TESTFIXTURES(fixtures) { 50 | new_TestFixture("testRepeatedOnce",testRepeatedOnce), 51 | new_TestFixture("testRepeatedMoreThanOnce",testRepeatedMoreThanOnce), 52 | new_TestFixture("testRepeatedZero",testRepeatedZero), 53 | }; 54 | EMB_UNIT_TESTCALLER(RepeatedTestTest,"RepeatedTestTest",setUp,tearDown,fixtures); 55 | 56 | return (TestRef)&RepeatedTestTest; 57 | } 58 | -------------------------------------------------------------------------------- /Tests/TestCallerTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void setUp(void) 4 | { 5 | } 6 | 7 | static void tearDown(void) 8 | { 9 | } 10 | 11 | static void testOneFixture(void) 12 | { 13 | TestFixture fixtures[] = { 14 | new_TestFixture(NULL,NULL), 15 | }; 16 | TestCaller caller = new_TestCaller(NULL,NULL,NULL,1,fixtures); 17 | TestResult result = new_TestResult(NULL); 18 | 19 | caller.isa->run(&caller,&result); 20 | 21 | TEST_ASSERT_EQUAL_INT(1, result.runCount); 22 | TEST_ASSERT_EQUAL_INT(1, caller.isa->countTestCases(&caller)); 23 | } 24 | 25 | static void testMoreThanOne(void) 26 | { 27 | TestFixture fixtures[] = { 28 | new_TestFixture(NULL,NULL), 29 | new_TestFixture(NULL,NULL), 30 | new_TestFixture(NULL,NULL), 31 | new_TestFixture(NULL,NULL), 32 | new_TestFixture(NULL,NULL), 33 | }; 34 | TestCaller caller = new_TestCaller(NULL,NULL,NULL,5,fixtures); 35 | TestResult result = new_TestResult(NULL); 36 | 37 | caller.isa->run(&caller,&result); 38 | 39 | TEST_ASSERT_EQUAL_INT(5, result.runCount); 40 | TEST_ASSERT_EQUAL_INT(5, caller.isa->countTestCases(&caller)); 41 | } 42 | 43 | static void testZeroFixture(void) 44 | { 45 | TestCaller caller = new_TestCaller(NULL,NULL,NULL,0,NULL); 46 | TestResult result = new_TestResult(NULL); 47 | 48 | caller.isa->run(&caller,&result); 49 | 50 | TEST_ASSERT_EQUAL_INT(0, result.runCount); 51 | TEST_ASSERT_EQUAL_INT(0, caller.isa->countTestCases(&caller)); 52 | } 53 | 54 | TestRef TestCallerTest_tests(void) 55 | { 56 | EMB_UNIT_TESTFIXTURES(fixtures) { 57 | new_TestFixture("testOneFixture",testOneFixture), 58 | new_TestFixture("testMoreThanOne",testMoreThanOne), 59 | new_TestFixture("testZeroFixture",testZeroFixture), 60 | }; 61 | EMB_UNIT_TESTCALLER(TestCallerTest,"TestCallerTest",setUp,tearDown,fixtures); 62 | 63 | return (TestRef)&TestCallerTest; 64 | } 65 | -------------------------------------------------------------------------------- /Tests/TestCaseTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MockTestCase.h" 3 | 4 | static void setUp(void) 5 | { 6 | } 7 | 8 | static void tearDown(void) 9 | { 10 | } 11 | 12 | static void testName(void) 13 | { 14 | TestCaseRef mock = MockTestCase_case(); 15 | TEST_ASSERT_EQUAL_STRING("MockTestCase", mock->isa->name(mock)); 16 | } 17 | 18 | static void testCountTestCases(void) 19 | { 20 | TestCaseRef mock = MockTestCase_case(); 21 | TEST_ASSERT_EQUAL_INT(1, mock->isa->countTestCases(mock)); 22 | } 23 | 24 | static void success_runTest(void) 25 | { 26 | } 27 | 28 | static void testSuccess(void) 29 | { 30 | TestCase tcase = new_TestCase("success",NULL,NULL,success_runTest); 31 | TestResult result = new_TestResult(NULL); 32 | 33 | tcase.isa->run(&tcase,&result); 34 | 35 | TEST_ASSERT_EQUAL_INT(1, result.runCount); 36 | TEST_ASSERT_EQUAL_INT(0, result.failureCount); 37 | } 38 | 39 | static void failure_runTest(void) 40 | { 41 | TEST_FAIL(""); 42 | } 43 | 44 | static void testFailure(void) 45 | { 46 | TestCase tcase = new_TestCase("failure",NULL,NULL,failure_runTest); 47 | TestResult result = new_TestResult(NULL); 48 | 49 | tcase.isa->run(&tcase,&result); 50 | 51 | TEST_ASSERT_EQUAL_INT(1, result.runCount); 52 | TEST_ASSERT_EQUAL_INT(1, result.failureCount); 53 | } 54 | 55 | TestRef TestCaseTest_tests(void) 56 | { 57 | EMB_UNIT_TESTFIXTURES(fixtures) { 58 | new_TestFixture("testName",testName), 59 | new_TestFixture("testCountTestCases",testCountTestCases), 60 | new_TestFixture("testSuccess",testSuccess), 61 | new_TestFixture("testFailure",testFailure), 62 | }; 63 | EMB_UNIT_TESTCALLER(TestCaseTest,"TestCaseTest",setUp,tearDown,fixtures); 64 | 65 | return (TestRef)&TestCaseTest; 66 | } 67 | -------------------------------------------------------------------------------- /Tests/TestResultTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void setUp(void) 4 | { 5 | } 6 | 7 | static void tearDown(void) 8 | { 9 | } 10 | 11 | static void testTestResult_result(void) 12 | { 13 | TestResult result = new_TestResult(NULL); 14 | 15 | TEST_ASSERT_EQUAL_INT(0, result.runCount); 16 | TEST_ASSERT_EQUAL_INT(0, result.failureCount); 17 | } 18 | 19 | static void testTestResult_startTest(void) 20 | { 21 | TestResult result = new_TestResult(NULL); 22 | 23 | TestResult_startTest(&result,NULL); 24 | 25 | TEST_ASSERT_EQUAL_INT(1, result.runCount); 26 | TEST_ASSERT_EQUAL_INT(0, result.failureCount); 27 | } 28 | 29 | static void testTestResult_endTest(void) 30 | { 31 | TestResult result = new_TestResult(NULL); 32 | 33 | TestResult_endTest(&result,NULL); 34 | 35 | TEST_ASSERT_EQUAL_INT(0, result.runCount); 36 | TEST_ASSERT_EQUAL_INT(0, result.failureCount); 37 | } 38 | 39 | static void testTestResult_addFailure(void) 40 | { 41 | TestResult result = new_TestResult(NULL); 42 | 43 | TestResult_addFailure(&result,NULL,"",0,""); 44 | 45 | TEST_ASSERT_EQUAL_INT(0, result.runCount); 46 | TEST_ASSERT_EQUAL_INT(1, result.failureCount); 47 | } 48 | 49 | TestRef TestResultTest_tests(void) 50 | { 51 | EMB_UNIT_TESTFIXTURES(fixtures) { 52 | new_TestFixture("testTestResult_result",testTestResult_result), 53 | new_TestFixture("testTestResult_startTest",testTestResult_startTest), 54 | new_TestFixture("testTestResult_endTest",testTestResult_endTest), 55 | new_TestFixture("testTestResult_addFailure",testTestResult_addFailure), 56 | }; 57 | EMB_UNIT_TESTCALLER(TestResultTest,"TestResultTest",setUp,tearDown,fixtures); 58 | 59 | return (TestRef)&TestResultTest; 60 | } 61 | -------------------------------------------------------------------------------- /Tests/Tests.cppproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 6.0 6 | com.Atmel.AVRGCC8 7 | {4f0a5c01-6ffe-4ffb-a9c1-ac7744427963} 8 | ATmega328P 9 | none 10 | Executable 11 | CPP 12 | $(MSBuildProjectName) 13 | .elf 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | Tests 16 | Tests 17 | Tests 18 | Native 19 | true 20 | false 21 | 22 | 0 23 | 24 | com.atmel.avrdbg.tool.simulator 25 | 26 | com.atmel.avrdbg.tool.simulator 27 | AVR Simulator 28 | 29 | 30 | true 31 | false 32 | 33 | 34 | 35 | 127.0.0.1 36 | 49544 37 | False 38 | 39 | 40 | 3.1.3 41 | 42 | 43 | 44 | 45 | True 46 | True 47 | True 48 | True 49 | True 50 | 51 | 52 | ../.. 53 | 54 | 55 | Optimize for size (-Os) 56 | True 57 | True 58 | True 59 | True 60 | True 61 | True 62 | 63 | 64 | ../.. 65 | 66 | 67 | Optimize for size (-Os) 68 | True 69 | True 70 | True 71 | True 72 | 73 | 74 | m 75 | embUnit 76 | 77 | 78 | 79 | 80 | ../../embUnit/Release 81 | 82 | 83 | True 84 | 85 | 86 | 87 | 88 | 89 | 90 | True 91 | True 92 | True 93 | True 94 | True 95 | 96 | 97 | ../.. 98 | 99 | 100 | Optimize (-O1) 101 | True 102 | True 103 | True 104 | Default (-g2) 105 | True 106 | True 107 | True 108 | 109 | 110 | ../.. 111 | 112 | 113 | Optimize (-O1) 114 | True 115 | True 116 | True 117 | Default (-g2) 118 | True 119 | 120 | 121 | m 122 | embUnit 123 | 124 | 125 | 126 | 127 | ../../embUnit/Debug 128 | 129 | 130 | True 131 | Default (-Wa,-g) 132 | 133 | 134 | 135 | 136 | 137 | compile 138 | 139 | 140 | compile 141 | 142 | 143 | compile 144 | 145 | 146 | compile 147 | 148 | 149 | compile 150 | 151 | 152 | compile 153 | 154 | 155 | compile 156 | 157 | 158 | compile 159 | 160 | 161 | compile 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /Tests/assertTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void setUp(void) 4 | { 5 | } 6 | 7 | static void tearDown(void) 8 | { 9 | } 10 | 11 | static void verify(TestCaseRef test) 12 | { 13 | TestResult result = new_TestResult(NULL); 14 | 15 | test->isa->run(test,&result); 16 | 17 | if (result.failureCount == 0) { 18 | TEST_FAIL("fail"); 19 | } 20 | } 21 | 22 | static void assert_equal_string_runTest(void) 23 | { 24 | TEST_ASSERT_EQUAL_STRING("123","456"); 25 | } 26 | 27 | static void assert_equal_int_runTest(void) 28 | { 29 | TEST_ASSERT_EQUAL_INT(123,456); 30 | } 31 | 32 | static void assert_null_runTest(void) 33 | { 34 | char *p=""; 35 | TEST_ASSERT_NULL(p); 36 | } 37 | 38 | static void assert_not_null_runTest(void) 39 | { 40 | char *p=NULL; 41 | TEST_ASSERT_NOT_NULL(p); 42 | } 43 | 44 | static void assert_message_runTest(void) 45 | { 46 | TEST_ASSERT_MESSAGE(0,"0"); 47 | } 48 | 49 | static void assert_runTest(void) 50 | { 51 | TEST_ASSERT(0); 52 | } 53 | 54 | static void testASSERT_EQUAL_STRING(void) 55 | { 56 | TestCase tcase = new_TestCase("assert_equal_string",NULL,NULL,assert_equal_string_runTest); 57 | verify(&tcase); 58 | } 59 | 60 | static void testASSERT_EQUAL_INT(void) 61 | { 62 | TestCase tcase = new_TestCase("assert_equal_int",NULL,NULL,assert_equal_int_runTest); 63 | verify(&tcase); 64 | } 65 | 66 | static void testASSERT_NULL(void) 67 | { 68 | TestCase tcase = new_TestCase("assert_null",NULL,NULL,assert_null_runTest); 69 | verify(&tcase); 70 | } 71 | 72 | static void testASSERT_NOT_NULL(void) 73 | { 74 | TestCase tcase = new_TestCase("assert_not_null",NULL,NULL,assert_not_null_runTest); 75 | verify(&tcase); 76 | } 77 | 78 | static void testASSERT_MESSAGE(void) 79 | { 80 | TestCase tcase = new_TestCase("assert_message",NULL,NULL,assert_message_runTest); 81 | verify(&tcase); 82 | } 83 | 84 | static void testASSERT(void) 85 | { 86 | TestCase tcase = new_TestCase("assert",NULL,NULL,assert_runTest); 87 | verify(&tcase); 88 | } 89 | 90 | TestRef assertTest_tests(void) 91 | { 92 | EMB_UNIT_TESTFIXTURES(fixtures) { 93 | new_TestFixture("testASSERT_EQUAL_STRING",testASSERT_EQUAL_STRING), 94 | new_TestFixture("testASSERT_EQUAL_INT",testASSERT_EQUAL_INT), 95 | new_TestFixture("testASSERT_NULL",testASSERT_NULL), 96 | new_TestFixture("testASSERT_NOT_NULL",testASSERT_NOT_NULL), 97 | new_TestFixture("testASSERT_MESSAGE",testASSERT_MESSAGE), 98 | new_TestFixture("testASSERT",testASSERT), 99 | }; 100 | EMB_UNIT_TESTCALLER(AssertTest,"AssertTest",setUp,tearDown,fixtures); 101 | 102 | return (TestRef)&AssertTest; 103 | } 104 | -------------------------------------------------------------------------------- /Tests/stdImplTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void setUp(void) 4 | { 5 | } 6 | 7 | static void tearDown(void) 8 | { 9 | } 10 | 11 | static void teststrcpy(void) 12 | { 13 | char buf[32]; 14 | char *p; 15 | 16 | p = stdimpl_strcpy(buf, "test"); 17 | TEST_ASSERT_EQUAL_STRING("test", buf); 18 | TEST_ASSERT( p == buf ); 19 | } 20 | 21 | static void teststrcat(void) 22 | { 23 | char buf[64]; 24 | 25 | stdimpl_strcpy(buf,"sample"); 26 | stdimpl_strcat(buf," extra string"); 27 | TEST_ASSERT_EQUAL_STRING("sample extra string", buf); 28 | 29 | stdimpl_strcpy(buf,""); 30 | stdimpl_strcat(buf,"sample"); 31 | TEST_ASSERT_EQUAL_STRING("sample", buf); 32 | } 33 | 34 | static void teststrncat(void) 35 | { 36 | char buf[64]; 37 | 38 | stdimpl_strcpy(buf,"sample"); 39 | stdimpl_strncat(buf," extra string",13); 40 | TEST_ASSERT_EQUAL_STRING("sample extra string", buf); 41 | 42 | stdimpl_strcpy(buf,"This is the initial string!"); 43 | stdimpl_strncat(buf," extra text to add to the string", 19); 44 | TEST_ASSERT_EQUAL_STRING("This is the initial string! extra text to add ", buf); 45 | } 46 | 47 | static void teststrlen(void) 48 | { 49 | TEST_ASSERT( stdimpl_strlen("test")==4 ); 50 | TEST_ASSERT( stdimpl_strlen("")==0 ); 51 | } 52 | 53 | static void teststrcmp(void) 54 | { 55 | TEST_ASSERT( stdimpl_strcmp("aaa","aaa") == 0 ); 56 | TEST_ASSERT( stdimpl_strcmp("aaa","bbb") != 0 ); 57 | TEST_ASSERT( stdimpl_strcmp("aaa","AAA") != 0 ); 58 | TEST_ASSERT( stdimpl_strcmp("Test","TestCase") != 0 ); 59 | TEST_ASSERT( stdimpl_strcmp("TestCase","Test") != 0 ); 60 | TEST_ASSERT( stdimpl_strcmp("","") == 0 ); 61 | } 62 | 63 | static void testitoa(void) 64 | { 65 | char buf[33]; 66 | char *p; 67 | 68 | p = stdimpl_itoa(10, buf, 2); 69 | TEST_ASSERT_EQUAL_STRING("1010", buf); 70 | TEST_ASSERT(p == buf); 71 | 72 | p = stdimpl_itoa(10, buf, 8); 73 | TEST_ASSERT_EQUAL_STRING("12", buf); 74 | TEST_ASSERT(p == buf); 75 | 76 | p = stdimpl_itoa(10, buf, 10); 77 | TEST_ASSERT_EQUAL_STRING("10", buf); 78 | TEST_ASSERT(p == buf); 79 | 80 | p = stdimpl_itoa(10, buf, 16); 81 | TEST_ASSERT_EQUAL_STRING("a", buf); 82 | TEST_ASSERT(p == buf); 83 | 84 | p = stdimpl_itoa(-10, buf, 2); 85 | TEST_ASSERT_EQUAL_STRING("11111111111111111111111111110110", buf); 86 | TEST_ASSERT(p == buf); 87 | 88 | p = stdimpl_itoa(-10, buf, 8); 89 | TEST_ASSERT_EQUAL_STRING("37777777766", buf); 90 | TEST_ASSERT(p == buf); 91 | 92 | p = stdimpl_itoa(-10, buf, 10); 93 | TEST_ASSERT_EQUAL_STRING("-10", buf); 94 | TEST_ASSERT(p == buf); 95 | 96 | p = stdimpl_itoa(-10, buf, 16); 97 | TEST_ASSERT_EQUAL_STRING("fffffff6", buf); 98 | TEST_ASSERT(p == buf); 99 | } 100 | 101 | TestRef stdImplTest_tests(void) 102 | { 103 | EMB_UNIT_TESTFIXTURES(fixtures) { 104 | new_TestFixture("teststrcpy",teststrcpy), 105 | new_TestFixture("teststrcat",teststrcat), 106 | new_TestFixture("teststrncat",teststrncat), 107 | new_TestFixture("teststrlen",teststrlen), 108 | new_TestFixture("teststrcmp",teststrcmp), 109 | new_TestFixture("testitoa",testitoa), 110 | }; 111 | EMB_UNIT_TESTCALLER(StdImplTest,"stdImplTest",setUp,tearDown,fixtures); 112 | 113 | return (TestRef)&StdImplTest; 114 | } 115 | -------------------------------------------------------------------------------- /TextUI/CompilerOutputter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: CompilerOutputter.c,v 1.2 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #include 36 | #include "CompilerOutputter.h" 37 | 38 | static void CompilerOutputter_printHeader(OutputterRef self,TestRef test) 39 | { 40 | } 41 | 42 | static void CompilerOutputter_printStartTest(OutputterRef self,TestRef test) 43 | { 44 | } 45 | 46 | static void CompilerOutputter_printEndTest(OutputterRef self,TestRef test) 47 | { 48 | } 49 | 50 | static void CompilerOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) 51 | { 52 | } 53 | 54 | static void CompilerOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) 55 | { 56 | fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg); 57 | } 58 | 59 | static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result) 60 | { 61 | } 62 | 63 | static const OutputterImplement CompilerOutputterImplement = { 64 | (OutputterPrintHeaderFunction) CompilerOutputter_printHeader, 65 | (OutputterPrintStartTestFunction) CompilerOutputter_printStartTest, 66 | (OutputterPrintEndTestFunction) CompilerOutputter_printEndTest, 67 | (OutputterPrintSuccessfulFunction) CompilerOutputter_printSuccessful, 68 | (OutputterPrintFailureFunction) CompilerOutputter_printFailure, 69 | (OutputterPrintStatisticsFunction) CompilerOutputter_printStatistics, 70 | }; 71 | 72 | static const Outputter CompilerOutputter = { 73 | (OutputterImplementRef)&CompilerOutputterImplement, 74 | }; 75 | 76 | OutputterRef CompilerOutputter_outputter(void) 77 | { 78 | return (OutputterRef)&CompilerOutputter; 79 | } 80 | -------------------------------------------------------------------------------- /TextUI/CompilerOutputter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: CompilerOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #ifndef __COMPILEROUTPUTTER_H__ 36 | #define __COMPILEROUTPUTTER_H__ 37 | 38 | #include "Outputter.h" 39 | 40 | OutputterRef CompilerOutputter_outputter(void); 41 | 42 | #endif/*__COMPILEROUTPUTTER_H__*/ 43 | -------------------------------------------------------------------------------- /TextUI/Outputter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: Outputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #ifndef __OUTPUTTER_H__ 36 | #define __OUTPUTTER_H__ 37 | 38 | #include 39 | 40 | typedef struct __OutputterImplement OutputterImplement; 41 | typedef struct __OutputterImplement* OutputterImplementRef; 42 | 43 | typedef void(*OutputterPrintHeaderFunction)(void*); 44 | typedef void(*OutputterPrintStartTestFunction)(void*,TestRef); 45 | typedef void(*OutputterPrintEndTestFunction)(void*,TestRef); 46 | typedef void(*OutputterPrintSuccessfulFunction)(void*,TestRef,int); 47 | typedef void(*OutputterPrintFailureFunction)(void*,TestRef,char*,int,char*,int); 48 | typedef void(*OutputterPrintStatisticsFunction)(void*,TestResultRef); 49 | 50 | 51 | struct __OutputterImplement { 52 | OutputterPrintHeaderFunction printHeader; 53 | OutputterPrintStartTestFunction printStartTest; 54 | OutputterPrintEndTestFunction printEndTest; 55 | OutputterPrintSuccessfulFunction printSuccessful; 56 | OutputterPrintFailureFunction printFailure; 57 | OutputterPrintStatisticsFunction printStatistics; 58 | }; 59 | 60 | typedef struct __Outputter Outputter; 61 | typedef struct __Outputter* OutputterRef; 62 | 63 | struct __Outputter { 64 | OutputterImplementRef isa; 65 | }; 66 | 67 | #define Outputter_printHeader(o) (o)->isa->printHeader(o) 68 | #define Outputter_printStartTest(o,t) (o)->isa->printStartTest(o,t) 69 | #define Outputter_printEndTest(o,t) (o)->isa->printEndTest(o,t) 70 | #define Outputter_printSuccessful(o,t,c) (o)->isa->printSuccessful(o,t,c) 71 | #define Outputter_printFailure(o,t,m,l,f,c) (o)->isa->printFailure(o,t,m,l,f,c) 72 | #define Outputter_printStatistics(o,r) (o)->isa->printStatistics(o,r) 73 | 74 | #endif/*__OUTPUTTER_H__*/ 75 | -------------------------------------------------------------------------------- /TextUI/TextOutputter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TextOutputter.c,v 1.4 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #include 36 | #include "TextOutputter.h" 37 | 38 | static void TextOutputter_printHeader(OutputterRef self) 39 | { 40 | } 41 | 42 | static void TextOutputter_printStartTest(OutputterRef self,TestRef test) 43 | { 44 | fprintf(stdout,"- %s\n",Test_name(test)); 45 | } 46 | 47 | static void TextOutputter_printEndTest(OutputterRef self,TestRef test) 48 | { 49 | } 50 | 51 | static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) 52 | { 53 | fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test)); 54 | } 55 | 56 | static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) 57 | { 58 | fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg); 59 | } 60 | 61 | static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result) 62 | { 63 | if (result->failureCount) { 64 | fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount); 65 | } else { 66 | fprintf(stdout,"\nOK (%d tests)\n",result->runCount); 67 | } 68 | } 69 | 70 | static const OutputterImplement TextOutputterImplement = { 71 | (OutputterPrintHeaderFunction) TextOutputter_printHeader, 72 | (OutputterPrintStartTestFunction) TextOutputter_printStartTest, 73 | (OutputterPrintEndTestFunction) TextOutputter_printEndTest, 74 | (OutputterPrintSuccessfulFunction) TextOutputter_printSuccessful, 75 | (OutputterPrintFailureFunction) TextOutputter_printFailure, 76 | (OutputterPrintStatisticsFunction) TextOutputter_printStatistics, 77 | }; 78 | 79 | static const Outputter TextOutputter = { 80 | (OutputterImplementRef)&TextOutputterImplement, 81 | }; 82 | 83 | OutputterRef TextOutputter_outputter(void) 84 | { 85 | return (OutputterRef)&TextOutputter; 86 | } 87 | -------------------------------------------------------------------------------- /TextUI/TextOutputter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TextOutputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #ifndef __TEXTOUTPUTTER_H__ 36 | #define __TEXTOUTPUTTER_H__ 37 | 38 | #include "Outputter.h" 39 | 40 | OutputterRef TextOutputter_outputter(void); 41 | 42 | #endif/*__TEXTOUTPUTTER_H__*/ 43 | -------------------------------------------------------------------------------- /TextUI/TextUI.cproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 6.0 6 | com.Atmel.AVRGCC8 7 | dce6c7e3-ee26-4d79-826b-08594b9ad897 8 | ATmega328P 9 | none 10 | StaticLibrary 11 | C 12 | lib$(MSBuildProjectName) 13 | .a 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | 16 | 17 | TextUI 18 | TextUI 19 | TextUI 20 | Native 21 | 3.1.3 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | True 31 | True 32 | True 33 | 34 | 35 | ../.. 36 | 37 | 38 | True 39 | True 40 | 41 | 42 | 43 | 44 | 45 | compile 46 | 47 | 48 | compile 49 | 50 | 51 | compile 52 | 53 | 54 | compile 55 | 56 | 57 | compile 58 | 59 | 60 | compile 61 | 62 | 63 | compile 64 | 65 | 66 | compile 67 | 68 | 69 | compile 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /TextUI/TextUIRunner.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TextUIRunner.c,v 1.4 2004/02/10 16:20:43 arms22 Exp $ 34 | */ 35 | #include "TextOutputter.h" 36 | #include "TextUIRunner.h" 37 | 38 | /* Private 39 | */ 40 | static TestResult result_; 41 | static OutputterRef outputterRef_ = 0; 42 | static int wasfailure_ = 0; 43 | 44 | static void TextUIRunner_startTest(TestListnerRef self,TestRef test) 45 | { 46 | wasfailure_ = 0; 47 | } 48 | 49 | static void TextUIRunner_endTest(TestListnerRef self,TestRef test) 50 | { 51 | if (!wasfailure_) 52 | Outputter_printSuccessful(outputterRef_,test,result_.runCount); 53 | } 54 | 55 | static void TextUIRunner_addFailure(TestListnerRef self,TestRef test,char *msg,int line,char *file) 56 | { 57 | wasfailure_ = 1; 58 | Outputter_printFailure(outputterRef_,test,msg,line,file,result_.runCount); 59 | } 60 | 61 | static const TestListnerImplement TextUIRunnerImplement = { 62 | (TestListnerStartTestCallBack) TextUIRunner_startTest, 63 | (TestListnerEndTestCallBack) TextUIRunner_endTest, 64 | (TestListnerAddFailureCallBack) TextUIRunner_addFailure, 65 | }; 66 | 67 | static const TestListner testuirunner_ = { 68 | (TestListnerImplement*)&TextUIRunnerImplement, 69 | }; 70 | 71 | /* Public 72 | */ 73 | void TextUIRunner_setOutputter(OutputterRef outputter) 74 | { 75 | outputterRef_ = outputter; 76 | } 77 | 78 | void TextUIRunner_startWithOutputter(OutputterRef outputter) 79 | { 80 | TestResult_init(&result_, (TestListnerRef)&testuirunner_); 81 | TextUIRunner_setOutputter(outputter); 82 | Outputter_printHeader(outputter); 83 | 84 | } 85 | 86 | void TextUIRunner_start(void) 87 | { 88 | if (!outputterRef_) 89 | outputterRef_ = TextOutputter_outputter(); 90 | TextUIRunner_startWithOutputter(outputterRef_); 91 | } 92 | 93 | void TextUIRunner_runTest(TestRef test) 94 | { 95 | Outputter_printStartTest(outputterRef_,test); 96 | Test_run(test, &result_); 97 | Outputter_printEndTest(outputterRef_,test); 98 | } 99 | 100 | void TextUIRunner_end(void) 101 | { 102 | Outputter_printStatistics(outputterRef_,&result_); 103 | } 104 | -------------------------------------------------------------------------------- /TextUI/TextUIRunner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TextUIRunner.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #ifndef __TEXTUIRUNNER_H__ 36 | #define __TEXTUIRUNNER_H__ 37 | 38 | #include 39 | 40 | void TextUIRunner_setOutputter(OutputterRef outputter); 41 | void TextUIRunner_startWithOutputter(OutputterRef outputter); 42 | void TextUIRunner_start(void); 43 | void TextUIRunner_runTest(TestRef test); 44 | void TextUIRunner_end(void); 45 | 46 | #endif/*__TEXTUIRUNNER_H__*/ 47 | -------------------------------------------------------------------------------- /TextUI/XMLOutputter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: XMLOutputter.c,v 1.6 2003/09/26 16:32:01 arms22 Exp $ 34 | */ 35 | #include 36 | #include "XMLOutputter.h" 37 | 38 | static char *stylesheet_; 39 | 40 | static void XMLOutputter_printHeader(OutputterRef self) 41 | { 42 | fprintf(stdout,"\n"); 43 | if (stylesheet_) 44 | fprintf(stdout,"\n",stylesheet_); 45 | fprintf(stdout,"\n"); 46 | } 47 | 48 | static void XMLOutputter_printStartTest(OutputterRef self,TestRef test) 49 | { 50 | fprintf(stdout,"<%s>\n",Test_name(test)); 51 | } 52 | 53 | static void XMLOutputter_printEndTest(OutputterRef self,TestRef test) 54 | { 55 | fprintf(stdout,"\n",Test_name(test)); 56 | } 57 | 58 | static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) 59 | { 60 | fprintf(stdout,"\n",runCount); 61 | fprintf(stdout,"%s\n",Test_name(test)); 62 | fprintf(stdout,"\n"); 63 | } 64 | 65 | static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) 66 | { 67 | fprintf(stdout,"\n",runCount); 68 | fprintf(stdout,"%s\n",Test_name(test)); 69 | fprintf(stdout,"\n"); 70 | fprintf(stdout,"%s\n",file); 71 | fprintf(stdout,"%d\n",line); 72 | fprintf(stdout,"\n"); 73 | fprintf(stdout,"%s\n",msg); 74 | fprintf(stdout,"\n"); 75 | } 76 | 77 | static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result) 78 | { 79 | fprintf(stdout,"\n"); 80 | fprintf(stdout,"%d\n",result->runCount); 81 | if (result->failureCount) { 82 | fprintf(stdout,"%d\n",result->failureCount); 83 | } 84 | fprintf(stdout,"\n"); 85 | fprintf(stdout,"\n"); 86 | } 87 | 88 | static const OutputterImplement XMLOutputterImplement = { 89 | (OutputterPrintHeaderFunction) XMLOutputter_printHeader, 90 | (OutputterPrintStartTestFunction) XMLOutputter_printStartTest, 91 | (OutputterPrintEndTestFunction) XMLOutputter_printEndTest, 92 | (OutputterPrintSuccessfulFunction) XMLOutputter_printSuccessful, 93 | (OutputterPrintFailureFunction) XMLOutputter_printFailure, 94 | (OutputterPrintStatisticsFunction) XMLOutputter_printStatistics, 95 | }; 96 | 97 | static const Outputter XMLOutputter = { 98 | (OutputterImplementRef)&XMLOutputterImplement, 99 | }; 100 | 101 | void XMLOutputter_setStyleSheet(char *style) 102 | { 103 | stylesheet_ = style; 104 | } 105 | 106 | OutputterRef XMLOutputter_outputter(void) 107 | { 108 | return (OutputterRef)&XMLOutputter; 109 | } 110 | -------------------------------------------------------------------------------- /TextUI/XMLOutputter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: XMLOutputter.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $ 34 | */ 35 | #ifndef __XMLOUTPUTTER_H__ 36 | #define __XMLOUTPUTTER_H__ 37 | 38 | #include "Outputter.h" 39 | 40 | void XMLOutputter_setStyleSheet(char *style); 41 | OutputterRef XMLOutputter_outputter(void); 42 | 43 | #endif/*__XMLOUTPUTTER_H__*/ 44 | -------------------------------------------------------------------------------- /embUnit.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "embUnit", "embUnit\embUnit.cproj", "{A3360898-4569-4689-AC93-9EB6A3534FF0}" 5 | EndProject 6 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "TextUI", "TextUI\TextUI.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {A3360898-4569-4689-AC93-9EB6A3534FF0} = {A3360898-4569-4689-AC93-9EB6A3534FF0} 9 | EndProjectSection 10 | EndProject 11 | Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "Example", "Example\Example.cppproj", "{4A4AC5C5-DAB1-4459-AF31-90AE023CC9E1}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {A3360898-4569-4689-AC93-9EB6A3534FF0} = {A3360898-4569-4689-AC93-9EB6A3534FF0} 14 | EndProjectSection 15 | EndProject 16 | Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "Tests", "Tests\Tests.cppproj", "{4F0A5C01-6FFE-4FFB-A9C1-AC7744427963}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {A3360898-4569-4689-AC93-9EB6A3534FF0} = {A3360898-4569-4689-AC93-9EB6A3534FF0} 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Debug|AVR = Debug|AVR 24 | Release|AVR = Release|AVR 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {A3360898-4569-4689-AC93-9EB6A3534FF0}.Debug|AVR.ActiveCfg = Debug|AVR 28 | {A3360898-4569-4689-AC93-9EB6A3534FF0}.Debug|AVR.Build.0 = Debug|AVR 29 | {A3360898-4569-4689-AC93-9EB6A3534FF0}.Release|AVR.ActiveCfg = Release|AVR 30 | {A3360898-4569-4689-AC93-9EB6A3534FF0}.Release|AVR.Build.0 = Release|AVR 31 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR 32 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR 33 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR 34 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR 35 | {4A4AC5C5-DAB1-4459-AF31-90AE023CC9E1}.Debug|AVR.ActiveCfg = Debug|AVR 36 | {4A4AC5C5-DAB1-4459-AF31-90AE023CC9E1}.Debug|AVR.Build.0 = Debug|AVR 37 | {4A4AC5C5-DAB1-4459-AF31-90AE023CC9E1}.Release|AVR.ActiveCfg = Release|AVR 38 | {4A4AC5C5-DAB1-4459-AF31-90AE023CC9E1}.Release|AVR.Build.0 = Release|AVR 39 | {4F0A5C01-6FFE-4FFB-A9C1-AC7744427963}.Debug|AVR.ActiveCfg = Debug|AVR 40 | {4F0A5C01-6FFE-4FFB-A9C1-AC7744427963}.Debug|AVR.Build.0 = Debug|AVR 41 | {4F0A5C01-6FFE-4FFB-A9C1-AC7744427963}.Release|AVR.ActiveCfg = Release|AVR 42 | {4F0A5C01-6FFE-4FFB-A9C1-AC7744427963}.Release|AVR.Build.0 = Release|AVR 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /embUnit/AssertImpl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: AssertImpl.c,v 1.5 2004/02/10 16:15:25 arms22 Exp $ 34 | */ 35 | #include "config.h" 36 | #include "stdImpl.h" 37 | #include "AssertImpl.h" 38 | 39 | void assertImplementationInt(int expected,int actual, long line, const char *file) 40 | { 41 | char buffer[32]; /*"exp -2147483647 was -2147483647"*/ 42 | char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/ 43 | 44 | stdimpl_strcpy(buffer, "exp "); 45 | 46 | { stdimpl_itoa(expected, numbuf, 10); 47 | stdimpl_strncat(buffer, numbuf, 11); } 48 | 49 | stdimpl_strcat(buffer, " was "); 50 | 51 | { stdimpl_itoa(actual, numbuf, 10); 52 | stdimpl_strncat(buffer, numbuf, 11); } 53 | 54 | addFailure(buffer, line, file); 55 | } 56 | 57 | void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file) 58 | { 59 | char buffer[ASSERT_STRING_BUFFER_MAX]; 60 | #define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */ 61 | int el; 62 | int al; 63 | 64 | if (expected) { 65 | el = stdimpl_strlen(expected); 66 | } else { 67 | el = 4; 68 | expected = "null"; 69 | } 70 | 71 | if (actual) { 72 | al = stdimpl_strlen(actual); 73 | } else { 74 | al = 4; 75 | actual = "null"; 76 | } 77 | if (el > exp_act_limit) { 78 | if (al > exp_act_limit) { 79 | al = exp_act_limit; 80 | el = exp_act_limit; 81 | } else { 82 | int w = exp_act_limit + (exp_act_limit - al); 83 | if (el > w) { 84 | el = w; 85 | } 86 | } 87 | } else { 88 | int w = exp_act_limit + (exp_act_limit - el); 89 | if (al > w) { 90 | al = w; 91 | } 92 | } 93 | stdimpl_strcpy(buffer, "exp \""); 94 | stdimpl_strncat(buffer, expected, el); 95 | stdimpl_strcat(buffer, "\" was \""); 96 | stdimpl_strncat(buffer, actual, al); 97 | stdimpl_strcat(buffer, "\""); 98 | 99 | addFailure(buffer, line, file); 100 | } 101 | -------------------------------------------------------------------------------- /embUnit/AssertImpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $ 34 | */ 35 | #ifndef __ASSERTIMPL_H__ 36 | #define __ASSERTIMPL_H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/ 43 | 44 | void assertImplementationInt(int expected,int actual, long line, const char *file); 45 | void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file); 46 | 47 | #define TEST_ASSERT_EQUAL_STRING(expected,actual)\ 48 | if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;} 49 | 50 | #define TEST_ASSERT_EQUAL_INT(expected,actual)\ 51 | if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;} 52 | 53 | #define TEST_ASSERT_NULL(pointer)\ 54 | TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.") 55 | 56 | #define TEST_ASSERT_NOT_NULL(pointer)\ 57 | TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.") 58 | 59 | #define TEST_ASSERT_MESSAGE(condition, message)\ 60 | if (condition) {} else {TEST_FAIL(message);} 61 | 62 | #define TEST_ASSERT(condition)\ 63 | if (condition) {} else {TEST_FAIL(#condition);} 64 | 65 | #define TEST_FAIL(message)\ 66 | if (0) {} else {addFailure(message,__LINE__,__FILE__);return;} 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif/*__ASSERTIMPL_H__*/ 73 | -------------------------------------------------------------------------------- /embUnit/HelperMacro.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __HELPERMACRO_H__ 36 | #define __HELPERMACRO_H__ 37 | 38 | #define EMB_UNIT_TESTCASE(ca,name,sup,tdw,run) \ 39 | static const TestCase ca = new_TestCase(name,sup,tdw,run) 40 | 41 | #define EMB_UNIT_TESTSUITE(su,name,array) \ 42 | static const TestSuite su = new_TestSuite(name,(Test**)array,sizeof(array)/sizeof(array[0])) 43 | 44 | #define EMB_UNIT_TESTREFS(tests) \ 45 | static Test* const tests[] = 46 | 47 | #define EMB_UNIT_ADD_TESTREF(testref) \ 48 | (Test*) testref 49 | 50 | #define EMB_UNIT_TESTCALLER(caller,name,sup,tdw,fixtures) \ 51 | static const TestCaller caller = new_TestCaller(name,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures) 52 | 53 | #define EMB_UNIT_TESTFIXTURES(fixtures) \ 54 | static const TestFixture fixtures[] = 55 | 56 | #define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \ 57 | static const RepeatedTest repeater = new_RepeatedTest(test,tmrp) 58 | 59 | #endif/*__HELPERMACRO_H__*/ 60 | -------------------------------------------------------------------------------- /embUnit/RepeatedTest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: RepeatedTest.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "Test.h" 36 | #include "RepeatedTest.h" 37 | 38 | char* RepeatedTest_name(RepeatedTest* self) 39 | { 40 | return Test_name(self->test); 41 | } 42 | 43 | void RepeatedTest_run(RepeatedTest* self,TestResult* result) 44 | { 45 | int i; 46 | Test* test = self->test; 47 | for (i=0; itimesRepeat; i++) { 48 | Test_run(test, result); 49 | } 50 | } 51 | 52 | int RepeatedTest_countTestCases(RepeatedTest* self) 53 | { 54 | return Test_countTestCases(self->test) * self->timesRepeat; 55 | } 56 | 57 | const TestImplement RepeatedTestImplement = { 58 | (TestNameFunction) RepeatedTest_name, 59 | (TestRunFunction) RepeatedTest_run, 60 | (TestCountTestCasesFunction)RepeatedTest_countTestCases, 61 | }; 62 | -------------------------------------------------------------------------------- /embUnit/RepeatedTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __REPEATEDTEST_H__ 36 | #define __REPEATEDTEST_H__ 37 | 38 | typedef struct __RepeatedTest RepeatedTest; 39 | typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/ 40 | 41 | struct __RepeatedTest { 42 | TestImplement* isa; 43 | Test* test; 44 | int timesRepeat; 45 | }; 46 | 47 | extern const TestImplement RepeatedTestImplement; 48 | 49 | #define new_RepeatedTest(test,tmrp)\ 50 | {\ 51 | (TestImplement*)&RepeatedTestImplement,\ 52 | (Test*)test,\ 53 | tmrp,\ 54 | } 55 | 56 | #endif/*__REPEATEDTEST_H__*/ 57 | -------------------------------------------------------------------------------- /embUnit/Test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TEST_H__ 36 | #define __TEST_H__ 37 | 38 | typedef struct __TestResult TestResult; 39 | typedef struct __TestResult* TestResultRef;/*downward compatible*/ 40 | 41 | typedef struct __TestImplement TestImplement; 42 | typedef struct __TestImplement* TestImplementRef;/*downward compatible*/ 43 | 44 | typedef char*(*TestNameFunction)(void*); 45 | typedef void(*TestRunFunction)(void*,TestResult*); 46 | typedef int(*TestCountTestCasesFunction)(void*); 47 | 48 | struct __TestImplement { 49 | TestNameFunction name; 50 | TestRunFunction run; 51 | TestCountTestCasesFunction countTestCases; 52 | }; 53 | 54 | typedef struct __Test Test; 55 | typedef struct __Test* TestRef;/*downward compatible*/ 56 | 57 | struct __Test { 58 | TestImplement* isa; 59 | }; 60 | 61 | #define Test_name(s) ((Test*)s)->isa->name(s) 62 | #define Test_run(s,r) ((Test*)s)->isa->run(s,r) 63 | #define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s) 64 | 65 | #endif/*__TEST_H__*/ 66 | -------------------------------------------------------------------------------- /embUnit/TestCaller.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestCaller.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "Test.h" 36 | #include "TestCase.h" 37 | #include "TestCaller.h" 38 | 39 | char* TestCaller_name(TestCaller* self) 40 | { 41 | return self->name; 42 | } 43 | 44 | void TestCaller_run(TestCaller* self,TestResult* result) 45 | { 46 | TestCase cs = new_TestCase(0,0,0,0); 47 | int i; 48 | cs.setUp= self->setUp; 49 | cs.tearDown = self->tearDown; 50 | for (i=0; inumberOfFixtuers; i++) { 51 | cs.name = self->fixtuers[i].name; 52 | cs.runTest = self->fixtuers[i].test; 53 | /*run test*/ 54 | Test_run(&cs,result); 55 | } 56 | } 57 | 58 | int TestCaller_countTestCases(TestCaller* self) 59 | { 60 | return self->numberOfFixtuers; 61 | } 62 | 63 | const TestImplement TestCallerImplement = { 64 | (TestNameFunction) TestCaller_name, 65 | (TestRunFunction) TestCaller_run, 66 | (TestCountTestCasesFunction)TestCaller_countTestCases, 67 | }; 68 | -------------------------------------------------------------------------------- /embUnit/TestCaller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestCaller.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTCALLER_H__ 36 | #define __TESTCALLER_H__ 37 | 38 | typedef struct __TestFixture TestFixture; 39 | typedef struct __TestFixture* TestFixtureRef;/*downward compatible*/ 40 | 41 | struct __TestFixture { 42 | char *name; 43 | void(*test)(void); 44 | }; 45 | 46 | #define new_TestFixture(name,test)\ 47 | {\ 48 | name,\ 49 | test,\ 50 | } 51 | 52 | typedef struct __TestCaller TestCaller; 53 | typedef struct __TestCaller* TestCallerRef;/*downward compatible*/ 54 | 55 | struct __TestCaller { 56 | TestImplement* isa; 57 | char *name; 58 | void(*setUp)(void); 59 | void(*tearDown)(void); 60 | int numberOfFixtuers; 61 | TestFixture *fixtuers; 62 | }; 63 | 64 | extern const TestImplement TestCallerImplement; 65 | 66 | #define new_TestCaller(name,sup,tdw,numberOfFixtuers,fixtuers)\ 67 | {\ 68 | (TestImplement*)&TestCallerImplement,\ 69 | name,\ 70 | sup,\ 71 | tdw,\ 72 | numberOfFixtuers,\ 73 | fixtuers,\ 74 | } 75 | 76 | #endif/*__TESTCALLER_H__*/ 77 | -------------------------------------------------------------------------------- /embUnit/TestCase.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestCase.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "Test.h" 36 | #include "TestCase.h" 37 | #include "TestResult.h" 38 | 39 | static TestResult* result_; 40 | static TestCase* self_; 41 | 42 | char* TestCase_name(TestCase* self) 43 | { 44 | return self->name; 45 | } 46 | 47 | void TestCase_run(TestCase* self,TestResult* result) 48 | { 49 | TestResult_startTest(result, (Test*)self); 50 | if (self->setUp) { 51 | self->setUp(); 52 | } 53 | if (self->runTest) { 54 | TestResult* wr =result_; /*push*/ 55 | TestCase* ws = self_; /*push*/ 56 | result_ = result; 57 | self_ = self; 58 | self->runTest(); 59 | result_ = wr; /*pop*/ 60 | self_ = ws; /*pop*/ 61 | } 62 | if (self->tearDown) { 63 | self->tearDown(); 64 | } 65 | TestResult_endTest(result, (Test*)self); 66 | } 67 | 68 | int TestCase_countTestCases(TestCase* self) 69 | { 70 | return 1; 71 | } 72 | 73 | const TestImplement TestCaseImplement = { 74 | (TestNameFunction) TestCase_name, 75 | (TestRunFunction) TestCase_run, 76 | (TestCountTestCasesFunction)TestCase_countTestCases, 77 | }; 78 | 79 | void addFailure(const char *msg, long line, const char *file) 80 | { 81 | TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file); 82 | } 83 | -------------------------------------------------------------------------------- /embUnit/TestCase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestCase.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTCASE_H__ 36 | #define __TESTCASE_H__ 37 | 38 | typedef struct __TestCase TestCase; 39 | typedef struct __TestCase* TestCaseRef;/*compatible embUnit1.0*/ 40 | 41 | struct __TestCase { 42 | TestImplement* isa; 43 | char *name; 44 | void(*setUp)(void); 45 | void(*tearDown)(void); 46 | void(*runTest)(void); 47 | }; 48 | 49 | extern const TestImplement TestCaseImplement; 50 | 51 | #define new_TestCase(name,setUp,tearDown,runTest)\ 52 | {\ 53 | (TestImplement*)&TestCaseImplement,\ 54 | name,\ 55 | setUp,\ 56 | tearDown,\ 57 | runTest,\ 58 | } 59 | 60 | #endif/*__TESTCASE_H__*/ 61 | -------------------------------------------------------------------------------- /embUnit/TestListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestListener.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTLISTENER_H__ 36 | #define __TESTLISTENER_H__ 37 | 38 | typedef struct __TestListnerImplement TestListnerImplement; 39 | typedef struct __TestListnerImplement* TestListnerImplementRef;/*downward compatible*/ 40 | 41 | typedef void(*TestListnerStartTestCallBack)(void*,void*); 42 | typedef void(*TestListnerEndTestCallBack)(void*,void*); 43 | typedef void(*TestListnerAddFailureCallBack)(void*,void*,const char*,int,const char*); 44 | 45 | struct __TestListnerImplement { 46 | TestListnerStartTestCallBack startTest; 47 | TestListnerEndTestCallBack endTest; 48 | TestListnerAddFailureCallBack addFailure; 49 | }; 50 | 51 | /*typedef struct __TestListner TestListner;*/ /*->TestResult.h*/ 52 | /*typedef struct __TestListner* TestListnerRef;*/ /*->TestResult.h*/ 53 | 54 | struct __TestListner { 55 | TestListnerImplement* isa; 56 | }; 57 | 58 | #define TestListner_startTest(s,t) ((TestListner*)s)->isa->startTest(s,t) 59 | #define TestListner_endTest(s,t) ((TestListner*)s)->isa->endTest(s,t) 60 | #define TestListner_addFailure(s,t,m,l,f) ((TestListner*)s)->isa->addFailure(s,t,m,l,f) 61 | 62 | #endif/*__TESTLISTENER_H__*/ 63 | -------------------------------------------------------------------------------- /embUnit/TestResult.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestResult.c,v 1.4 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "Test.h" 36 | #include "TestListener.h" 37 | #include "TestResult.h" 38 | 39 | void TestResult_init(TestResult* self,TestListner* listner) 40 | { 41 | self->runCount = 0; 42 | self->failureCount = 0; 43 | self->listener = listner; 44 | } 45 | 46 | void TestResult_startTest(TestResult* self,Test* test) 47 | { 48 | self->runCount++; 49 | if (self->listener) { 50 | TestListner_startTest(self->listener, test); 51 | } 52 | } 53 | 54 | void TestResult_endTest(TestResult* self,Test* test) 55 | { 56 | if (self->listener) { 57 | TestListner_endTest(self->listener, test); 58 | } 59 | } 60 | 61 | void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file) 62 | { 63 | self->failureCount++; 64 | if (self->listener) { 65 | TestListner_addFailure(self->listener, test, msg, line, file); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /embUnit/TestResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestResult.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTRESULT_H__ 36 | #define __TESTRESULT_H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /*typedef struct __TestResult TestResult;*//* -> Test.h*/ 43 | /*typedef struct __TestResult* TestResultRef;*//* -> Test.h*/ 44 | 45 | typedef struct __TestListner TestListner; 46 | typedef struct __TestListner* TestListnerRef;/*downward compatible*/ 47 | 48 | struct __TestResult { 49 | unsigned short runCount; 50 | unsigned short failureCount; 51 | TestListner* listener; 52 | }; 53 | 54 | #define new_TestResult(listener)\ 55 | {\ 56 | 0,\ 57 | 0,\ 58 | (TestListner*)listener,\ 59 | } 60 | 61 | void TestResult_init(TestResult* self,TestListner* listner); 62 | void TestResult_startTest(TestResult* self,Test* test); 63 | void TestResult_endTest(TestResult* self,Test* test); 64 | void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif/*__TESTRESULT_H__*/ 71 | -------------------------------------------------------------------------------- /embUnit/TestRunner.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestRunner.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "config.h" 36 | #include "stdImpl.h" 37 | #include "Test.h" 38 | #include "TestListener.h" 39 | #include "TestResult.h" 40 | #include "TestRunner.h" 41 | 42 | static TestResult result_; 43 | static Test* root_; 44 | 45 | static void TestRunner_startTest(TestListner* self,Test* test) 46 | { 47 | stdimpl_print("."); 48 | } 49 | 50 | static void TestRunner_endTest(TestListner* self,Test* test) 51 | { 52 | } 53 | 54 | static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file) 55 | { 56 | stdimpl_print("\n"); 57 | stdimpl_print(Test_name(root_)); 58 | stdimpl_print("."); 59 | stdimpl_print(Test_name(test)); 60 | { 61 | char buf[16]; 62 | stdimpl_print(" ("); 63 | stdimpl_print(file); 64 | stdimpl_print(" "); 65 | stdimpl_itoa(line, buf, 10); 66 | stdimpl_print(buf); 67 | stdimpl_print(") "); 68 | } 69 | stdimpl_print(msg); 70 | stdimpl_print("\n"); 71 | } 72 | 73 | static const TestListnerImplement TestRunnerImplement = { 74 | (TestListnerStartTestCallBack) TestRunner_startTest, 75 | (TestListnerEndTestCallBack) TestRunner_endTest, 76 | (TestListnerAddFailureCallBack) TestRunner_addFailure, 77 | }; 78 | 79 | static const TestListner testrunner_ = { 80 | (TestListnerImplement*)&TestRunnerImplement, 81 | }; 82 | 83 | void TestRunner_start(void) 84 | { 85 | TestResult_init(&result_, (TestListner*)&testrunner_); 86 | } 87 | 88 | void TestRunner_runTest(Test* test) 89 | { 90 | root_ = test; 91 | Test_run(test, &result_); 92 | } 93 | 94 | void TestRunner_end(void) 95 | { 96 | char buf[16]; 97 | if (result_.failureCount) { 98 | stdimpl_print("\nrun "); 99 | stdimpl_itoa(result_.runCount, buf, 10); 100 | stdimpl_print(buf); 101 | stdimpl_print(" failures "); 102 | stdimpl_itoa(result_.failureCount, buf, 10); 103 | stdimpl_print(buf); 104 | stdimpl_print("\n"); 105 | } else { 106 | stdimpl_print("\nOK ("); 107 | stdimpl_itoa(result_.runCount, buf, 10); 108 | stdimpl_print(buf); 109 | stdimpl_print(" tests)\n"); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /embUnit/TestRunner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestRunner.h,v 1.6 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTRUNNER_H__ 36 | #define __TESTRUNNER_H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | void TestRunner_start(void); 43 | void TestRunner_runTest(Test* test); 44 | void TestRunner_end(void); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif/*__TESTRUNNER_H__*/ 51 | -------------------------------------------------------------------------------- /embUnit/TestSuite.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestSuite.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #include "Test.h" 36 | #include "TestSuite.h" 37 | 38 | char* TestSuite_name(TestSuite* self) 39 | { 40 | return self->name; 41 | } 42 | 43 | void TestSuite_run(TestSuite* self,TestResult* result) 44 | { 45 | int i; 46 | Test* test; 47 | if (self->tests) { 48 | for (i=0; inumberOfTests; i++) { 49 | test = self->tests[i]; 50 | Test_run(test, result); 51 | } 52 | } 53 | } 54 | 55 | int TestSuite_countTestCases(TestSuite* self) 56 | { 57 | int count = 0; 58 | int i; 59 | Test* test; 60 | if (self->tests) { 61 | for (i=0; inumberOfTests; i++) { 62 | test = self->tests[i]; 63 | count += Test_countTestCases(test); 64 | } 65 | } 66 | return count; 67 | } 68 | 69 | const TestImplement TestSuiteImplement = { 70 | (TestNameFunction) TestSuite_name, 71 | (TestRunFunction) TestSuite_run, 72 | (TestCountTestCasesFunction)TestSuite_countTestCases, 73 | }; 74 | -------------------------------------------------------------------------------- /embUnit/TestSuite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: TestSuite.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $ 34 | */ 35 | #ifndef __TESTSUITE_H__ 36 | #define __TESTSUITE_H__ 37 | 38 | typedef struct __TestSuite TestSuite; 39 | typedef struct __TestSuite* TestSuiteRef;/*downward compatible*/ 40 | 41 | struct __TestSuite { 42 | TestImplement* isa; 43 | char *name; 44 | int numberOfTests; 45 | Test** tests; 46 | }; 47 | 48 | extern const TestImplement TestSuiteImplement; 49 | 50 | #define new_TestSuite(name,tests,numberOfTests)\ 51 | {\ 52 | (TestImplement*)&TestSuiteImplement,\ 53 | name,\ 54 | numberOfTests,\ 55 | tests,\ 56 | } 57 | 58 | #endif/*__TESTSUITE_H__*/ 59 | -------------------------------------------------------------------------------- /embUnit/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: config.h,v 1.7 2004/02/10 16:17:07 arms22 Exp $ 34 | */ 35 | #ifndef __CONFIG_H__ 36 | #define __CONFIG_H__ 37 | 38 | /* #define NO_STDIO_PRINTF*/ 39 | #ifdef NO_STDIO_PRINTF 40 | extern void stdimpl_print(const char *string); 41 | #else 42 | #include 43 | #define stdimpl_print printf 44 | #endif 45 | 46 | #define ASSERT_STRING_BUFFER_MAX 64 47 | 48 | #endif/*__CONFIG_H__*/ 49 | -------------------------------------------------------------------------------- /embUnit/embUnit.cproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 6.0 6 | com.Atmel.AVRGCC8 7 | {a3360898-4569-4689-ac93-9eb6a3534ff0} 8 | ATmega328P 9 | none 10 | StaticLibrary 11 | C 12 | lib$(MSBuildProjectName) 13 | .a 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | 16 | 17 | embUnit 18 | embUnit 19 | embUnit 20 | Native 21 | true 22 | false 23 | 24 | 0 25 | 3.1.3 26 | 27 | com.atmel.avrdbg.tool.simulator 28 | 29 | com.atmel.avrdbg.tool.simulator 30 | AVR Simulator 31 | 32 | 33 | true 34 | false 35 | 36 | 37 | 38 | 127.0.0.1 39 | 49544 40 | False 41 | 42 | 43 | 44 | 45 | 46 | 47 | True 48 | True 49 | True 50 | True 51 | True 52 | Optimize for size (-Os) 53 | True 54 | True 55 | True 56 | 57 | 58 | m 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | True 68 | True 69 | True 70 | True 71 | True 72 | True 73 | True 74 | True 75 | Default (-g2) 76 | True 77 | 78 | 79 | m 80 | 81 | 82 | True 83 | Default (-Wa,-g) 84 | 85 | 86 | 87 | 88 | 89 | compile 90 | 91 | 92 | compile 93 | 94 | 95 | compile 96 | 97 | 98 | compile 99 | 100 | 101 | compile 102 | 103 | 104 | compile 105 | 106 | 107 | compile 108 | 109 | 110 | compile 111 | 112 | 113 | compile 114 | 115 | 116 | compile 117 | 118 | 119 | compile 120 | 121 | 122 | compile 123 | 124 | 125 | compile 126 | 127 | 128 | compile 129 | 130 | 131 | compile 132 | 133 | 134 | compile 135 | 136 | 137 | compile 138 | 139 | 140 | compile 141 | 142 | 143 | compile 144 | 145 | 146 | compile 147 | 148 | 149 | compile 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /embUnit/embUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: embUnit.h,v 1.4 2004/02/10 16:16:19 arms22 Exp $ 34 | */ 35 | #ifndef __EMBUNIT_H__ 36 | #define __EMBUNIT_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #endif/*__EMBUNIT_H__*/ 51 | -------------------------------------------------------------------------------- /embUnit/stdImpl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: stdImpl.c,v 1.3 2004/02/10 16:15:25 arms22 Exp $ 34 | */ 35 | #include "stdImpl.h" 36 | 37 | char* stdimpl_strcpy(char *dst, const char *src) 38 | { 39 | char *start = dst; 40 | char c; 41 | do { 42 | c = *src; 43 | *dst = c; 44 | src++; 45 | dst++; 46 | } while (c); 47 | return start; 48 | } 49 | 50 | char* stdimpl_strcat(char *dst, const char *src) 51 | { 52 | char *start = dst; 53 | char c; 54 | do { 55 | c = *dst; 56 | dst++; 57 | } while (c); 58 | dst--; 59 | do { 60 | c = *src; 61 | *dst = c; 62 | src++; 63 | dst++; 64 | } while (c); 65 | return start; 66 | } 67 | 68 | char* stdimpl_strncat(char *dst, const char *src,unsigned int count) 69 | { 70 | char *start = dst; 71 | char c; 72 | do { 73 | c = *dst; 74 | dst++; 75 | } while (c); 76 | dst--; 77 | if (count) { 78 | do { 79 | c = *src; 80 | *dst = c; 81 | src++; 82 | dst++; 83 | count--; 84 | } while (c && count); 85 | *dst = '\0'; 86 | } 87 | return start; 88 | } 89 | 90 | int stdimpl_strlen(const char *str) 91 | { 92 | const char *estr = str; 93 | char c; 94 | do { 95 | c = *estr; 96 | estr++; 97 | } while (c); 98 | return ((int)(estr - str - 1)); 99 | } 100 | 101 | int stdimpl_strcmp(const char *s1, const char *s2) 102 | { 103 | char c1,c2; 104 | do { 105 | c1 = *s1++; 106 | c2 = *s2++; 107 | } while ((c1) && (c2) && (c1==c2)); 108 | return c1 - c2; 109 | } 110 | 111 | static char* _xtoa(unsigned long v,char *string, int r, int is_neg) 112 | { 113 | char *start = string; 114 | char buf[33],*p; 115 | 116 | p = buf; 117 | 118 | do { 119 | *p++ = "0123456789abcdef"[(v % r) & 0xf]; 120 | } while (v /= r); 121 | 122 | if (is_neg) { 123 | *p++ = '-'; 124 | } 125 | 126 | do { 127 | *string++ = *--p; 128 | } while (buf != p); 129 | 130 | *string = '\0'; 131 | 132 | return start; 133 | } 134 | 135 | char* stdimpl_itoa(int v,char *string,int r) 136 | { 137 | if ((r == 10) && (v < 0)) { 138 | return _xtoa((unsigned long)(-v), string, r, 1); 139 | } 140 | return _xtoa((unsigned long)(v), string, r, 0); 141 | } 142 | -------------------------------------------------------------------------------- /embUnit/stdImpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * COPYRIGHT AND PERMISSION NOTICE 3 | * 4 | * Copyright (c) 2003 Embedded Unit Project 5 | * 6 | * All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, provided that the above 14 | * copyright notice(s) and this permission notice appear in all copies 15 | * of the Software and that both the above copyright notice(s) and this 16 | * permission notice appear in supporting documentation. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 21 | * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 | * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 23 | * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 24 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 25 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 26 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | * 28 | * Except as contained in this notice, the name of a copyright holder 29 | * shall not be used in advertising or otherwise to promote the sale, 30 | * use or other dealings in this Software without prior written 31 | * authorization of the copyright holder. 32 | * 33 | * $Id: stdImpl.h,v 1.4 2004/02/10 16:15:25 arms22 Exp $ 34 | */ 35 | #ifndef __STDIMPL_H__ 36 | #define __STDIMPL_H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #ifndef NULL 43 | #define NULL 0 44 | #endif 45 | 46 | char* stdimpl_strcpy(char *s1, const char *s2); 47 | char* stdimpl_strcat(char *dst, const char *src); 48 | char* stdimpl_strncat(char *dst, const char *src,unsigned int count); 49 | int stdimpl_strlen(const char *str); 50 | int stdimpl_strcmp(const char *s1, const char *s2); 51 | char* stdimpl_itoa(int v,char *string,int r); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif/*__STDIMPL_H__*/ 58 | --------------------------------------------------------------------------------