diff --git a/Makefile b/Makefile index 7ec5bdbc8ce9d9617017b61b955f9e9655f89ac6..86925f534eea04134fd99293b23859d63fe116cf 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,14 @@ DIRS = $(RIOTCPU)/$(CPU) core drivers sys +ifneq (,$(filter embunit,$(USEMODULE))) + DIRS += tests/unittests/embunit/embUnit +endif + +ifneq (,$(filter embunit_textui,$(USEMODULE))) + DIRS += tests/unittests/embunit/textui +endif + + .PHONY: all clean doc all: diff --git a/tests/unittests/embunit/embUnit/HelperMacro.h b/tests/unittests/embunit/embUnit/HelperMacro.h index 533e1be2a16672e105fa6e2d85f54618ab21f575..a6e28fadd2a8655dd9958197ea6ea87b5b7134b0 100644 --- a/tests/unittests/embunit/embUnit/HelperMacro.h +++ b/tests/unittests/embunit/embUnit/HelperMacro.h @@ -35,11 +35,11 @@ #ifndef __HELPERMACRO_H__ #define __HELPERMACRO_H__ -#define EMB_UNIT_TESTCASE(ca,name,sup,tdw,run) \ - static const TestCase ca = new_TestCase(name,sup,tdw,run) +#define EMB_UNIT_TESTCASE(ca,sup,tdw,run) \ + static const TestCase ca = new_TestCase(#ca,sup,tdw,run) -#define EMB_UNIT_TESTSUITE(su,name,array) \ - static const TestSuite su = new_TestSuite(name,(Test**)array,sizeof(array)/sizeof(array[0])) +#define EMB_UNIT_TESTSUITE(su,array) \ + static const TestSuite su = new_TestSuite(#su,(Test**)array,sizeof(array)/sizeof(array[0])) #define EMB_UNIT_TESTREFS(tests) \ static Test* const tests[] = @@ -47,8 +47,8 @@ #define EMB_UNIT_ADD_TESTREF(testref) \ (Test*) testref -#define EMB_UNIT_TESTCALLER(caller,name,sup,tdw,fixtures) \ - static const TestCaller caller = new_TestCaller(name,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures) +#define EMB_UNIT_TESTCALLER(caller,sup,tdw,fixtures) \ + static const TestCaller caller = new_TestCaller(#caller,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures) #define EMB_UNIT_TESTFIXTURES(fixtures) \ static const TestFixture fixtures[] = diff --git a/tests/unittests/embunit/embUnit/Makefile b/tests/unittests/embunit/embUnit/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..981297ba89a421b6cd3b9241fb02c84ce90e9a6d --- /dev/null +++ b/tests/unittests/embunit/embUnit/Makefile @@ -0,0 +1,5 @@ +MODULE = embunit + +INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit + +include $(RIOTBASE)/Makefile.base diff --git a/tests/unittests/embunit/embUnit/TestCaller.h b/tests/unittests/embunit/embUnit/TestCaller.h index 22166b8387958c661e2788a8ba27c6cf4cbf2b4c..1bb5bc4b88ea38911cd4637ba6d000ae2e42fa33 100644 --- a/tests/unittests/embunit/embUnit/TestCaller.h +++ b/tests/unittests/embunit/embUnit/TestCaller.h @@ -43,11 +43,7 @@ struct __TestFixture { void(*test)(void); }; -#define new_TestFixture(name,test)\ - {\ - name,\ - test,\ - } +#define new_TestFixture(test) { #test, test } typedef struct __TestCaller TestCaller; typedef struct __TestCaller* TestCallerRef;/*downward compatible*/ diff --git a/tests/unittests/embunit/embUnit/TestCase.c b/tests/unittests/embunit/embUnit/TestCase.c index 6688ca66be590cf4fbf8eb0f318d27bbedcc7af7..b710e7475337059c25b8c7df5fb64c14938c3143 100644 --- a/tests/unittests/embunit/embUnit/TestCase.c +++ b/tests/unittests/embunit/embUnit/TestCase.c @@ -67,6 +67,7 @@ void TestCase_run(TestCase* self,TestResult* result) int TestCase_countTestCases(TestCase* self) { + (void)self; return 1; } diff --git a/tests/unittests/embunit/embUnit/TestRunner.c b/tests/unittests/embunit/embUnit/TestRunner.c index a6388d0e300c99873467e2beb8697358f435120d..0698185e30af695ee4faac32775c8cd517916bed 100644 --- a/tests/unittests/embunit/embUnit/TestRunner.c +++ b/tests/unittests/embunit/embUnit/TestRunner.c @@ -44,15 +44,20 @@ static Test* root_; static void TestRunner_startTest(TestListner* self,Test* test) { + (void)self; + (void)test; stdimpl_print("."); } static void TestRunner_endTest(TestListner* self,Test* test) { + (void)self; + (void)test; } static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int line,char* file) { + (void)self; stdimpl_print("\n"); stdimpl_print(Test_name(root_)); stdimpl_print("."); diff --git a/tests/unittests/embunit/embUnit/config.h b/tests/unittests/embunit/embUnit/config.h index 2328d3a14bd3cbff0617b0f93c9149fe9d1a7b65..4851b043ea07f1dacc1ab87bd656536010e15685 100644 --- a/tests/unittests/embunit/embUnit/config.h +++ b/tests/unittests/embunit/embUnit/config.h @@ -40,7 +40,7 @@ extern void stdimpl_print(const char *string); #else #include<stdio.h> - #define stdimpl_print printf + #define stdimpl_print(s) printf("%s", s); #endif #define ASSERT_STRING_BUFFER_MAX 64 diff --git a/tests/unittests/embunit/embUnit/makefile b/tests/unittests/embunit/embUnit/makefile deleted file mode 100644 index 6ed48380ed90b38512f936fbbee35b62b9916a83..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/embUnit/makefile +++ /dev/null @@ -1,32 +0,0 @@ -CC = gcc -CFLAGS = -O -AR = ar -ARFLAGS = ru -RANLIB = ranlib -RM = rm -OUTPUT = ../lib/ -TARGET = libembUnit.a -OBJS = AssertImpl.o RepeatedTest.o stdImpl.o TestCaller.o TestCase.o TestResult.o TestRunner.o TestSuite.o - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(AR) $(ARFLAGS) $(OUTPUT)$@ $(OBJS) - $(RANLIB) $(OUTPUT)$@ - -.c.o: - $(CC) $(CFLAGS) $(INCLUDES) -c $< - -AssertImpl.o: AssertImpl.h stdImpl.h -RepeatedTest.o: RepeatedTest.h Test.h -stdImpl.o: stdImpl.h -TestCaller.o: TestCaller.h TestResult.h TestListener.h TestCase.h Test.h -TestCase.o: TestCase.h TestResult.h TestListener.h Test.h -TestResult.o: TestResult.h TestListener.h Test.h -TestRunner.o: TestRunner.h TestResult.h TestListener.h Test.h stdImpl.h config.h -TestSuite.o: TestSuite.h TestResult.h TestListener.h Test.h - -clean: - -$(RM) $(OBJS) $(TARGET) - -.PHONY: clean all diff --git a/tests/unittests/embunit/makefile b/tests/unittests/embunit/makefile deleted file mode 100644 index c2a174fcfdf24506fe56324b279dcf5b0c6bf79d..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/makefile +++ /dev/null @@ -1,20 +0,0 @@ -all: - -@mkdir lib - -@cd ./embUnit ;$(MAKE) - -@cd ./tests ;$(MAKE) - -@cd ./samples ;$(MAKE) - -@cd ./tools ;$(MAKE) - -test: - -@./tests/embUnitTest - -samples: - -@./samples/samples - -clean: - -@cd ./embUnit ;$(MAKE) clean - -@cd ./tests ;$(MAKE) clean - -@cd ./samples ;$(MAKE) clean - -@cd ./tools ;$(MAKE) clean - -.PHONY: clean samples test all diff --git a/tests/unittests/embunit/readme.txt b/tests/unittests/embunit/readme.txt deleted file mode 100644 index b24259e77f50e78dd51f0f796ff228c0227bbe21..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/readme.txt +++ /dev/null @@ -1,132 +0,0 @@ - - - == Embedded Unit == - https://sourceforge.jp/projects/embunit/ - ------------------------------------------------------------------------------- - -Embedded UnitはC言語を使った組み込み系開発向けのテストユニットフレームワークで -す。C標準ライブラリを使わないので実行資源の少ないターゲット環境で動作可能です。 -また、malloc関数も使用していません。すべてのオブジェクトはROM領域に確保されま -す。 - ------------------------------------------------------------------------------- - -1.ディレクトリ・ファイル構成 - [embUnit] - +- COPYING : ライセンス - +- makefile : メイクファイル - +- readme.txt : このファイル - +- [embUnit] : Embedded Unit ライブラリソース - +- [msvc] : MSVC++6.0 Project - +- [samples] : Embedded Unit サンプルソース - +- [tests] : Embedded Unit テストソース - +- [tools] : テストコードの雛形生成ツール - - -2.ターゲットシステムと開発環境 - - Embedded Unitの実行環境として次のものを想定している - - ・2KB以上のROM領域、128b以上のスタック領域を使用可能な環境 - ・標準Cライブラリが使用できない、したくない環境 - - また、開発環境として次のものを想定している - - ・Cコンパイラが使える環境 - - 補足 - - Embedded Unitの開発は次の環境で行われている - - ・Microsoft Windows XP Professional - ・VC++.NET or cygwin 1.3.22 + gcc 3.2 - ・Microsoft Windows 98 - ・VC++6.0 - ・Apple Computer MacOS X 10.1.5 - ・Project Builder 1.1.1 (gcc 2.95.2) - - -3.コンパイル - 3.1.UNIX系(cygwin) - - 必要に応じてembUnit/config.hを編集,以下のコマンドを実行. - - $ make - - - テストフレーム自身のテストを実行. - - $ make test - - - サンプルを実行. - - $ make samples - - 3.2.MSVC++6.0 - - msvc/embUnit.dsw を開いて各プロジェクトをビルドしてください. - - 3.3.MacOSX - - 必要に応じてembUnit/config.hを編集,CC変数をccに置き換えコマンド実行. - - $ make CC=cc - - -4.サポートする機能の概要 - - ・検証マクロ - TEST_ASSERT_EQUAL_STRING・・・文字列の検証 - TEST_ASSERT_EQUAL_INT・・・int型変数の検証 - TEST_ASSERT_NULL・・・NULLポインタの検証 - TEST_ASSERT_NOT_NULL・・・非NULLポインタの検証 - TEST_ASSERT_MESSAGE・・・検証とメッセージ - TEST_ASSERT・・・検証 - TEST_FAIL・・・失敗 - - ・ヘルパーマクロ - テストを記述するのに必要な作業をヘルパーマクロで簡略化します. - - -5.将来サポートする機能の概要 - - ・CUITestRunner - 対話型のTestRunnerの開発を予定しています. - ※標準Cライブラリが使える環境を想定して開発を行います. - 可能なら標準Cライブラリを使わないバージョンも開発します. - - ・GUITestRunner - GUIを利用したTestRunnerです. - - ・textui - Text形式、XML形式、Compiler形式のテスト結果を出力するTestRunnerを開発し - ます. - - -6.制限事項 - - Embedded Unitはテスト結果の出力に標準ライブラリのprintf関数を使用していま - す.もし標準ライブラリのprintf関数を使用したくない場合は、 - - void stdimpl_print(const char* string) - ※stdimpl_print関数は文字列の終わりに改行を出力しない関数 - - という関数を実装し、コンパイルオプションに"-DNO_STDIO_PRINTF"を追加してく - ださい.もしくはconfigヘッダの以下のコメントはずしてください. - - /*#define NO_STDIO_PRINTF*/ - - -7.ライセンス - - 7.1.ライセンス - Embedded Unitは - MIT/X Consortium License - に従うものとします. - - 7.2.日本語訳(参考) - http://xjman.dsl.gr.jp/xf86_3/CPYRIGHT-2.html - - 7.3.さまざまなライセンスとそれらについての解説 - http://www.gnu.org/licenses/license-list.ja.html - - ------------------------------------------------------------------------------- -$Id: readme.txt,v 1.10 2003/09/16 11:41:48 arms22 Exp $ diff --git a/tests/unittests/embunit/samples/AllTests.c b/tests/unittests/embunit/samples/AllTests.c deleted file mode 100644 index 8665cc447cd29c54c1fad3138f70db9bd6852ed1..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/AllTests.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <embUnit/embUnit.h> - -TestRef CounterTest_tests(void); -TestRef PersonTest_tests(void); - -int main (int argc, const char* argv[]) -{ - TestRunner_start(); - TestRunner_runTest(CounterTest_tests()); - TestRunner_runTest(PersonTest_tests()); - TestRunner_end(); - return 0; -} diff --git a/tests/unittests/embunit/samples/counter.c b/tests/unittests/embunit/samples/counter.c deleted file mode 100644 index 36a5826e1cedcc11e51f9eb7566c414175a9638b..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/counter.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include "counter.h" - -CounterRef Counter_alloc(void) -{ - return (CounterRef)malloc(sizeof(Counter)); -} - -void Counter_dealloc(CounterRef self) -{ - free(self); -} - -CounterRef Counter_init(CounterRef self) -{ - self->value = 0; - return self; -} - -CounterRef Counter_counter(void) -{ - return Counter_init(Counter_alloc()); -} - -int Counter_value(CounterRef self) -{ - return self->value; -} - -void Counter_setValue(CounterRef self,int value) -{ - self->value = value; -} - -int Counter_inc(CounterRef self) -{ - self->value++; - return self->value; -} - -int Counter_dec(CounterRef self) -{ - self->value--; - return self->value; -} - -void Counter_clr(CounterRef self) -{ - self->value = 0; -} diff --git a/tests/unittests/embunit/samples/counter.h b/tests/unittests/embunit/samples/counter.h deleted file mode 100644 index d9eb99be13cd83772b576489aab29c907e15014d..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/counter.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __COUNTER_H__ -#define __COUNTER_H__ - -typedef struct __Counter Counter; -typedef struct __Counter* CounterRef; - -struct __Counter { - int value; -}; - -CounterRef Counter_alloc(void); -void Counter_dealloc(CounterRef); -CounterRef Counter_init(CounterRef); -CounterRef Counter_counter(void); -int Counter_value(CounterRef); -void Counter_setValue(CounterRef,int); -int Counter_inc(CounterRef); -int Counter_dec(CounterRef); -void Counter_clr(CounterRef); - -#endif/*__COUNTER_H__*/ diff --git a/tests/unittests/embunit/samples/counterTest.c b/tests/unittests/embunit/samples/counterTest.c deleted file mode 100644 index 5c59129fa429f0bd04e4851b46cccda77c56af58..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/counterTest.c +++ /dev/null @@ -1,69 +0,0 @@ -#include <embUnit/embUnit.h> -#include "counter.h" - -CounterRef counterRef; - -static void setUp(void) -{ - counterRef = Counter_counter(); -} - -static void tearDown(void) -{ - Counter_dealloc(counterRef); -} - -static void testInit(void) -{ - TEST_ASSERT_EQUAL_INT(0, Counter_value(counterRef)); -} - -static void testSetValue(void) -{ - Counter_setValue(counterRef,1); - TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); - - Counter_setValue(counterRef,-1); - TEST_ASSERT_EQUAL_INT(-1, Counter_value(counterRef)); -} - -static void testInc(void) -{ - Counter_inc(counterRef); - TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); - - Counter_inc(counterRef); - TEST_ASSERT_EQUAL_INT(2, Counter_value(counterRef)); -} - -static void testDec(void) -{ - Counter_dec(counterRef); - TEST_ASSERT_EQUAL_INT(-1, Counter_value(counterRef)); - - Counter_dec(counterRef); - TEST_ASSERT_EQUAL_INT(-2, Counter_value(counterRef)); -} - -static void testClr(void) -{ - Counter_inc(counterRef); - TEST_ASSERT_EQUAL_INT(1, Counter_value(counterRef)); - - Counter_clr(counterRef); - TEST_ASSERT_EQUAL_INT(0, Counter_value(counterRef)); -} - -TestRef CounterTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testInit",testInit), - new_TestFixture("testSetValue",testSetValue), - new_TestFixture("testInc",testInc), - new_TestFixture("testDec",testDec), - new_TestFixture("testClr",testClr), - }; - EMB_UNIT_TESTCALLER(CounterTest,"CounterTest",setUp,tearDown,fixtures); - - return (TestRef)&CounterTest; -} diff --git a/tests/unittests/embunit/samples/makefile b/tests/unittests/embunit/samples/makefile deleted file mode 100644 index 85bf7e962c984953df852fd36fb2c6af48a4c518..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/makefile +++ /dev/null @@ -1,20 +0,0 @@ -CC = gcc -CFLAGS = -O -INCLUDES = .. -LIBS = ../lib -RM = rm -TARGET = samples -OBJS = AllTests.o counter.o counterTest.o person.o personTest.o - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) -L$(LIBS) -lembUnit - -.c.o: - $(CC) $(CFLAGS) -I$(INCLUDES) -c $< - -clean: - -$(RM) $(TARGET) $(OBJS) - -.PHONY: clean all diff --git a/tests/unittests/embunit/samples/person.c b/tests/unittests/embunit/samples/person.c deleted file mode 100644 index ff1c83dac4c892c4b810cec6c88579f65aa12c30..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/person.c +++ /dev/null @@ -1,179 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "person.h" - -PersonRef Person_alloc(void) -{ - return (PersonRef)malloc(sizeof(Person)); -} - -PersonRef Person_init(PersonRef self) -{ - return Person_initWithName(self, NULL); -} - -PersonRef Person_initWithName(PersonRef self,char *fullname) -{ - self->fullname = NULL; - self->firstname = NULL; - self->lastname = NULL; - Person_setFullName(self,fullname); - return self; -} - -PersonRef Person_personWithName(char *fullname) -{ - return Person_initWithName(Person_alloc(),fullname); -} - -void Person_dealloc(PersonRef self) -{ - if (self) { - free(self->fullname); - free(self->firstname); - free(self->lastname); - free(self); - } -} - -static void setfullname(PersonRef self,char *fullname) -{ - free(self->fullname); - self->fullname = NULL; - if (fullname) { - self->fullname = (char*)malloc(strlen(fullname)+1); - strcpy(self->fullname,fullname); - } -} - -static void setfirstname(PersonRef self,char *firstname) -{ - free(self->firstname); - self->firstname = NULL; - if (firstname) { - self->firstname = (char*)malloc(strlen(firstname)+1); - strcpy(self->firstname,firstname); - } -} - -static void setlastname(PersonRef self,char *lastname) -{ - free(self->lastname); - self->lastname = NULL; - if (lastname) { - self->lastname = (char*)malloc(strlen(lastname)+1); - strcpy(self->lastname,lastname); - } -} - -static void makefullname(PersonRef self) -{ - size_t fl,ll,fulllen,pos; - fl = ll = fulllen = pos = 0; - if (self->firstname) { - fl = strlen(self->firstname); - } - if (self->lastname) { - ll = strlen(self->lastname); - } - if (fl) { - fulllen = fl + 1; /* + space */ - } - if (ll) { - fulllen = fulllen + ll + 1; /* + null */ - } - if (fulllen) { - self->fullname = (char*)malloc(fulllen); - if (fl && ll) { - sprintf(self->fullname,"%s %s",self->firstname,self->lastname); - } else { - if (fl) { - strcpy(self->fullname,self->firstname); - } - if (ll) { - strcpy(self->fullname,self->lastname); - } - } - } -} - -static void makefirstname(PersonRef self) -{ - if (self->fullname) { - char *p; - int len; - p = strchr(self->fullname, ' '); - if (p) { - len = (int)(p - self->fullname); - p = (char*)malloc(len + 1); - strncpy(p,self->fullname,len); - p[len] = '\0'; - setfirstname(self,p); - free(p); - } else { - setfirstname(self,self->fullname); - } - } -} - -static void makelastname(PersonRef self) -{ - if (self->fullname) { - char *p = strchr(self->fullname, ' '); - if (p) { - setlastname(self,p+1); - } else { - setlastname(self,""); - } - } -} - -char* Person_fullName(PersonRef self) -{ - if (self->fullname == NULL) { - makefullname(self); - } - return self->fullname; -} - -char* Person_firstName(PersonRef self) -{ - if (self->firstname == NULL) { - makefirstname(self); - } - return self->firstname; -} - -char* Person_lastName(PersonRef self) -{ - if (self->lastname == NULL) { - makelastname(self); - } - return self->lastname; -} - -void Person_setFullName(PersonRef self,char *fullname) -{ - setfullname(self,fullname); - setfirstname(self,NULL); - setlastname(self,NULL); -} - -void Person_setFirstName(PersonRef self,char *firstname) -{ - if (self->lastname == NULL) { - makelastname(self); - } - setfirstname(self,firstname); - setfullname(self,NULL); -} - -void Person_setLastName(PersonRef self,char *lastname) -{ - if (self->firstname == NULL) { - makefirstname(self); - } - setlastname(self,lastname); - setfullname(self,NULL); -} diff --git a/tests/unittests/embunit/samples/person.h b/tests/unittests/embunit/samples/person.h deleted file mode 100644 index 698e5e4a50cd253db40626de29a4f83ebbe5713d..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/person.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __PERSON_H__ -#define __PERSON_H__ - -typedef struct __Person Person; -typedef struct __Person* PersonRef; - -struct __Person { - char *fullname; - char *firstname; - char *lastname; -}; - -PersonRef Person_alloc(void); -PersonRef Person_init(PersonRef); -PersonRef Person_initWithName(PersonRef,char*); -PersonRef Person_personWithName(char*); -void Person_dealloc(PersonRef); -char* Person_fullName(PersonRef); -char* Person_firstName(PersonRef); -char* Person_lastName(PersonRef); -void Person_setFullName(PersonRef,char*); -void Person_setFirstName(PersonRef,char*); -void Person_setLastName(PersonRef,char*); - -#endif/*__PERSON_H__*/ diff --git a/tests/unittests/embunit/samples/personTest.c b/tests/unittests/embunit/samples/personTest.c deleted file mode 100644 index 862a385ef8a1d96842e38aedff7772a6ca6e914b..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/samples/personTest.c +++ /dev/null @@ -1,111 +0,0 @@ -#include <embUnit/embUnit.h> -#include "person.h" - -PersonRef personRef; - -static void setUp(void) -{ - personRef = Person_personWithName("test tarou"); -} - -static void tearDown(void) -{ - Person_dealloc(personRef); -} - -static void testfullname(void) -{ - TEST_ASSERT_EQUAL_STRING("test tarou", Person_fullName(personRef)); -} - -static void testfirstname(void) -{ - TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); -} - -static void testlastname(void) -{ - TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); -} - -static void testsetfullname(void) -{ - Person_setFullName(personRef, "sample hanako"); - - TEST_ASSERT_EQUAL_STRING("sample hanako", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("hanako", Person_lastName(personRef)); -} - -static void testsetfirstname(void) -{ - Person_setFirstName(personRef, "sample"); - - TEST_ASSERT_EQUAL_STRING("sample tarou", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); -} - -static void testsetlastname(void) -{ - Person_setLastName(personRef, "hanako"); - - TEST_ASSERT_EQUAL_STRING("test hanako", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("hanako", Person_lastName(personRef)); -} - -static void testnullcharfullname(void) -{ - Person_setFullName(personRef, ""); - - TEST_ASSERT_EQUAL_STRING("", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("", Person_lastName(personRef)); -} - -static void testnullpointerfullname(void) -{ - Person_setFullName(personRef, NULL); - - TEST_ASSERT_NULL(Person_fullName(personRef)); - TEST_ASSERT_NULL(Person_firstName(personRef)); - TEST_ASSERT_NULL(Person_lastName(personRef)); -} - -static void testnosepfullname(void) -{ - Person_setFullName(personRef, "sample"); - - TEST_ASSERT_EQUAL_STRING("sample", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("", Person_lastName(personRef)); - - Person_setLastName(personRef, "tarou"); - TEST_ASSERT_EQUAL_STRING("sample tarou", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("sample", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); - - Person_setFirstName(personRef, "test"); - TEST_ASSERT_EQUAL_STRING("test tarou", Person_fullName(personRef)); - TEST_ASSERT_EQUAL_STRING("test", Person_firstName(personRef)); - TEST_ASSERT_EQUAL_STRING("tarou", Person_lastName(personRef)); -} - -TestRef PersonTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testfullname",testfullname), - new_TestFixture("testfirstname",testfirstname), - new_TestFixture("testlastname",testlastname), - new_TestFixture("testsetfullname",testsetfullname), - new_TestFixture("testsetfirstname",testsetfirstname), - new_TestFixture("testsetlastname",testsetlastname), - new_TestFixture("testnullcharfullname",testnullcharfullname), - new_TestFixture("testnullpointerfullname",testnullpointerfullname), - new_TestFixture("testnosepfullname",testnosepfullname), - }; - EMB_UNIT_TESTCALLER(PersonTest,"PersonTest",setUp,tearDown,fixtures); - - return (TestRef)&PersonTest; -} diff --git a/tests/unittests/embunit/tests/AllTests.c b/tests/unittests/embunit/tests/AllTests.c deleted file mode 100644 index dba06e96224cce9e99f544a5e5dea9d515de3c57..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/AllTests.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <embUnit/embUnit.h> - -extern TestRef assertTest_tests(void); -extern TestRef stdImplTest_tests(void); -extern TestRef TestCaseTest_tests(void); -extern TestRef TestCallerTest_tests(void); -extern TestRef TestResultTest_tests(void); -extern TestRef RepeatedTestTest_tests(void); - -int main (int argc, const char* argv[]) -{ - TestRunner_start(); - TestRunner_runTest(assertTest_tests()); - TestRunner_runTest(stdImplTest_tests()); - TestRunner_runTest(TestCaseTest_tests()); - TestRunner_runTest(TestCallerTest_tests()); - TestRunner_runTest(TestResultTest_tests()); - TestRunner_runTest(RepeatedTestTest_tests()); - TestRunner_end(); - return 0; -} diff --git a/tests/unittests/embunit/tests/MockTestCase.c b/tests/unittests/embunit/tests/MockTestCase.c deleted file mode 100644 index 5d92fd2b6a534cc103571c101144d26e62ed9b3e..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/MockTestCase.c +++ /dev/null @@ -1,12 +0,0 @@ -#include <embUnit/embUnit.h> -#include "MockTestCase.h" - -static void runTest(void) -{ -} - -TestCaseRef MockTestCase_case(void) -{ - EMB_UNIT_TESTCASE(MockTestCase,"MockTestCase",NULL,NULL,runTest); - return (TestCaseRef)&MockTestCase; -} diff --git a/tests/unittests/embunit/tests/MockTestCase.h b/tests/unittests/embunit/tests/MockTestCase.h deleted file mode 100644 index 81de8e3b1c4b3b337982452b3b2e1ef44a7b5484..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/MockTestCase.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MOCKTESTCASE_H__ -#define __MOCKTESTCASE_H__ - -TestCaseRef MockTestCase_case(void); - -#endif/*__MOCKTESTCASE_H__*/ diff --git a/tests/unittests/embunit/tests/RepeatedTestTest.c b/tests/unittests/embunit/tests/RepeatedTestTest.c deleted file mode 100644 index a68e04ad19bd76f6b76599dee46b42c1f81a268f..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/RepeatedTestTest.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <embUnit/embUnit.h> -#include "MockTestCase.h" - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void testRepeatedOnce(void) -{ - RepeatedTest test = new_RepeatedTest(MockTestCase_case(),1); - TestResult result = new_TestResult(NULL); - - test.isa->run(&test,&result); - - TEST_ASSERT_EQUAL_INT(1, result.runCount); - TEST_ASSERT_EQUAL_INT(1, test.isa->countTestCases(&test)); -} - -static void testRepeatedMoreThanOnce(void) -{ - RepeatedTest test = new_RepeatedTest(MockTestCase_case(),100); - TestResult result = new_TestResult(NULL); - - test.isa->run(&test,&result); - - - TEST_ASSERT_EQUAL_INT(100, result.runCount); - TEST_ASSERT_EQUAL_INT(100, test.isa->countTestCases(&test)); -} - -static void testRepeatedZero(void) -{ - RepeatedTest test = new_RepeatedTest(MockTestCase_case(),0); - TestResult result = new_TestResult(NULL); - - test.isa->run(&test,&result); - - - TEST_ASSERT_EQUAL_INT(0, result.runCount); - TEST_ASSERT_EQUAL_INT(0, test.isa->countTestCases(&test)); -} - -TestRef RepeatedTestTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testRepeatedOnce",testRepeatedOnce), - new_TestFixture("testRepeatedMoreThanOnce",testRepeatedMoreThanOnce), - new_TestFixture("testRepeatedZero",testRepeatedZero), - }; - EMB_UNIT_TESTCALLER(RepeatedTestTest,"RepeatedTestTest",setUp,tearDown,fixtures); - - return (TestRef)&RepeatedTestTest; -} diff --git a/tests/unittests/embunit/tests/TestCallerTest.c b/tests/unittests/embunit/tests/TestCallerTest.c deleted file mode 100644 index b8b9d9e1a87743ff48f76eb1c0b2ac7c45663c75..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/TestCallerTest.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <embUnit/embUnit.h> - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void testOneFixture(void) -{ - TestFixture fixtures[] = { - new_TestFixture(NULL,NULL), - }; - TestCaller caller = new_TestCaller(NULL,NULL,NULL,1,fixtures); - TestResult result = new_TestResult(NULL); - - caller.isa->run(&caller,&result); - - TEST_ASSERT_EQUAL_INT(1, result.runCount); - TEST_ASSERT_EQUAL_INT(1, caller.isa->countTestCases(&caller)); -} - -static void testMoreThanOne(void) -{ - TestFixture fixtures[] = { - new_TestFixture(NULL,NULL), - new_TestFixture(NULL,NULL), - new_TestFixture(NULL,NULL), - new_TestFixture(NULL,NULL), - new_TestFixture(NULL,NULL), - }; - TestCaller caller = new_TestCaller(NULL,NULL,NULL,5,fixtures); - TestResult result = new_TestResult(NULL); - - caller.isa->run(&caller,&result); - - TEST_ASSERT_EQUAL_INT(5, result.runCount); - TEST_ASSERT_EQUAL_INT(5, caller.isa->countTestCases(&caller)); -} - -static void testZeroFixture(void) -{ - TestCaller caller = new_TestCaller(NULL,NULL,NULL,0,NULL); - TestResult result = new_TestResult(NULL); - - caller.isa->run(&caller,&result); - - TEST_ASSERT_EQUAL_INT(0, result.runCount); - TEST_ASSERT_EQUAL_INT(0, caller.isa->countTestCases(&caller)); -} - -TestRef TestCallerTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testOneFixture",testOneFixture), - new_TestFixture("testMoreThanOne",testMoreThanOne), - new_TestFixture("testZeroFixture",testZeroFixture), - }; - EMB_UNIT_TESTCALLER(TestCallerTest,"TestCallerTest",setUp,tearDown,fixtures); - - return (TestRef)&TestCallerTest; -} diff --git a/tests/unittests/embunit/tests/TestCaseTest.c b/tests/unittests/embunit/tests/TestCaseTest.c deleted file mode 100644 index f8a637f757d1f51fed6ae2f2c4a06b81805b50b2..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/TestCaseTest.c +++ /dev/null @@ -1,66 +0,0 @@ -#include <embUnit/embUnit.h> -#include "MockTestCase.h" - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void testName(void) -{ - TestCaseRef mock = MockTestCase_case(); - TEST_ASSERT_EQUAL_STRING("MockTestCase", mock->isa->name(mock)); -} - -static void testCountTestCases(void) -{ - TestCaseRef mock = MockTestCase_case(); - TEST_ASSERT_EQUAL_INT(1, mock->isa->countTestCases(mock)); -} - -static void success_runTest(void) -{ -} - -static void testSuccess(void) -{ - TestCase tcase = new_TestCase("success",NULL,NULL,success_runTest); - TestResult result = new_TestResult(NULL); - - tcase.isa->run(&tcase,&result); - - TEST_ASSERT_EQUAL_INT(1, result.runCount); - TEST_ASSERT_EQUAL_INT(0, result.failureCount); -} - -static void failure_runTest(void) -{ - TEST_FAIL(""); -} - -static void testFailure(void) -{ - TestCase tcase = new_TestCase("failure",NULL,NULL,failure_runTest); - TestResult result = new_TestResult(NULL); - - tcase.isa->run(&tcase,&result); - - TEST_ASSERT_EQUAL_INT(1, result.runCount); - TEST_ASSERT_EQUAL_INT(1, result.failureCount); -} - -TestRef TestCaseTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testName",testName), - new_TestFixture("testCountTestCases",testCountTestCases), - new_TestFixture("testSuccess",testSuccess), - new_TestFixture("testFailure",testFailure), - }; - EMB_UNIT_TESTCALLER(TestCaseTest,"TestCaseTest",setUp,tearDown,fixtures); - - return (TestRef)&TestCaseTest; -} diff --git a/tests/unittests/embunit/tests/TestResultTest.c b/tests/unittests/embunit/tests/TestResultTest.c deleted file mode 100644 index a475b0833b9dbf671509059b013754bc18a06002..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/TestResultTest.c +++ /dev/null @@ -1,60 +0,0 @@ -#include <embUnit/embUnit.h> - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void testTestResult_result(void) -{ - TestResult result = new_TestResult(NULL); - - TEST_ASSERT_EQUAL_INT(0, result.runCount); - TEST_ASSERT_EQUAL_INT(0, result.failureCount); -} - -static void testTestResult_startTest(void) -{ - TestResult result = new_TestResult(NULL); - - TestResult_startTest(&result,NULL); - - TEST_ASSERT_EQUAL_INT(1, result.runCount); - TEST_ASSERT_EQUAL_INT(0, result.failureCount); -} - -static void testTestResult_endTest(void) -{ - TestResult result = new_TestResult(NULL); - - TestResult_endTest(&result,NULL); - - TEST_ASSERT_EQUAL_INT(0, result.runCount); - TEST_ASSERT_EQUAL_INT(0, result.failureCount); -} - -static void testTestResult_addFailure(void) -{ - TestResult result = new_TestResult(NULL); - - TestResult_addFailure(&result,NULL,"",0,""); - - TEST_ASSERT_EQUAL_INT(0, result.runCount); - TEST_ASSERT_EQUAL_INT(1, result.failureCount); -} - -TestRef TestResultTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testTestResult_result",testTestResult_result), - new_TestFixture("testTestResult_startTest",testTestResult_startTest), - new_TestFixture("testTestResult_endTest",testTestResult_endTest), - new_TestFixture("testTestResult_addFailure",testTestResult_addFailure), - }; - EMB_UNIT_TESTCALLER(TestResultTest,"TestResultTest",setUp,tearDown,fixtures); - - return (TestRef)&TestResultTest; -} diff --git a/tests/unittests/embunit/tests/assertTest.c b/tests/unittests/embunit/tests/assertTest.c deleted file mode 100644 index fde85977aaae5c867e22330e4ff76a9905adf893..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/assertTest.c +++ /dev/null @@ -1,103 +0,0 @@ -#include <embUnit/embUnit.h> - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void verify(TestCaseRef test) -{ - TestResult result = new_TestResult(NULL); - - test->isa->run(test,&result); - - if (result.failureCount == 0) { - TEST_FAIL("fail"); - } -} - -static void assert_equal_string_runTest(void) -{ - TEST_ASSERT_EQUAL_STRING("123","456"); -} - -static void assert_equal_int_runTest(void) -{ - TEST_ASSERT_EQUAL_INT(123,456); -} - -static void assert_null_runTest(void) -{ - char *p=""; - TEST_ASSERT_NULL(p); -} - -static void assert_not_null_runTest(void) -{ - char *p=NULL; - TEST_ASSERT_NOT_NULL(p); -} - -static void assert_message_runTest(void) -{ - TEST_ASSERT_MESSAGE(0,"0"); -} - -static void assert_runTest(void) -{ - TEST_ASSERT(0); -} - -static void testASSERT_EQUAL_STRING(void) -{ - TestCase tcase = new_TestCase("assert_equal_string",NULL,NULL,assert_equal_string_runTest); - verify(&tcase); -} - -static void testASSERT_EQUAL_INT(void) -{ - TestCase tcase = new_TestCase("assert_equal_int",NULL,NULL,assert_equal_int_runTest); - verify(&tcase); -} - -static void testASSERT_NULL(void) -{ - TestCase tcase = new_TestCase("assert_null",NULL,NULL,assert_null_runTest); - verify(&tcase); -} - -static void testASSERT_NOT_NULL(void) -{ - TestCase tcase = new_TestCase("assert_not_null",NULL,NULL,assert_not_null_runTest); - verify(&tcase); -} - -static void testASSERT_MESSAGE(void) -{ - TestCase tcase = new_TestCase("assert_message",NULL,NULL,assert_message_runTest); - verify(&tcase); -} - -static void testASSERT(void) -{ - TestCase tcase = new_TestCase("assert",NULL,NULL,assert_runTest); - verify(&tcase); -} - -TestRef assertTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("testASSERT_EQUAL_STRING",testASSERT_EQUAL_STRING), - new_TestFixture("testASSERT_EQUAL_INT",testASSERT_EQUAL_INT), - new_TestFixture("testASSERT_NULL",testASSERT_NULL), - new_TestFixture("testASSERT_NOT_NULL",testASSERT_NOT_NULL), - new_TestFixture("testASSERT_MESSAGE",testASSERT_MESSAGE), - new_TestFixture("testASSERT",testASSERT), - }; - EMB_UNIT_TESTCALLER(AssertTest,"AssertTest",setUp,tearDown,fixtures); - - return (TestRef)&AssertTest; -} diff --git a/tests/unittests/embunit/tests/makefile b/tests/unittests/embunit/tests/makefile deleted file mode 100644 index 27c8ea2283328206f256f3744774e36b7a0bcf75..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/makefile +++ /dev/null @@ -1,21 +0,0 @@ -CC = gcc -CFLAGS = -O -LDFLAGS = -INCLUDES = .. -LIBS = ../lib -RM = rm -TARGET = embUnitTest -OBJS = AllTests.o RepeatedTestTest.o assertTest.o stdImplTest.o TestCallerTest.o TestCaseTest.o TestResultTest.o MockTestCase.o - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) -L$(LIBS) -lembUnit - -.c.o: - $(CC) $(CFLAGS) -I$(INCLUDES) -c $< - -clean: - -$(RM) $(TARGET) $(OBJS) - -.PHONY: clean all diff --git a/tests/unittests/embunit/tests/stdImplTest.c b/tests/unittests/embunit/tests/stdImplTest.c deleted file mode 100644 index 4dc73dadf23c1d88be7424c3e635db0edfe8ba37..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tests/stdImplTest.c +++ /dev/null @@ -1,114 +0,0 @@ -#include <embUnit/embUnit.h> - -static void setUp(void) -{ -} - -static void tearDown(void) -{ -} - -static void teststrcpy(void) -{ - char buf[32]; - char *p; - - p = stdimpl_strcpy(buf, "test"); - TEST_ASSERT_EQUAL_STRING("test", buf); - TEST_ASSERT( p == buf ); -} - -static void teststrcat(void) -{ - char buf[64]; - - stdimpl_strcpy(buf,"sample"); - stdimpl_strcat(buf," extra string"); - TEST_ASSERT_EQUAL_STRING("sample extra string", buf); - - stdimpl_strcpy(buf,""); - stdimpl_strcat(buf,"sample"); - TEST_ASSERT_EQUAL_STRING("sample", buf); -} - -static void teststrncat(void) -{ - char buf[64]; - - stdimpl_strcpy(buf,"sample"); - stdimpl_strncat(buf," extra string",13); - TEST_ASSERT_EQUAL_STRING("sample extra string", buf); - - stdimpl_strcpy(buf,"This is the initial string!"); - stdimpl_strncat(buf," extra text to add to the string", 19); - TEST_ASSERT_EQUAL_STRING("This is the initial string! extra text to add ", buf); -} - -static void teststrlen(void) -{ - TEST_ASSERT( stdimpl_strlen("test")==4 ); - TEST_ASSERT( stdimpl_strlen("")==0 ); -} - -static void teststrcmp(void) -{ - TEST_ASSERT( stdimpl_strcmp("aaa","aaa") == 0 ); - TEST_ASSERT( stdimpl_strcmp("aaa","bbb") != 0 ); - TEST_ASSERT( stdimpl_strcmp("aaa","AAA") != 0 ); - TEST_ASSERT( stdimpl_strcmp("Test","TestCase") != 0 ); - TEST_ASSERT( stdimpl_strcmp("TestCase","Test") != 0 ); - TEST_ASSERT( stdimpl_strcmp("","") == 0 ); -} - -static void testitoa(void) -{ - char buf[33]; - char *p; - - p = stdimpl_itoa(10, buf, 2); - TEST_ASSERT_EQUAL_STRING("1010", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(10, buf, 8); - TEST_ASSERT_EQUAL_STRING("12", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(10, buf, 10); - TEST_ASSERT_EQUAL_STRING("10", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(10, buf, 16); - TEST_ASSERT_EQUAL_STRING("a", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(-10, buf, 2); - TEST_ASSERT_EQUAL_STRING("11111111111111111111111111110110", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(-10, buf, 8); - TEST_ASSERT_EQUAL_STRING("37777777766", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(-10, buf, 10); - TEST_ASSERT_EQUAL_STRING("-10", buf); - TEST_ASSERT(p == buf); - - p = stdimpl_itoa(-10, buf, 16); - TEST_ASSERT_EQUAL_STRING("fffffff6", buf); - TEST_ASSERT(p == buf); -} - -TestRef stdImplTest_tests(void) -{ - EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture("teststrcpy",teststrcpy), - new_TestFixture("teststrcat",teststrcat), - new_TestFixture("teststrncat",teststrncat), - new_TestFixture("teststrlen",teststrlen), - new_TestFixture("teststrcmp",teststrcmp), - new_TestFixture("testitoa",testitoa), - }; - EMB_UNIT_TESTCALLER(StdImplTest,"stdImplTest",setUp,tearDown,fixtures); - - return (TestRef)&StdImplTest; -} diff --git a/tests/unittests/embunit/textui/CompilerOutputter.c b/tests/unittests/embunit/textui/CompilerOutputter.c index 1a380a7b73cd9743c7d98bbdc2474335caa7913f..2359d68a104f395cba631ba1bbdf1d3bc7a33080 100644 --- a/tests/unittests/embunit/textui/CompilerOutputter.c +++ b/tests/unittests/embunit/textui/CompilerOutputter.c @@ -1,79 +1,92 @@ -/* - * COPYRIGHT AND PERMISSION NOTICE - * - * Copyright (c) 2003 Embedded Unit Project - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies - * of the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - * - * $Id: CompilerOutputter.c,v 1.2 2003/09/06 13:28:27 arms22 Exp $ - */ -#include <stdio.h> -#include "CompilerOutputter.h" - -static void CompilerOutputter_printHeader(OutputterRef self,TestRef test) -{ -} - -static void CompilerOutputter_printStartTest(OutputterRef self,TestRef test) -{ -} - -static void CompilerOutputter_printEndTest(OutputterRef self,TestRef test) -{ -} - -static void CompilerOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) -{ -} - -static void CompilerOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) -{ - fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg); -} - -static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result) -{ -} - -static const OutputterImplement CompilerOutputterImplement = { - (OutputterPrintHeaderFunction) CompilerOutputter_printHeader, - (OutputterPrintStartTestFunction) CompilerOutputter_printStartTest, - (OutputterPrintEndTestFunction) CompilerOutputter_printEndTest, - (OutputterPrintSuccessfulFunction) CompilerOutputter_printSuccessful, - (OutputterPrintFailureFunction) CompilerOutputter_printFailure, - (OutputterPrintStatisticsFunction) CompilerOutputter_printStatistics, -}; - -static const Outputter CompilerOutputter = { - (OutputterImplementRef)&CompilerOutputterImplement, -}; - -OutputterRef CompilerOutputter_outputter(void) -{ - return (OutputterRef)&CompilerOutputter; -} +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: CompilerOutputter.c,v 1.2 2003/09/06 13:28:27 arms22 Exp $ + */ +#include <stdio.h> +#include "CompilerOutputter.h" + +static void CompilerOutputter_printHeader(OutputterRef self,TestRef test) +{ + (void)self; + (void)test; +} + +static void CompilerOutputter_printStartTest(OutputterRef self,TestRef test) +{ + (void)self; + (void)test; +} + +static void CompilerOutputter_printEndTest(OutputterRef self,TestRef test) +{ + (void)self; + (void)test; +} + +static void CompilerOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) +{ + (void)self; + (void)test; + (void)runCount; +} + +static void CompilerOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) +{ + (void)self; + (void)runCount; + fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg); +} + +static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result) +{ + (void)self; + (void)result; +} + +static const OutputterImplement CompilerOutputterImplement = { + (OutputterPrintHeaderFunction) CompilerOutputter_printHeader, + (OutputterPrintStartTestFunction) CompilerOutputter_printStartTest, + (OutputterPrintEndTestFunction) CompilerOutputter_printEndTest, + (OutputterPrintSuccessfulFunction) CompilerOutputter_printSuccessful, + (OutputterPrintFailureFunction) CompilerOutputter_printFailure, + (OutputterPrintStatisticsFunction) CompilerOutputter_printStatistics, +}; + +static const Outputter CompilerOutputter = { + (OutputterImplementRef)&CompilerOutputterImplement, +}; + +OutputterRef CompilerOutputter_outputter(void) +{ + return (OutputterRef)&CompilerOutputter; +} diff --git a/tests/unittests/embunit/textui/Makefile b/tests/unittests/embunit/textui/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5f5c5983eb114acf2185d5fb06db0fe9727106f7 --- /dev/null +++ b/tests/unittests/embunit/textui/Makefile @@ -0,0 +1,5 @@ +MODULE = embunit_textui + +INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit + +include $(RIOTBASE)/Makefile.base diff --git a/tests/unittests/embunit/textui/TextOutputter.c b/tests/unittests/embunit/textui/TextOutputter.c index de717f6f4df511e2815bcdb65a9d70f8ac6d6e9d..80fb485ab987118bbd0ba1051f30da116e236f02 100644 --- a/tests/unittests/embunit/textui/TextOutputter.c +++ b/tests/unittests/embunit/textui/TextOutputter.c @@ -1,86 +1,93 @@ -/* - * COPYRIGHT AND PERMISSION NOTICE - * - * Copyright (c) 2003 Embedded Unit Project - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies - * of the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - * - * $Id: TextOutputter.c,v 1.4 2003/09/06 13:28:27 arms22 Exp $ - */ -#include <stdio.h> -#include "TextOutputter.h" - -static void TextOutputter_printHeader(OutputterRef self) -{ -} - -static void TextOutputter_printStartTest(OutputterRef self,TestRef test) -{ - fprintf(stdout,"- %s\n",Test_name(test)); -} - -static void TextOutputter_printEndTest(OutputterRef self,TestRef test) -{ -} - -static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) -{ - fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test)); -} - -static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) -{ - fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg); -} - -static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result) -{ - if (result->failureCount) { - fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount); - } else { - fprintf(stdout,"\nOK (%d tests)\n",result->runCount); - } -} - -static const OutputterImplement TextOutputterImplement = { - (OutputterPrintHeaderFunction) TextOutputter_printHeader, - (OutputterPrintStartTestFunction) TextOutputter_printStartTest, - (OutputterPrintEndTestFunction) TextOutputter_printEndTest, - (OutputterPrintSuccessfulFunction) TextOutputter_printSuccessful, - (OutputterPrintFailureFunction) TextOutputter_printFailure, - (OutputterPrintStatisticsFunction) TextOutputter_printStatistics, -}; - -static const Outputter TextOutputter = { - (OutputterImplementRef)&TextOutputterImplement, -}; - -OutputterRef TextOutputter_outputter(void) -{ - return (OutputterRef)&TextOutputter; -} +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: TextOutputter.c,v 1.4 2003/09/06 13:28:27 arms22 Exp $ + */ +#include <stdio.h> +#include "TextOutputter.h" + +static void TextOutputter_printHeader(OutputterRef self) +{ + (void)self; +} + +static void TextOutputter_printStartTest(OutputterRef self,TestRef test) +{ + (void)self; + fprintf(stdout,"- %s\n",Test_name(test)); +} + +static void TextOutputter_printEndTest(OutputterRef self,TestRef test) +{ + (void)self; + (void)test; +} + +static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) +{ + (void)self; + fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test)); +} + +static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) +{ + (void)self; + fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg); +} + +static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result) +{ + (void)self; + if (result->failureCount) { + fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount); + } else { + fprintf(stdout,"\nOK (%d tests)\n",result->runCount); + } +} + +static const OutputterImplement TextOutputterImplement = { + (OutputterPrintHeaderFunction) TextOutputter_printHeader, + (OutputterPrintStartTestFunction) TextOutputter_printStartTest, + (OutputterPrintEndTestFunction) TextOutputter_printEndTest, + (OutputterPrintSuccessfulFunction) TextOutputter_printSuccessful, + (OutputterPrintFailureFunction) TextOutputter_printFailure, + (OutputterPrintStatisticsFunction) TextOutputter_printStatistics, +}; + +static const Outputter TextOutputter = { + (OutputterImplementRef)&TextOutputterImplement, +}; + +OutputterRef TextOutputter_outputter(void) +{ + return (OutputterRef)&TextOutputter; +} diff --git a/tests/unittests/embunit/textui/TextUIRunner.c b/tests/unittests/embunit/textui/TextUIRunner.c index 7dade444a7d92b0fb1a6974529426897014b3789..b10e6f870fcd1beb6d5924c681f0553ce974450b 100644 --- a/tests/unittests/embunit/textui/TextUIRunner.c +++ b/tests/unittests/embunit/textui/TextUIRunner.c @@ -43,17 +43,21 @@ static int wasfailure_ = 0; static void TextUIRunner_startTest(TestListnerRef self,TestRef test) { + (void)self; + (void)test; wasfailure_ = 0; } static void TextUIRunner_endTest(TestListnerRef self,TestRef test) { + (void)self; if (!wasfailure_) Outputter_printSuccessful(outputterRef_,test,result_.runCount); } static void TextUIRunner_addFailure(TestListnerRef self,TestRef test,char *msg,int line,char *file) { + (void)self; wasfailure_ = 1; Outputter_printFailure(outputterRef_,test,msg,line,file,result_.runCount); } diff --git a/tests/unittests/embunit/textui/XMLOutputter.c b/tests/unittests/embunit/textui/XMLOutputter.c index 7e0087b5caebcfdea7d61866a1142ddbb6791043..3211d4a81ee06a649615470db3cdbd6e23ae1044 100644 --- a/tests/unittests/embunit/textui/XMLOutputter.c +++ b/tests/unittests/embunit/textui/XMLOutputter.c @@ -1,109 +1,115 @@ -/* - * COPYRIGHT AND PERMISSION NOTICE - * - * Copyright (c) 2003 Embedded Unit Project - * - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies - * of the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY - * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - * - * $Id: XMLOutputter.c,v 1.6 2003/09/26 16:32:01 arms22 Exp $ - */ -#include <stdio.h> -#include "XMLOutputter.h" - -static char *stylesheet_; - -static void XMLOutputter_printHeader(OutputterRef self) -{ - fprintf(stdout,"<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n"); - if (stylesheet_) - fprintf(stdout,"<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_); - fprintf(stdout,"<TestRun>\n"); -} - -static void XMLOutputter_printStartTest(OutputterRef self,TestRef test) -{ - fprintf(stdout,"<%s>\n",Test_name(test)); -} - -static void XMLOutputter_printEndTest(OutputterRef self,TestRef test) -{ - fprintf(stdout,"</%s>\n",Test_name(test)); -} - -static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) -{ - fprintf(stdout,"<Test id=\"%d\">\n",runCount); - fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); - fprintf(stdout,"</Test>\n"); -} - -static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) -{ - fprintf(stdout,"<FailedTest id=\"%d\">\n",runCount); - fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); - fprintf(stdout,"<Location>\n"); - fprintf(stdout,"<File>%s</File>\n",file); - fprintf(stdout,"<Line>%d</Line>\n",line); - fprintf(stdout,"</Location>\n"); - fprintf(stdout,"<Message>%s</Message>\n",msg); - fprintf(stdout,"</FailedTest>\n"); -} - -static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result) -{ - fprintf(stdout,"<Statistics>\n"); - fprintf(stdout,"<Tests>%d</Tests>\n",result->runCount); - if (result->failureCount) { - fprintf(stdout,"<Failures>%d</Failures>\n",result->failureCount); - } - fprintf(stdout,"</Statistics>\n"); - fprintf(stdout,"</TestRun>\n"); -} - -static const OutputterImplement XMLOutputterImplement = { - (OutputterPrintHeaderFunction) XMLOutputter_printHeader, - (OutputterPrintStartTestFunction) XMLOutputter_printStartTest, - (OutputterPrintEndTestFunction) XMLOutputter_printEndTest, - (OutputterPrintSuccessfulFunction) XMLOutputter_printSuccessful, - (OutputterPrintFailureFunction) XMLOutputter_printFailure, - (OutputterPrintStatisticsFunction) XMLOutputter_printStatistics, -}; - -static const Outputter XMLOutputter = { - (OutputterImplementRef)&XMLOutputterImplement, -}; - -void XMLOutputter_setStyleSheet(char *style) -{ - stylesheet_ = style; -} - -OutputterRef XMLOutputter_outputter(void) -{ - return (OutputterRef)&XMLOutputter; -} +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (c) 2003 Embedded Unit Project + * + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies + * of the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written + * authorization of the copyright holder. + * + * $Id: XMLOutputter.c,v 1.6 2003/09/26 16:32:01 arms22 Exp $ + */ +#include <stdio.h> +#include "XMLOutputter.h" + +static char *stylesheet_; + +static void XMLOutputter_printHeader(OutputterRef self) +{ + (void)self; + fprintf(stdout,"<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n"); + if (stylesheet_) + fprintf(stdout,"<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_); + fprintf(stdout,"<TestRun>\n"); +} + +static void XMLOutputter_printStartTest(OutputterRef self,TestRef test) +{ + (void)self; + fprintf(stdout,"<%s>\n",Test_name(test)); +} + +static void XMLOutputter_printEndTest(OutputterRef self,TestRef test) +{ + (void)self; + fprintf(stdout,"</%s>\n",Test_name(test)); +} + +static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount) +{ + (void)self; + fprintf(stdout,"<Test id=\"%d\">\n",runCount); + fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); + fprintf(stdout,"</Test>\n"); +} + +static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount) +{ + (void)self; + fprintf(stdout,"<FailedTest id=\"%d\">\n",runCount); + fprintf(stdout,"<Name>%s</Name>\n",Test_name(test)); + fprintf(stdout,"<Location>\n"); + fprintf(stdout,"<File>%s</File>\n",file); + fprintf(stdout,"<Line>%d</Line>\n",line); + fprintf(stdout,"</Location>\n"); + fprintf(stdout,"<Message>%s</Message>\n",msg); + fprintf(stdout,"</FailedTest>\n"); +} + +static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result) +{ + (void)self; + fprintf(stdout,"<Statistics>\n"); + fprintf(stdout,"<Tests>%d</Tests>\n",result->runCount); + if (result->failureCount) { + fprintf(stdout,"<Failures>%d</Failures>\n",result->failureCount); + } + fprintf(stdout,"</Statistics>\n"); + fprintf(stdout,"</TestRun>\n"); +} + +static const OutputterImplement XMLOutputterImplement = { + (OutputterPrintHeaderFunction) XMLOutputter_printHeader, + (OutputterPrintStartTestFunction) XMLOutputter_printStartTest, + (OutputterPrintEndTestFunction) XMLOutputter_printEndTest, + (OutputterPrintSuccessfulFunction) XMLOutputter_printSuccessful, + (OutputterPrintFailureFunction) XMLOutputter_printFailure, + (OutputterPrintStatisticsFunction) XMLOutputter_printStatistics, +}; + +static const Outputter XMLOutputter = { + (OutputterImplementRef)&XMLOutputterImplement, +}; + +void XMLOutputter_setStyleSheet(char *style) +{ + stylesheet_ = style; +} + +OutputterRef XMLOutputter_outputter(void) +{ + return (OutputterRef)&XMLOutputter; +} diff --git a/tests/unittests/embunit/textui/makefile b/tests/unittests/embunit/textui/makefile deleted file mode 100644 index 746dd791a14fad30ad1925f22f957eea79c6407b..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/textui/makefile +++ /dev/null @@ -1,30 +0,0 @@ -CC = gcc -CFLAGS = -O -INCLUDES = .. -LIBS = ../lib -AR = ar -ARFLAGS = ru -RANLIB = ranlib -RM = rm -OUTPUT = ../lib/ -TARGET = libtextui.a -OBJS = TextUIRunner.o XMLOutputter.o TextOutputter.o CompilerOutputter.o - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(AR) $(ARFLAGS) $(OUTPUT)$@ $(OBJS) - $(RANLIB) $(OUTPUT)$@ - -.c.o: - $(CC) $(CFLAGS) -I$(INCLUDES) -c $< - -TextUIRunner.o: TextUIRunner.h XMLOutputter.h TextOutputter.h CompilerOutputter.h Outputter.h -XMLOutputter.o: XMLOutputter.h Outputter.h -TextOutputter.o: TextOutputter.h Outputter.h -CompilerOutputter.o: CompilerOutputter.h Outputter.h - -clean: - -$(RM) $(TARGET) $(OBJS) - -.PHONY: clean all diff --git a/tests/unittests/embunit/tools/COPYING b/tests/unittests/embunit/tools/COPYING deleted file mode 100644 index b5064458ae46dd7a5b08fdb7bef12b8012026f24..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/COPYING +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2003 Embedded Unit Project -Copyright (c) 2002 cuppa project - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/unittests/embunit/tools/makefile b/tests/unittests/embunit/tools/makefile deleted file mode 100644 index bec4eece6f4bb28d7467260bd0224cddc4838049..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/makefile +++ /dev/null @@ -1,23 +0,0 @@ -CC = gcc -CFLAGS = -O -INCLUDE =-I./tbcuppa/ -RM = rm - -all: bcuppa tcuppa buma tuma - -bcuppa:./tbcuppa/bcuppa.c ./tbcuppa/strvec.c - $(CC) -o $@ $(INCLUDE) ./tbcuppa/bcuppa.c ./tbcuppa/strvec.c - -tcuppa:./tbcuppa/tcuppa.c ./tbcuppa/strvec.c - $(CC) -o $@ $(INCLUDE) ./tbcuppa/tcuppa.c ./tbcuppa/strvec.c - -buma:./tbuma/buma.c ./tbcuppa/strvec.c - $(CC) -o $@ $(INCLUDE) ./tbuma/buma.c ./tbcuppa/strvec.c - -tuma:./tbuma/tuma.c ./tbcuppa/strvec.c - $(CC) -o $@ $(INCLUDE) ./tbuma/tuma.c ./tbcuppa/strvec.c - -clean: - $(RM) bcuppa tcuppa buma tuma - -.PHONY: clean all diff --git a/tests/unittests/embunit/tools/readme.txt b/tests/unittests/embunit/tools/readme.txt deleted file mode 100644 index 7402173c35f21200bfb9e3cfd5c1ac39b709cc8d..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/readme.txt +++ /dev/null @@ -1,84 +0,0 @@ - -1.概要 - - ちび河童&ちび馬は河童プロジェクトで作られたCUnit対応テストコード雛型 - 生成ツールです. - このちび河童&ちび馬の吐き出すコードをEmbedded Unit用に書き換えました. - - オリジナルのちび河童&ちび馬は以下のURLから入手可能です. - - 河童プロジェクト - http://sourceforge.jp/projects/cuppa/ - - 河童(CppUnit PreProcess Aid) - http://www.unittest.org/ - - -2.ファイル構成 - - [tools] - +- readme.txt :このファイル - +- makefile :メイクファイル - +- COPYING :著作権表示 - +- [tbcuppa] :ちび河童改ソースコード - +- [tbuma] :ちび馬改ソースコード - - -3.コンパイル - - toolsディレクトに移動して'make'コマンドを実行してください. - toolsディレクトリに以下の4つのアプリケーションが作成されます. - - tcuppa :テストグループの雛形を生成します. - bcuppa :tcuppaで生成されたテストグループを実行するmainを作成します. - tuma :tcuppaで生成されたテストグループにテストを追加します. - buma :bcuppaで生成されたmainにテスト実行コードを追加します. - - -4.使い方 - -4.1.tcuppa - My.hに定義されている関数をテストするテストグループ MyTest を生成したい場合 - - $ tcuppa My.h MyTest testXxx testYyy - - と入力する.そうするとMy.hをインクルードし空のテスト関数 - - static void testXxx(void) - static void testYyy(void) - - を実装したMyTest.c が生成される.ヘッダは省略可能,また複数指定可能. - -4.2.bcuppa - bcuppaはtcuppaによって生成されたテストグループを順次実行する - メインルーチンを生成します. - 先ほど作成した MyTest を実行するコード AllTests を生成するには - - $ bcuppa AllTests MyTest - - と入力する.またカレントディレクトリに ATest.c BTest.cと在った場合 - - $ bcuppa AllTests *Test.c - - のようなコマンドの指定が可能です. - -4.3.tuma - tcuppaで生成されたテストグループにテストを追加します. - やはり先ほど作成した MyTest にテスト testZzz を追加したい場合、 - - $ tuma MyTest testZzz - - と入力します. - -4.4.buma - bcuppaで生成された AllTests に実行コードを追加します. - 新しく YourTest と言うテストグループを生成します. - - $ tcuppa YourTest testXxx testYyy - - そして YourTest を AllTests に追加します. - - $ buma AllTests YourTest - ------------------------------------------------------------------------------- -$Id: readme.txt,v 1.1 2003/09/02 12:07:44 arms22 Exp $ diff --git a/tests/unittests/embunit/tools/readme_en.txt b/tests/unittests/embunit/tools/readme_en.txt deleted file mode 100644 index 532b89929eacd2ab7bb704390c9d9b60001c32fd..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/readme_en.txt +++ /dev/null @@ -1,73 +0,0 @@ -1.Overview - - This tools generates the test template code for the Embedded Unit. - The following four tools are distributed. - - tcuppa : generate test template source file - bcuppa : generate the main file, included main() - tuma : add a code to the code generated by tcuppa. - buma : add a code to the code generated by bcuppa. - - Original tcuppa, bcuppa, tuma, buma is developed by cuppa project. - It is generate the test template code for the CUnit. - It can be downloaded from the following URL. - - cuppa project - http://sourceforge.jp/projects/cuppa/ - - cuppa (CppUnit PreProcess Aid) - http://www.unittest.org/ - - -2.Contents - [tools] - +- readme.txt : japanese - +- readme_en.txt : this file - +- makefile : makefile - +- COPYING : copyright notice - +- [tbcuppa] : tcuppa & bcuppa source code - +- [tbuma] : tuma & buma source code - - -3.Compile - - $ cd <toolsdir> - $ make - - -4.Usage - -4.1.tcuppa - The following commands generate the "MyTest.c" file which tests the - function defined as My.h. - * It does not mean that the function of My.h is searched automatically. - - $ tcuppa My.h MyTest testXxx testYyy - - The file containing '.' is added to a code as a header file. - -4.2.bcuppa - bcuppa generates the main routine which performs the test generated by - tcuppa. The following commands generate the "AllTests.c" file which - performs MyTest. - - $ bcuppa AllTests MyTest - -4.3.tuma - The following commands add a "textZzz" test function to MyTest. - - $ tuma MyTest testZzz - -4.4.buma - The following commands generate "YourTest.c" containing "testXxx" and - "testYyy" test function. - - $ tcuppa YourTest testXxx testYyy - - And, then the following commands add the code which performs "YourTest.c" to - "AllTest.c". - - $ buma AllTests YourTest - ------------------------------------------------------------------------------- -$Id: readme_en.txt,v 1.3 2003/09/10 11:34:17 arms22 Exp $ diff --git a/tests/unittests/embunit/tools/tbcuppa/bcuppa.c b/tests/unittests/embunit/tools/tbcuppa/bcuppa.c deleted file mode 100644 index 26b68222bf749613af4c66d195d7b30e0b6cd4c8..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbcuppa/bcuppa.c +++ /dev/null @@ -1,73 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "strvec.h" - -int main(int argc, char* argv[]) { - strvec* groups; - char* name; - FILE* file; - char path[256]; - int i; - - groups = strvec_new(4); - name = 0; - - for ( i = 1; i < argc; ++i ) { - char arg[256]; - strcpy(arg,argv[i]); - if ( strchr(arg,'.') ) { - *strchr(arg,'.') = '\0'; - strvec_push_back(groups,arg); - } else if ( name ) { - strvec_push_back(groups,arg); - } else { - name = argv[i]; - } - } - - if ( !name ) { - return 0; - } - - strcpy(path, name); - strcat(path, ".c"); - - file = fopen(path, "wt"); - if ( !file ) { - fprintf(stderr, "%s open failure.\n", path); - return 1; - } - - fprintf(file, "#include <embUnit/embUnit.h>\n\n"); - - fprintf(file, "/*embunit:extern=+ */\n"); - for ( i = 0; i < strvec_size(groups); ++i ) { - fprintf(file, "extern TestRef %s_tests(void);\n" - ,strvec_get(groups,i)); - } - fprintf(file, "/*embunit:extern=- */\n\n"); - - fprintf(file, "int main(int argc,char *argv[])\n" - "{\n" - " TestRunner_start();\n" - ); - - fprintf(file, " /*embunit:run=+ */\n"); - for ( i = 0; i < strvec_size(groups); ++i ) { - fprintf(file, " TestRunner_runTest(%s_tests());\n", strvec_get(groups,i)); - } - fprintf(file, " /*embunit:run=- */\n"); - - fprintf(file, " TestRunner_end();\n" - " return 0;\n" - "}\n" - ); - - fclose(file); - - strvec_del(groups); - - return 0; - -} diff --git a/tests/unittests/embunit/tools/tbcuppa/strvec.c b/tests/unittests/embunit/tools/tbcuppa/strvec.c deleted file mode 100644 index 693d3e05218d7d823eee2daabe8333a324bf3962..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbcuppa/strvec.c +++ /dev/null @@ -1,108 +0,0 @@ -#include "strvec.h" - -#include <string.h> /* str... */ -#include <stdlib.h> /* malloc, free */ - -strvec* -strvec_new(int initial_capacity) { - strvec* result = (strvec*)malloc(sizeof(strvec)); - if ( result ) { - result->size = 0; - result->capa = 0; - result->body = (char**)malloc(sizeof(char*)*initial_capacity); - if ( result->body ) { - result->capa = initial_capacity; - } - } - return result; -} - -void -strvec_clear(strvec* sv) { - int i; - for ( i = 0; i < sv->size; ++i ) { - free(sv->body[i]); - } - sv->size = 0; -} - -void -strvec_del(strvec* sv) { - strvec_clear(sv); - free(sv); -} - -static void -strvec_grow(strvec* sv) { - if ( sv->size >= sv->capa ) { - int new_capa = sv->capa + 8; - char** new_body = (char**)malloc(sizeof(char*) * new_capa); - if ( new_body ) { - int i; - for ( i = 0; i < sv->size; ++i ) { - new_body[i] = sv->body[i]; - } - free(sv->body); - sv->body = new_body; - sv->capa = new_capa; - } - } -} - -void -strvec_push_back(strvec* sv, const char* str) { - strvec_grow(sv); - sv->body[sv->size++] = strdup(str); -} - -void -strvec_insert_before(strvec* sv, int pos, const char* str) { - int i; - if ( pos < 0 ) return; - if ( pos >= sv->size ) return; - strvec_grow(sv); - for ( i = sv->size; i > pos; --i ) { - sv->body[i] = sv->body[i-1]; - } - sv->body[pos] = strdup(str); - ++sv->size; -} - -int -strvec_size(const strvec* sv) { - return sv->size; -} - -void -strvec_erase(strvec* sv, int pos) { - int i; - if ( pos < 0 ) return; - if ( pos >= sv->size ) return; - free(sv->body[pos]); - for ( i = pos; i < sv->size - 1; ++i ) { - sv->body[i] = sv->body[i+1]; - } - --sv->size; -} - -int -strvec_capacity(const strvec* sv) { - return sv->capa; -} - -const -char* strvec_get(const strvec* sv, int index) { - if ( index >= 0 || index < sv->size ) { - return sv->body[index]; - } - return 0; -} - -int -strvec_find(const strvec* sv, const char* str) { - int i; - for ( i = 0; i < sv->size; ++i ) { - if ( strcmp(str, sv->body[i]) == 0 ) return i; - } - return -1; -} diff --git a/tests/unittests/embunit/tools/tbcuppa/strvec.h b/tests/unittests/embunit/tools/tbcuppa/strvec.h deleted file mode 100644 index 9363b5d68072ae2632161c43f7886dfd87c7f038..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbcuppa/strvec.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STRVEC_H -#define STRVEC_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct strvec_t { - char** body; - int size; - int capa; -}; - -typedef struct strvec_t strvec; - -strvec* strvec_new(int initial_capacity); -void strvec_del(strvec* sv); - -void strvec_push_back(strvec* sv, const char* str); -void strvec_insert_before(strvec* sv, int n, const char* str); -void strvec_erase(strvec* sv, int n); -int strvec_size(const strvec* sv); -int strvec_capacity(const strvec* sv); -const char* strvec_get(const strvec* sv, int n); -void strvec_clear(strvec* sv); -int strvec_find(const strvec* sv, const char* str); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tests/unittests/embunit/tools/tbcuppa/tcuppa.c b/tests/unittests/embunit/tools/tbcuppa/tcuppa.c deleted file mode 100644 index cfc9332bb2139ddf1e4a13ada3ecf97c875eaba3..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbcuppa/tcuppa.c +++ /dev/null @@ -1,105 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "strvec.h" - -int main(int argc, char* argv[]) { - strvec* includes; - strvec* cases; - char* group; - FILE* file; - char path[256]; - int i; - - includes = strvec_new(4); - cases = strvec_new(4); - group = 0; - - for ( i = 1; i < argc; ++i ) { - char* arg = argv[i]; - if ( strchr(arg,'.') ) { - strvec_push_back(includes,arg); - } else if ( group ) { - strvec_push_back(cases,arg); - } else { - group = arg; - } - } - - if ( !group ) { - return 0; - } - - strcpy(path, group); - strcat(path, ".c"); - file = fopen(path, "rt"); - if ( file ) { - fclose(file); - fprintf(stderr, "%s already exists. (skip)\n", path); - return 0; - } - - file = fopen(path, "wt"); - if ( !file ) { - fprintf(stderr, "%s open failure.\n", path); - return 1; - } - - fprintf(file, "#include <embUnit/embUnit.h>\n\n"); - - fprintf(file, "/*embunit:include=+ */\n"); - for ( i = 0; i < strvec_size(includes); ++i ) { - fprintf(file, "#include \"%s\"\n",strvec_get(includes,i)); - } - fprintf(file, "/*embunit:include=- */\n\n"); - - fprintf(file, "static void setUp(void)\n" - "{\n" - "\t/* initialize */\n" - "}\n\n" - "static void tearDown(void)\n" - "{\n" - "\t/* terminate */\n" - "}\n\n" - ); - - fprintf(file, "/*embunit:impl=+ */\n"); - for ( i = 0; i < strvec_size(cases); ++i ) { - fprintf(file, "static void %s(void)\n" - "{\n" - " TEST_FAIL(\"no implementation\");\n" - "}\n\n" - ,strvec_get(cases, i) - ); - } - fprintf(file, "/*embunit:impl=- */\n"); - - fprintf(file, "TestRef %s_tests(void)\n" - "{\n" - " EMB_UNIT_TESTFIXTURES(fixtures) {\n" - ,group - ); - - fprintf(file, " /*embunit:fixtures=+ */\n"); - for ( i = 0; i < strvec_size(cases); ++i ) { - fprintf(file, " new_TestFixture(\x22%s\x22,%s),\n" - ,strvec_get(cases, i), strvec_get(cases, i) - ); - } - fprintf(file, " /*embunit:fixtures=- */\n"); - - fprintf(file, " };\n" - " EMB_UNIT_TESTCALLER(%s,\x22%s\x22,setUp,tearDown,fixtures);\n" - " return (TestRef)&%s;\n" - "};\n" - ,group,group,group - ); - - fclose(file); - - strvec_del(includes); - strvec_del(cases); - - return 0; - -} diff --git a/tests/unittests/embunit/tools/tbuma/buma.c b/tests/unittests/embunit/tools/tbuma/buma.c deleted file mode 100644 index f14d0a95418190900b76a9783837089cd9226cbe..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbuma/buma.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "strvec.h" - -int main(int argc, char* argv[]) { - strvec* groups; - strvec* target; - char* runner; - FILE* file; - char path[256]; - char line[1024]; - int i; - int decl_pos; - int reg_pos; - - groups = strvec_new(4); - target = strvec_new(40); - runner = 0; - - for ( i = 1; i < argc; ++i ) { - char* arg = argv[i]; - if ( runner ) { - strvec_push_back(groups,arg); - } else { - runner = arg; - } - } - - if ( !runner ) { - return 0; - } - - strcpy(path, runner); - strcat(path, ".c"); - file = fopen(path, "rt"); - if ( !file ) { - fprintf(stderr, "can't open %s\n", path); - return 1; - } - - for ( i = 0; fgets(line, 1023, file); ++i ) { - strvec_push_back(target, line); - if ( strstr(line,"embunit:extern=-") ) decl_pos = i; - if ( strstr(line,"embunit:run=-" ) ) reg_pos = i; - } - - fclose(file); - - for ( i = 0; i < strvec_size(groups); ++i ) { - const char* name = strvec_get(groups,i); - sprintf(line," TestRunner_runTest(%s_tests());\n", name); - strvec_insert_before(target, reg_pos++, line); - } - - for ( i = 0; i < strvec_size(groups); ++i ) { - const char* name = strvec_get(groups,i); - sprintf(line,"extern TestRef %s_tests(void);\n", name); - strvec_insert_before(target, decl_pos++, line); - } - - file = fopen(path, "wt"); - if ( !file ) { - fprintf(stderr, "can't open %s\n", path); - return 1; - } - - for ( i = 0; i < strvec_size(target); ++i ) { - fprintf(file,"%s", strvec_get(target,i)); - } - fclose(file); - - strvec_del(target); - strvec_del(groups); - - return 0; - -} diff --git a/tests/unittests/embunit/tools/tbuma/tuma.c b/tests/unittests/embunit/tools/tbuma/tuma.c deleted file mode 100644 index bf9c1f96987fa91f37464146fb62d8fb4ca57326..0000000000000000000000000000000000000000 --- a/tests/unittests/embunit/tools/tbuma/tuma.c +++ /dev/null @@ -1,120 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "strvec.h" - -int main(int argc, char* argv[]) { - strvec* includes; - strvec* cases; - strvec* target; - char* group; - FILE* file; - char path[256]; - char line[1024]; - int i; - int incl_pos; - int impl_pos; - int suite_pos; - int in_incl; - int in_suite; - - includes = strvec_new(4); - cases = strvec_new(4); - target = strvec_new(40); - group = 0; - - for ( i = 1; i < argc; ++i ) { - char* arg = argv[i]; - if ( strchr(arg,'.') ) { - strvec_push_back(includes, arg); - } else if ( group ) { - strvec_push_back(cases,arg); - } else { - group = arg; - } - } - - if ( !group ) { - return 0; - } - - strcpy(path, group); - strcat(path, ".c"); - file = fopen(path, "rt"); - if ( !file ) { - fprintf(stderr, "can't open %s\n", path); - return 1; - } - - in_incl = 0; - in_suite = 0; - for ( i = 0; fgets(line, 1023, file); ++i ) { - char* token; - strvec_push_back(target, line); - if ( strstr(line,"embunit:include=+") ) in_incl = 1; - if ( strstr(line,"embunit:fixtures=+" ) ) in_suite = 1; - if ( strstr(line,"embunit:include=-") ) { incl_pos = i; in_incl = 0; } - if ( strstr(line,"embunit:impl=-" ) ) impl_pos = i; - if ( strstr(line,"embunit:fixtures=-" ) ) { suite_pos = i; in_suite = 0; } - else { - if ( in_incl ) { - strtok(line,"\"<>"); token = strtok(0, "\"<>"); - if ( token ) { - int i = strvec_find(includes, token); - if ( i >= 0 ) { - strvec_erase(includes,i); - break; - } - } - } - else if ( in_suite ) { - strtok(line,", \t"); token = strtok(0, ", \t"); token = strtok(0, ", \t)"); - if ( token ) { - int i = strvec_find(cases, token); - if ( i >= 0 ) { - strvec_erase(cases,i); - break; - } - } - } - } - } - - fclose(file); - - for ( i = 0; i < strvec_size(cases); ++i ) { - const char* name = strvec_get(cases,i); - sprintf(line," new_TestFixture(\x22%s\x22,%s),\n", name, name); - strvec_insert_before(target, suite_pos++, line); - } - - for ( i = 0; i < strvec_size(cases); ++i ) { - const char* name = strvec_get(cases,i); - sprintf(line,"static void %s(void)\n{\n\tTEST_FAIL(\"no implementation\");\n}\n\n", name); - strvec_insert_before(target, impl_pos++, line); - } - - for ( i = 0; i < strvec_size(includes); ++i ) { - const char* name = strvec_get(includes,i); - sprintf(line,"#include \"%s\"\n", name); - strvec_insert_before(target, incl_pos++, line); - } - - file = fopen(path, "wt"); - if ( !file ) { - fprintf(stderr, "can't open %s\n", path); - return 1; - } - - for ( i = 0; i < strvec_size(target); ++i ) { - fprintf(file,"%s", strvec_get(target,i)); - } - fclose(file); - - strvec_del(target); - strvec_del(includes); - strvec_del(cases); - - return 0; - -}