mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #381 from authmillenon/unittests
Unittests via embUnit
This commit is contained in:
commit
3903b8add2
9
Makefile
9
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:
|
||||
|
21
tests/unittests/Makefile
Normal file
21
tests/unittests/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
export PROJECT = unittests
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += embunit
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
|
||||
|
||||
ifeq ($(OUTPUT),XML)
|
||||
CFLAGS += -DOUTPUT=OUTPUT_XML
|
||||
USEMODULE += embunit_textui
|
||||
else ifeq ($(OUTPUT),TEXT)
|
||||
CFLAGS += -DOUTPUT=OUTPUT_TEXT
|
||||
USEMODULE += embunit_textui
|
||||
else ifeq ($(OUTPUT),COMPILER)
|
||||
CFLAGS += -DOUTPUT=OUTPUT_COMPILER
|
||||
USEMODULE += embunit_textui
|
||||
endif
|
||||
|
||||
.PHONY : all clean core
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
6
tests/unittests/README.md
Normal file
6
tests/unittests/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Unittests
|
||||
|
||||
see [Wiki][Testing-RIOT]
|
||||
|
||||
|
||||
[Testing-RIOT]: https://github.com/RIOT-OS/RIOT/wiki/Testing-RIOT
|
1
tests/unittests/embunit/AUTHORS
Normal file
1
tests/unittests/embunit/AUTHORS
Normal file
@ -0,0 +1 @@
|
||||
arms22<arms22@users.sourceforge.jp> <arms22@users.sourceforge.net>
|
30
tests/unittests/embunit/COPYING
Normal file
30
tests/unittests/embunit/COPYING
Normal file
@ -0,0 +1,30 @@
|
||||
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.
|
100
tests/unittests/embunit/embUnit/AssertImpl.c
Normal file
100
tests/unittests/embunit/embUnit/AssertImpl.c
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: AssertImpl.c,v 1.5 2004/02/10 16:15:25 arms22 Exp $
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "stdImpl.h"
|
||||
#include "AssertImpl.h"
|
||||
|
||||
void assertImplementationInt(int expected,int actual, long line, const char *file)
|
||||
{
|
||||
char buffer[32]; /*"exp -2147483647 was -2147483647"*/
|
||||
char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/
|
||||
|
||||
stdimpl_strcpy(buffer, "exp ");
|
||||
|
||||
{ stdimpl_itoa(expected, numbuf, 10);
|
||||
stdimpl_strncat(buffer, numbuf, 11); }
|
||||
|
||||
stdimpl_strcat(buffer, " was ");
|
||||
|
||||
{ stdimpl_itoa(actual, numbuf, 10);
|
||||
stdimpl_strncat(buffer, numbuf, 11); }
|
||||
|
||||
addFailure(buffer, line, file);
|
||||
}
|
||||
|
||||
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file)
|
||||
{
|
||||
char buffer[ASSERT_STRING_BUFFER_MAX];
|
||||
#define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */
|
||||
int el;
|
||||
int al;
|
||||
|
||||
if (expected) {
|
||||
el = stdimpl_strlen(expected);
|
||||
} else {
|
||||
el = 4;
|
||||
expected = "null";
|
||||
}
|
||||
|
||||
if (actual) {
|
||||
al = stdimpl_strlen(actual);
|
||||
} else {
|
||||
al = 4;
|
||||
actual = "null";
|
||||
}
|
||||
if (el > exp_act_limit) {
|
||||
if (al > exp_act_limit) {
|
||||
al = exp_act_limit;
|
||||
el = exp_act_limit;
|
||||
} else {
|
||||
int w = exp_act_limit + (exp_act_limit - al);
|
||||
if (el > w) {
|
||||
el = w;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int w = exp_act_limit + (exp_act_limit - el);
|
||||
if (al > w) {
|
||||
al = w;
|
||||
}
|
||||
}
|
||||
stdimpl_strcpy(buffer, "exp \"");
|
||||
stdimpl_strncat(buffer, expected, el);
|
||||
stdimpl_strcat(buffer, "\" was \"");
|
||||
stdimpl_strncat(buffer, actual, al);
|
||||
stdimpl_strcat(buffer, "\"");
|
||||
|
||||
addFailure(buffer, line, file);
|
||||
}
|
72
tests/unittests/embunit/embUnit/AssertImpl.h
Normal file
72
tests/unittests/embunit/embUnit/AssertImpl.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $
|
||||
*/
|
||||
#ifndef __ASSERTIMPL_H__
|
||||
#define __ASSERTIMPL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/
|
||||
|
||||
void assertImplementationInt(int expected,int actual, long line, const char *file);
|
||||
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file);
|
||||
|
||||
#define TEST_ASSERT_EQUAL_STRING(expected,actual)\
|
||||
if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;}
|
||||
|
||||
#define TEST_ASSERT_EQUAL_INT(expected,actual)\
|
||||
if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;}
|
||||
|
||||
#define TEST_ASSERT_NULL(pointer)\
|
||||
TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.")
|
||||
|
||||
#define TEST_ASSERT_NOT_NULL(pointer)\
|
||||
TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.")
|
||||
|
||||
#define TEST_ASSERT_MESSAGE(condition, message)\
|
||||
if (condition) {} else {TEST_FAIL(message);}
|
||||
|
||||
#define TEST_ASSERT(condition)\
|
||||
if (condition) {} else {TEST_FAIL(#condition);}
|
||||
|
||||
#define TEST_FAIL(message)\
|
||||
if (0) {} else {addFailure(message,__LINE__,__FILE__);return;}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif/*__ASSERTIMPL_H__*/
|
59
tests/unittests/embunit/embUnit/HelperMacro.h
Normal file
59
tests/unittests/embunit/embUnit/HelperMacro.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __HELPERMACRO_H__
|
||||
#define __HELPERMACRO_H__
|
||||
|
||||
#define EMB_UNIT_TESTCASE(ca,sup,tdw,run) \
|
||||
static const TestCase ca = new_TestCase(#ca,sup,tdw,run)
|
||||
|
||||
#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[] =
|
||||
|
||||
#define EMB_UNIT_ADD_TESTREF(testref) \
|
||||
(Test*) testref
|
||||
|
||||
#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[] =
|
||||
|
||||
#define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \
|
||||
static const RepeatedTest repeater = new_RepeatedTest(test,tmrp)
|
||||
|
||||
#endif/*__HELPERMACRO_H__*/
|
5
tests/unittests/embunit/embUnit/Makefile
Normal file
5
tests/unittests/embunit/embUnit/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
MODULE = embunit
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
61
tests/unittests/embunit/embUnit/RepeatedTest.c
Normal file
61
tests/unittests/embunit/embUnit/RepeatedTest.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: RepeatedTest.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "RepeatedTest.h"
|
||||
|
||||
char* RepeatedTest_name(RepeatedTest* self)
|
||||
{
|
||||
return Test_name(self->test);
|
||||
}
|
||||
|
||||
void RepeatedTest_run(RepeatedTest* self,TestResult* result)
|
||||
{
|
||||
int i;
|
||||
Test* test = self->test;
|
||||
for (i=0; i<self->timesRepeat; i++) {
|
||||
Test_run(test, result);
|
||||
}
|
||||
}
|
||||
|
||||
int RepeatedTest_countTestCases(RepeatedTest* self)
|
||||
{
|
||||
return Test_countTestCases(self->test) * self->timesRepeat;
|
||||
}
|
||||
|
||||
const TestImplement RepeatedTestImplement = {
|
||||
(TestNameFunction) RepeatedTest_name,
|
||||
(TestRunFunction) RepeatedTest_run,
|
||||
(TestCountTestCasesFunction)RepeatedTest_countTestCases,
|
||||
};
|
56
tests/unittests/embunit/embUnit/RepeatedTest.h
Normal file
56
tests/unittests/embunit/embUnit/RepeatedTest.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __REPEATEDTEST_H__
|
||||
#define __REPEATEDTEST_H__
|
||||
|
||||
typedef struct __RepeatedTest RepeatedTest;
|
||||
typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/
|
||||
|
||||
struct __RepeatedTest {
|
||||
TestImplement* isa;
|
||||
Test* test;
|
||||
int timesRepeat;
|
||||
};
|
||||
|
||||
extern const TestImplement RepeatedTestImplement;
|
||||
|
||||
#define new_RepeatedTest(test,tmrp)\
|
||||
{\
|
||||
(TestImplement*)&RepeatedTestImplement,\
|
||||
(Test*)test,\
|
||||
tmrp,\
|
||||
}
|
||||
|
||||
#endif/*__REPEATEDTEST_H__*/
|
65
tests/unittests/embunit/embUnit/Test.h
Normal file
65
tests/unittests/embunit/embUnit/Test.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TEST_H__
|
||||
#define __TEST_H__
|
||||
|
||||
typedef struct __TestResult TestResult;
|
||||
typedef struct __TestResult* TestResultRef;/*downward compatible*/
|
||||
|
||||
typedef struct __TestImplement TestImplement;
|
||||
typedef struct __TestImplement* TestImplementRef;/*downward compatible*/
|
||||
|
||||
typedef char*(*TestNameFunction)(void*);
|
||||
typedef void(*TestRunFunction)(void*,TestResult*);
|
||||
typedef int(*TestCountTestCasesFunction)(void*);
|
||||
|
||||
struct __TestImplement {
|
||||
TestNameFunction name;
|
||||
TestRunFunction run;
|
||||
TestCountTestCasesFunction countTestCases;
|
||||
};
|
||||
|
||||
typedef struct __Test Test;
|
||||
typedef struct __Test* TestRef;/*downward compatible*/
|
||||
|
||||
struct __Test {
|
||||
TestImplement* isa;
|
||||
};
|
||||
|
||||
#define Test_name(s) ((Test*)s)->isa->name(s)
|
||||
#define Test_run(s,r) ((Test*)s)->isa->run(s,r)
|
||||
#define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s)
|
||||
|
||||
#endif/*__TEST_H__*/
|
67
tests/unittests/embunit/embUnit/TestCaller.c
Normal file
67
tests/unittests/embunit/embUnit/TestCaller.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestCaller.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "TestCase.h"
|
||||
#include "TestCaller.h"
|
||||
|
||||
char* TestCaller_name(TestCaller* self)
|
||||
{
|
||||
return self->name;
|
||||
}
|
||||
|
||||
void TestCaller_run(TestCaller* self,TestResult* result)
|
||||
{
|
||||
TestCase cs = new_TestCase(0,0,0,0);
|
||||
int i;
|
||||
cs.setUp= self->setUp;
|
||||
cs.tearDown = self->tearDown;
|
||||
for (i=0; i<self->numberOfFixtuers; i++) {
|
||||
cs.name = self->fixtuers[i].name;
|
||||
cs.runTest = self->fixtuers[i].test;
|
||||
/*run test*/
|
||||
Test_run(&cs,result);
|
||||
}
|
||||
}
|
||||
|
||||
int TestCaller_countTestCases(TestCaller* self)
|
||||
{
|
||||
return self->numberOfFixtuers;
|
||||
}
|
||||
|
||||
const TestImplement TestCallerImplement = {
|
||||
(TestNameFunction) TestCaller_name,
|
||||
(TestRunFunction) TestCaller_run,
|
||||
(TestCountTestCasesFunction)TestCaller_countTestCases,
|
||||
};
|
72
tests/unittests/embunit/embUnit/TestCaller.h
Normal file
72
tests/unittests/embunit/embUnit/TestCaller.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestCaller.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTCALLER_H__
|
||||
#define __TESTCALLER_H__
|
||||
|
||||
typedef struct __TestFixture TestFixture;
|
||||
typedef struct __TestFixture* TestFixtureRef;/*downward compatible*/
|
||||
|
||||
struct __TestFixture {
|
||||
char *name;
|
||||
void(*test)(void);
|
||||
};
|
||||
|
||||
#define new_TestFixture(test) { #test, test }
|
||||
|
||||
typedef struct __TestCaller TestCaller;
|
||||
typedef struct __TestCaller* TestCallerRef;/*downward compatible*/
|
||||
|
||||
struct __TestCaller {
|
||||
TestImplement* isa;
|
||||
char *name;
|
||||
void(*setUp)(void);
|
||||
void(*tearDown)(void);
|
||||
int numberOfFixtuers;
|
||||
TestFixture *fixtuers;
|
||||
};
|
||||
|
||||
extern const TestImplement TestCallerImplement;
|
||||
|
||||
#define new_TestCaller(name,sup,tdw,numberOfFixtuers,fixtuers)\
|
||||
{\
|
||||
(TestImplement*)&TestCallerImplement,\
|
||||
name,\
|
||||
sup,\
|
||||
tdw,\
|
||||
numberOfFixtuers,\
|
||||
fixtuers,\
|
||||
}
|
||||
|
||||
#endif/*__TESTCALLER_H__*/
|
83
tests/unittests/embunit/embUnit/TestCase.c
Normal file
83
tests/unittests/embunit/embUnit/TestCase.c
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestCase.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "TestCase.h"
|
||||
#include "TestResult.h"
|
||||
|
||||
static TestResult* result_;
|
||||
static TestCase* self_;
|
||||
|
||||
char* TestCase_name(TestCase* self)
|
||||
{
|
||||
return self->name;
|
||||
}
|
||||
|
||||
void TestCase_run(TestCase* self,TestResult* result)
|
||||
{
|
||||
TestResult_startTest(result, (Test*)self);
|
||||
if (self->setUp) {
|
||||
self->setUp();
|
||||
}
|
||||
if (self->runTest) {
|
||||
TestResult* wr =result_; /*push*/
|
||||
TestCase* ws = self_; /*push*/
|
||||
result_ = result;
|
||||
self_ = self;
|
||||
self->runTest();
|
||||
result_ = wr; /*pop*/
|
||||
self_ = ws; /*pop*/
|
||||
}
|
||||
if (self->tearDown) {
|
||||
self->tearDown();
|
||||
}
|
||||
TestResult_endTest(result, (Test*)self);
|
||||
}
|
||||
|
||||
int TestCase_countTestCases(TestCase* self)
|
||||
{
|
||||
(void)self;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const TestImplement TestCaseImplement = {
|
||||
(TestNameFunction) TestCase_name,
|
||||
(TestRunFunction) TestCase_run,
|
||||
(TestCountTestCasesFunction)TestCase_countTestCases,
|
||||
};
|
||||
|
||||
void addFailure(const char *msg, long line, const char *file)
|
||||
{
|
||||
TestResult_addFailure(result_, (Test*)self_, (char*)msg, line, (char*)file);
|
||||
}
|
60
tests/unittests/embunit/embUnit/TestCase.h
Normal file
60
tests/unittests/embunit/embUnit/TestCase.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestCase.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTCASE_H__
|
||||
#define __TESTCASE_H__
|
||||
|
||||
typedef struct __TestCase TestCase;
|
||||
typedef struct __TestCase* TestCaseRef;/*compatible embUnit1.0*/
|
||||
|
||||
struct __TestCase {
|
||||
TestImplement* isa;
|
||||
char *name;
|
||||
void(*setUp)(void);
|
||||
void(*tearDown)(void);
|
||||
void(*runTest)(void);
|
||||
};
|
||||
|
||||
extern const TestImplement TestCaseImplement;
|
||||
|
||||
#define new_TestCase(name,setUp,tearDown,runTest)\
|
||||
{\
|
||||
(TestImplement*)&TestCaseImplement,\
|
||||
name,\
|
||||
setUp,\
|
||||
tearDown,\
|
||||
runTest,\
|
||||
}
|
||||
|
||||
#endif/*__TESTCASE_H__*/
|
62
tests/unittests/embunit/embUnit/TestListener.h
Normal file
62
tests/unittests/embunit/embUnit/TestListener.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestListener.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTLISTENER_H__
|
||||
#define __TESTLISTENER_H__
|
||||
|
||||
typedef struct __TestListnerImplement TestListnerImplement;
|
||||
typedef struct __TestListnerImplement* TestListnerImplementRef;/*downward compatible*/
|
||||
|
||||
typedef void(*TestListnerStartTestCallBack)(void*,void*);
|
||||
typedef void(*TestListnerEndTestCallBack)(void*,void*);
|
||||
typedef void(*TestListnerAddFailureCallBack)(void*,void*,const char*,int,const char*);
|
||||
|
||||
struct __TestListnerImplement {
|
||||
TestListnerStartTestCallBack startTest;
|
||||
TestListnerEndTestCallBack endTest;
|
||||
TestListnerAddFailureCallBack addFailure;
|
||||
};
|
||||
|
||||
/*typedef struct __TestListner TestListner;*/ /*->TestResult.h*/
|
||||
/*typedef struct __TestListner* TestListnerRef;*/ /*->TestResult.h*/
|
||||
|
||||
struct __TestListner {
|
||||
TestListnerImplement* isa;
|
||||
};
|
||||
|
||||
#define TestListner_startTest(s,t) ((TestListner*)s)->isa->startTest(s,t)
|
||||
#define TestListner_endTest(s,t) ((TestListner*)s)->isa->endTest(s,t)
|
||||
#define TestListner_addFailure(s,t,m,l,f) ((TestListner*)s)->isa->addFailure(s,t,m,l,f)
|
||||
|
||||
#endif/*__TESTLISTENER_H__*/
|
67
tests/unittests/embunit/embUnit/TestResult.c
Normal file
67
tests/unittests/embunit/embUnit/TestResult.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestResult.c,v 1.4 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "TestListener.h"
|
||||
#include "TestResult.h"
|
||||
|
||||
void TestResult_init(TestResult* self,TestListner* listner)
|
||||
{
|
||||
self->runCount = 0;
|
||||
self->failureCount = 0;
|
||||
self->listener = listner;
|
||||
}
|
||||
|
||||
void TestResult_startTest(TestResult* self,Test* test)
|
||||
{
|
||||
self->runCount++;
|
||||
if (self->listener) {
|
||||
TestListner_startTest(self->listener, test);
|
||||
}
|
||||
}
|
||||
|
||||
void TestResult_endTest(TestResult* self,Test* test)
|
||||
{
|
||||
if (self->listener) {
|
||||
TestListner_endTest(self->listener, test);
|
||||
}
|
||||
}
|
||||
|
||||
void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file)
|
||||
{
|
||||
self->failureCount++;
|
||||
if (self->listener) {
|
||||
TestListner_addFailure(self->listener, test, msg, line, file);
|
||||
}
|
||||
}
|
70
tests/unittests/embunit/embUnit/TestResult.h
Normal file
70
tests/unittests/embunit/embUnit/TestResult.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestResult.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTRESULT_H__
|
||||
#define __TESTRESULT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*typedef struct __TestResult TestResult;*//* -> Test.h*/
|
||||
/*typedef struct __TestResult* TestResultRef;*//* -> Test.h*/
|
||||
|
||||
typedef struct __TestListner TestListner;
|
||||
typedef struct __TestListner* TestListnerRef;/*downward compatible*/
|
||||
|
||||
struct __TestResult {
|
||||
unsigned short runCount;
|
||||
unsigned short failureCount;
|
||||
TestListner* listener;
|
||||
};
|
||||
|
||||
#define new_TestResult(listener)\
|
||||
{\
|
||||
0,\
|
||||
0,\
|
||||
(TestListner*)listener,\
|
||||
}
|
||||
|
||||
void TestResult_init(TestResult* self,TestListner* listner);
|
||||
void TestResult_startTest(TestResult* self,Test* test);
|
||||
void TestResult_endTest(TestResult* self,Test* test);
|
||||
void TestResult_addFailure(TestResult* self,Test* test,const char* msg,int line,const char* file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif/*__TESTRESULT_H__*/
|
116
tests/unittests/embunit/embUnit/TestRunner.c
Normal file
116
tests/unittests/embunit/embUnit/TestRunner.c
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestRunner.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "stdImpl.h"
|
||||
#include "Test.h"
|
||||
#include "TestListener.h"
|
||||
#include "TestResult.h"
|
||||
#include "TestRunner.h"
|
||||
|
||||
static TestResult result_;
|
||||
static Test* root_;
|
||||
|
||||
static void TestRunner_startTest(TestListner* self,Test* test)
|
||||
{
|
||||
(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(".");
|
||||
stdimpl_print(Test_name(test));
|
||||
{
|
||||
char buf[16];
|
||||
stdimpl_print(" (");
|
||||
stdimpl_print(file);
|
||||
stdimpl_print(" ");
|
||||
stdimpl_itoa(line, buf, 10);
|
||||
stdimpl_print(buf);
|
||||
stdimpl_print(") ");
|
||||
}
|
||||
stdimpl_print(msg);
|
||||
stdimpl_print("\n");
|
||||
}
|
||||
|
||||
static const TestListnerImplement TestRunnerImplement = {
|
||||
(TestListnerStartTestCallBack) TestRunner_startTest,
|
||||
(TestListnerEndTestCallBack) TestRunner_endTest,
|
||||
(TestListnerAddFailureCallBack) TestRunner_addFailure,
|
||||
};
|
||||
|
||||
static const TestListner testrunner_ = {
|
||||
(TestListnerImplement*)&TestRunnerImplement,
|
||||
};
|
||||
|
||||
void TestRunner_start(void)
|
||||
{
|
||||
TestResult_init(&result_, (TestListner*)&testrunner_);
|
||||
}
|
||||
|
||||
void TestRunner_runTest(Test* test)
|
||||
{
|
||||
root_ = test;
|
||||
Test_run(test, &result_);
|
||||
}
|
||||
|
||||
void TestRunner_end(void)
|
||||
{
|
||||
char buf[16];
|
||||
if (result_.failureCount) {
|
||||
stdimpl_print("\nrun ");
|
||||
stdimpl_itoa(result_.runCount, buf, 10);
|
||||
stdimpl_print(buf);
|
||||
stdimpl_print(" failures ");
|
||||
stdimpl_itoa(result_.failureCount, buf, 10);
|
||||
stdimpl_print(buf);
|
||||
stdimpl_print("\n");
|
||||
} else {
|
||||
stdimpl_print("\nOK (");
|
||||
stdimpl_itoa(result_.runCount, buf, 10);
|
||||
stdimpl_print(buf);
|
||||
stdimpl_print(" tests)\n");
|
||||
}
|
||||
}
|
50
tests/unittests/embunit/embUnit/TestRunner.h
Normal file
50
tests/unittests/embunit/embUnit/TestRunner.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestRunner.h,v 1.6 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTRUNNER_H__
|
||||
#define __TESTRUNNER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void TestRunner_start(void);
|
||||
void TestRunner_runTest(Test* test);
|
||||
void TestRunner_end(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif/*__TESTRUNNER_H__*/
|
73
tests/unittests/embunit/embUnit/TestSuite.c
Normal file
73
tests/unittests/embunit/embUnit/TestSuite.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestSuite.c,v 1.5 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "TestSuite.h"
|
||||
|
||||
char* TestSuite_name(TestSuite* self)
|
||||
{
|
||||
return self->name;
|
||||
}
|
||||
|
||||
void TestSuite_run(TestSuite* self,TestResult* result)
|
||||
{
|
||||
int i;
|
||||
Test* test;
|
||||
if (self->tests) {
|
||||
for (i=0; i<self->numberOfTests; i++) {
|
||||
test = self->tests[i];
|
||||
Test_run(test, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TestSuite_countTestCases(TestSuite* self)
|
||||
{
|
||||
int count = 0;
|
||||
int i;
|
||||
Test* test;
|
||||
if (self->tests) {
|
||||
for (i=0; i<self->numberOfTests; i++) {
|
||||
test = self->tests[i];
|
||||
count += Test_countTestCases(test);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
const TestImplement TestSuiteImplement = {
|
||||
(TestNameFunction) TestSuite_name,
|
||||
(TestRunFunction) TestSuite_run,
|
||||
(TestCountTestCasesFunction)TestSuite_countTestCases,
|
||||
};
|
58
tests/unittests/embunit/embUnit/TestSuite.h
Normal file
58
tests/unittests/embunit/embUnit/TestSuite.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: TestSuite.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TESTSUITE_H__
|
||||
#define __TESTSUITE_H__
|
||||
|
||||
typedef struct __TestSuite TestSuite;
|
||||
typedef struct __TestSuite* TestSuiteRef;/*downward compatible*/
|
||||
|
||||
struct __TestSuite {
|
||||
TestImplement* isa;
|
||||
char *name;
|
||||
int numberOfTests;
|
||||
Test** tests;
|
||||
};
|
||||
|
||||
extern const TestImplement TestSuiteImplement;
|
||||
|
||||
#define new_TestSuite(name,tests,numberOfTests)\
|
||||
{\
|
||||
(TestImplement*)&TestSuiteImplement,\
|
||||
name,\
|
||||
numberOfTests,\
|
||||
tests,\
|
||||
}
|
||||
|
||||
#endif/*__TESTSUITE_H__*/
|
48
tests/unittests/embunit/embUnit/config.h
Normal file
48
tests/unittests/embunit/embUnit/config.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: config.h,v 1.7 2004/02/10 16:17:07 arms22 Exp $
|
||||
*/
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
/* #define NO_STDIO_PRINTF*/
|
||||
#ifdef NO_STDIO_PRINTF
|
||||
extern void stdimpl_print(const char *string);
|
||||
#else
|
||||
#include<stdio.h>
|
||||
#define stdimpl_print(s) printf("%s", s);
|
||||
#endif
|
||||
|
||||
#define ASSERT_STRING_BUFFER_MAX 64
|
||||
|
||||
#endif/*__CONFIG_H__*/
|
50
tests/unittests/embunit/embUnit/embUnit.h
Normal file
50
tests/unittests/embunit/embUnit/embUnit.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: embUnit.h,v 1.4 2004/02/10 16:16:19 arms22 Exp $
|
||||
*/
|
||||
#ifndef __EMBUNIT_H__
|
||||
#define __EMBUNIT_H__
|
||||
|
||||
#include <embUnit/Test.h>
|
||||
#include <embUnit/TestCase.h>
|
||||
#include <embUnit/TestListener.h>
|
||||
#include <embUnit/TestResult.h>
|
||||
#include <embUnit/TestSuite.h>
|
||||
#include <embUnit/TestRunner.h>
|
||||
#include <embUnit/TestCaller.h>
|
||||
#include <embUnit/RepeatedTest.h>
|
||||
#include <embUnit/stdImpl.h>
|
||||
#include <embUnit/AssertImpl.h>
|
||||
#include <embUnit/HelperMacro.h>
|
||||
|
||||
#endif/*__EMBUNIT_H__*/
|
141
tests/unittests/embunit/embUnit/stdImpl.c
Normal file
141
tests/unittests/embunit/embUnit/stdImpl.c
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: stdImpl.c,v 1.3 2004/02/10 16:15:25 arms22 Exp $
|
||||
*/
|
||||
#include "stdImpl.h"
|
||||
|
||||
char* stdimpl_strcpy(char *dst, const char *src)
|
||||
{
|
||||
char *start = dst;
|
||||
char c;
|
||||
do {
|
||||
c = *src;
|
||||
*dst = c;
|
||||
src++;
|
||||
dst++;
|
||||
} while (c);
|
||||
return start;
|
||||
}
|
||||
|
||||
char* stdimpl_strcat(char *dst, const char *src)
|
||||
{
|
||||
char *start = dst;
|
||||
char c;
|
||||
do {
|
||||
c = *dst;
|
||||
dst++;
|
||||
} while (c);
|
||||
dst--;
|
||||
do {
|
||||
c = *src;
|
||||
*dst = c;
|
||||
src++;
|
||||
dst++;
|
||||
} while (c);
|
||||
return start;
|
||||
}
|
||||
|
||||
char* stdimpl_strncat(char *dst, const char *src,unsigned int count)
|
||||
{
|
||||
char *start = dst;
|
||||
char c;
|
||||
do {
|
||||
c = *dst;
|
||||
dst++;
|
||||
} while (c);
|
||||
dst--;
|
||||
if (count) {
|
||||
do {
|
||||
c = *src;
|
||||
*dst = c;
|
||||
src++;
|
||||
dst++;
|
||||
count--;
|
||||
} while (c && count);
|
||||
*dst = '\0';
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
int stdimpl_strlen(const char *str)
|
||||
{
|
||||
const char *estr = str;
|
||||
char c;
|
||||
do {
|
||||
c = *estr;
|
||||
estr++;
|
||||
} while (c);
|
||||
return ((int)(estr - str - 1));
|
||||
}
|
||||
|
||||
int stdimpl_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
char c1,c2;
|
||||
do {
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
} while ((c1) && (c2) && (c1==c2));
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
static char* _xtoa(unsigned long v,char *string, int r, int is_neg)
|
||||
{
|
||||
char *start = string;
|
||||
char buf[33],*p;
|
||||
|
||||
p = buf;
|
||||
|
||||
do {
|
||||
*p++ = "0123456789abcdef"[(v % r) & 0xf];
|
||||
} while (v /= r);
|
||||
|
||||
if (is_neg) {
|
||||
*p++ = '-';
|
||||
}
|
||||
|
||||
do {
|
||||
*string++ = *--p;
|
||||
} while (buf != p);
|
||||
|
||||
*string = '\0';
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
char* stdimpl_itoa(int v,char *string,int r)
|
||||
{
|
||||
if ((r == 10) && (v < 0)) {
|
||||
return _xtoa((unsigned long)(-v), string, r, 1);
|
||||
}
|
||||
return _xtoa((unsigned long)(v), string, r, 0);
|
||||
}
|
57
tests/unittests/embunit/embUnit/stdImpl.h
Normal file
57
tests/unittests/embunit/embUnit/stdImpl.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (c) 2003 Embedded Unit Project
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies
|
||||
* of the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written
|
||||
* authorization of the copyright holder.
|
||||
*
|
||||
* $Id: stdImpl.h,v 1.4 2004/02/10 16:15:25 arms22 Exp $
|
||||
*/
|
||||
#ifndef __STDIMPL_H__
|
||||
#define __STDIMPL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
char* stdimpl_strcpy(char *s1, const char *s2);
|
||||
char* stdimpl_strcat(char *dst, const char *src);
|
||||
char* stdimpl_strncat(char *dst, const char *src,unsigned int count);
|
||||
int stdimpl_strlen(const char *str);
|
||||
int stdimpl_strcmp(const char *s1, const char *s2);
|
||||
char* stdimpl_itoa(int v,char *string,int r);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif/*__STDIMPL_H__*/
|
87
tests/unittests/embunit/readme_en.txt
Normal file
87
tests/unittests/embunit/readme_en.txt
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
|
||||
== Embedded Unit ==
|
||||
https://sourceforge.net/projects/embunit/
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Embedded Unit is unit testing framework for Embedded C System. It's design was
|
||||
copied from JUnit and CUnit and more, and then adapted somewhat for Embedded C
|
||||
System. Embedded Unit does not require std C libs. All objects are allocated
|
||||
to const area.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
1.Release Contetns
|
||||
[embUnit]
|
||||
+- COPYING : Copyright Notice
|
||||
+- makefile :
|
||||
+- readme.txt : japanese
|
||||
+- readme_en.txt : this file
|
||||
+- [embUnit] : Embedded Unit Source
|
||||
+- [msvc] : MSVC++6.0 Project
|
||||
+- [samples] : Embedded Unit Samples
|
||||
+- [tests] : Embedded Unit Self Tests
|
||||
+- [tools] : test template generation tools
|
||||
|
||||
|
||||
2.Development environment and Execution environment
|
||||
|
||||
2.1.Required execution environment
|
||||
- The ROM more than 2KB
|
||||
- The Stack more than 128b
|
||||
|
||||
2.2.Required development environment
|
||||
- C Compiler
|
||||
|
||||
2.3.Development of Embedded Unit is performed in the following environment
|
||||
- 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.Compile
|
||||
Embedded Unit is using stdio print function for the output of a test
|
||||
result message. Implement the following function, if you do not want
|
||||
to use stdio print function.
|
||||
|
||||
void stdimpl_print(const char *string)
|
||||
* this function does not output a new-line in the end of a string.
|
||||
|
||||
And then add compile-option '-DNO_STDIO_PRINTF', or release the following
|
||||
comments of a embUnit/config.h.
|
||||
|
||||
/*#define NO_STDIO_PRINTF*/
|
||||
|
||||
3.1.GNU building tools
|
||||
- edit embUnit/config.h if needed and execute the following commands.
|
||||
|
||||
$ make
|
||||
|
||||
- running self tests
|
||||
|
||||
$ make test
|
||||
|
||||
- running samples
|
||||
|
||||
$ make samples
|
||||
|
||||
3.2.MSVC++6.0
|
||||
- open msvc/embUnit.dsw and build each project.
|
||||
|
||||
3.3.MacOSX
|
||||
- edit embUnit/config.h if needed and execute the following commands.
|
||||
|
||||
$ make CC=cc
|
||||
|
||||
|
||||
4.License
|
||||
|
||||
MIT/X Consortium License
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
$Id: readme_en.txt,v 1.6 2003/09/16 11:08:45 arms22 Exp $
|
92
tests/unittests/embunit/textui/CompilerOutputter.c
Normal file
92
tests/unittests/embunit/textui/CompilerOutputter.c
Normal file
@ -0,0 +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)
|
||||
{
|
||||
(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;
|
||||
}
|
42
tests/unittests/embunit/textui/CompilerOutputter.h
Normal file
42
tests/unittests/embunit/textui/CompilerOutputter.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
|
||||
*/
|
||||
#ifndef __COMPILEROUTPUTTER_H__
|
||||
#define __COMPILEROUTPUTTER_H__
|
||||
|
||||
#include "Outputter.h"
|
||||
|
||||
OutputterRef CompilerOutputter_outputter(void);
|
||||
|
||||
#endif/*__COMPILEROUTPUTTER_H__*/
|
5
tests/unittests/embunit/textui/Makefile
Normal file
5
tests/unittests/embunit/textui/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
MODULE = embunit_textui
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
74
tests/unittests/embunit/textui/Outputter.h
Normal file
74
tests/unittests/embunit/textui/Outputter.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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: Outputter.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
|
||||
*/
|
||||
#ifndef __OUTPUTTER_H__
|
||||
#define __OUTPUTTER_H__
|
||||
|
||||
#include <embUnit/embUnit.h>
|
||||
|
||||
typedef struct __OutputterImplement OutputterImplement;
|
||||
typedef struct __OutputterImplement* OutputterImplementRef;
|
||||
|
||||
typedef void(*OutputterPrintHeaderFunction)(void*);
|
||||
typedef void(*OutputterPrintStartTestFunction)(void*,TestRef);
|
||||
typedef void(*OutputterPrintEndTestFunction)(void*,TestRef);
|
||||
typedef void(*OutputterPrintSuccessfulFunction)(void*,TestRef,int);
|
||||
typedef void(*OutputterPrintFailureFunction)(void*,TestRef,char*,int,char*,int);
|
||||
typedef void(*OutputterPrintStatisticsFunction)(void*,TestResultRef);
|
||||
|
||||
|
||||
struct __OutputterImplement {
|
||||
OutputterPrintHeaderFunction printHeader;
|
||||
OutputterPrintStartTestFunction printStartTest;
|
||||
OutputterPrintEndTestFunction printEndTest;
|
||||
OutputterPrintSuccessfulFunction printSuccessful;
|
||||
OutputterPrintFailureFunction printFailure;
|
||||
OutputterPrintStatisticsFunction printStatistics;
|
||||
};
|
||||
|
||||
typedef struct __Outputter Outputter;
|
||||
typedef struct __Outputter* OutputterRef;
|
||||
|
||||
struct __Outputter {
|
||||
OutputterImplementRef isa;
|
||||
};
|
||||
|
||||
#define Outputter_printHeader(o) (o)->isa->printHeader(o)
|
||||
#define Outputter_printStartTest(o,t) (o)->isa->printStartTest(o,t)
|
||||
#define Outputter_printEndTest(o,t) (o)->isa->printEndTest(o,t)
|
||||
#define Outputter_printSuccessful(o,t,c) (o)->isa->printSuccessful(o,t,c)
|
||||
#define Outputter_printFailure(o,t,m,l,f,c) (o)->isa->printFailure(o,t,m,l,f,c)
|
||||
#define Outputter_printStatistics(o,r) (o)->isa->printStatistics(o,r)
|
||||
|
||||
#endif/*__OUTPUTTER_H__*/
|
93
tests/unittests/embunit/textui/TextOutputter.c
Normal file
93
tests/unittests/embunit/textui/TextOutputter.c
Normal file
@ -0,0 +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)
|
||||
{
|
||||
(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;
|
||||
}
|
42
tests/unittests/embunit/textui/TextOutputter.h
Normal file
42
tests/unittests/embunit/textui/TextOutputter.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.h,v 1.2 2003/09/06 13:28:27 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TEXTOUTPUTTER_H__
|
||||
#define __TEXTOUTPUTTER_H__
|
||||
|
||||
#include "Outputter.h"
|
||||
|
||||
OutputterRef TextOutputter_outputter(void);
|
||||
|
||||
#endif/*__TEXTOUTPUTTER_H__*/
|
107
tests/unittests/embunit/textui/TextUIRunner.c
Normal file
107
tests/unittests/embunit/textui/TextUIRunner.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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: TextUIRunner.c,v 1.4 2004/02/10 16:20:43 arms22 Exp $
|
||||
*/
|
||||
#include "TextOutputter.h"
|
||||
#include "TextUIRunner.h"
|
||||
|
||||
/* Private
|
||||
*/
|
||||
static TestResult result_;
|
||||
static OutputterRef outputterRef_ = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
static const TestListnerImplement TextUIRunnerImplement = {
|
||||
(TestListnerStartTestCallBack) TextUIRunner_startTest,
|
||||
(TestListnerEndTestCallBack) TextUIRunner_endTest,
|
||||
(TestListnerAddFailureCallBack) TextUIRunner_addFailure,
|
||||
};
|
||||
|
||||
static const TestListner testuirunner_ = {
|
||||
(TestListnerImplement*)&TextUIRunnerImplement,
|
||||
};
|
||||
|
||||
/* Public
|
||||
*/
|
||||
void TextUIRunner_setOutputter(OutputterRef outputter)
|
||||
{
|
||||
outputterRef_ = outputter;
|
||||
}
|
||||
|
||||
void TextUIRunner_startWithOutputter(OutputterRef outputter)
|
||||
{
|
||||
TestResult_init(&result_, (TestListnerRef)&testuirunner_);
|
||||
TextUIRunner_setOutputter(outputter);
|
||||
Outputter_printHeader(outputter);
|
||||
|
||||
}
|
||||
|
||||
void TextUIRunner_start(void)
|
||||
{
|
||||
if (!outputterRef_)
|
||||
outputterRef_ = TextOutputter_outputter();
|
||||
TextUIRunner_startWithOutputter(outputterRef_);
|
||||
}
|
||||
|
||||
void TextUIRunner_runTest(TestRef test)
|
||||
{
|
||||
Outputter_printStartTest(outputterRef_,test);
|
||||
Test_run(test, &result_);
|
||||
Outputter_printEndTest(outputterRef_,test);
|
||||
}
|
||||
|
||||
void TextUIRunner_end(void)
|
||||
{
|
||||
Outputter_printStatistics(outputterRef_,&result_);
|
||||
}
|
46
tests/unittests/embunit/textui/TextUIRunner.h
Normal file
46
tests/unittests/embunit/textui/TextUIRunner.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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: TextUIRunner.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $
|
||||
*/
|
||||
#ifndef __TEXTUIRUNNER_H__
|
||||
#define __TEXTUIRUNNER_H__
|
||||
|
||||
#include <embUnit/embUnit.h>
|
||||
|
||||
void TextUIRunner_setOutputter(OutputterRef outputter);
|
||||
void TextUIRunner_startWithOutputter(OutputterRef outputter);
|
||||
void TextUIRunner_start(void);
|
||||
void TextUIRunner_runTest(TestRef test);
|
||||
void TextUIRunner_end(void);
|
||||
|
||||
#endif/*__TEXTUIRUNNER_H__*/
|
115
tests/unittests/embunit/textui/XMLOutputter.c
Normal file
115
tests/unittests/embunit/textui/XMLOutputter.c
Normal file
@ -0,0 +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)
|
||||
{
|
||||
(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;
|
||||
}
|
43
tests/unittests/embunit/textui/XMLOutputter.h
Normal file
43
tests/unittests/embunit/textui/XMLOutputter.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.h,v 1.3 2003/09/06 13:28:27 arms22 Exp $
|
||||
*/
|
||||
#ifndef __XMLOUTPUTTER_H__
|
||||
#define __XMLOUTPUTTER_H__
|
||||
|
||||
#include "Outputter.h"
|
||||
|
||||
void XMLOutputter_setStyleSheet(char *style);
|
||||
OutputterRef XMLOutputter_outputter(void);
|
||||
|
||||
#endif/*__XMLOUTPUTTER_H__*/
|
64
tests/unittests/main.c
Normal file
64
tests/unittests/main.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Martin Lenders
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
#include "embUnit/embUnit.h"
|
||||
|
||||
#include "lpm.h"
|
||||
|
||||
#ifdef OUTPUT
|
||||
#define OUTPUT_XML (1)
|
||||
#define OUTPUT_TEXT (2)
|
||||
#define OUTPUT_COMPILER (4)
|
||||
|
||||
#if (OUTPUT==OUTPUT_XML)
|
||||
#include "textui/XMLOutputter.h"
|
||||
|
||||
#define OUTPUTTER (XMLOutputter_outputter())
|
||||
#endif
|
||||
|
||||
#if (OUTPUT==OUTPUT_TEXT)
|
||||
#include "textui/TextOutputter.h"
|
||||
|
||||
#define OUTPUTTER (TextOutputter_outputter())
|
||||
#endif
|
||||
|
||||
#if (OUTPUT==OUTPUT_COMPILER)
|
||||
#include "textui/CompilerOutputter.h"
|
||||
|
||||
#define OUTPUTTER (CompilerOutputter_outputter())
|
||||
#endif
|
||||
|
||||
#include "textui/TextUIRunner.h"
|
||||
|
||||
#define TESTS_START() TextUIRunner_start()
|
||||
#define TESTS_RUN(t) TextUIRunner_runTest(t)
|
||||
#define TESTS_END() TextUIRunner_end()
|
||||
|
||||
#else
|
||||
|
||||
#define TESTS_START() TestRunner_start()
|
||||
#define TESTS_RUN(t) TestRunner_runTest(t)
|
||||
#define TESTS_END() TestRunner_end()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#ifdef OUTPUT
|
||||
TextUIRunner_setOutputter(OUTPUTTER);
|
||||
#endif
|
||||
|
||||
TESTS_START();
|
||||
/* put test TEST_RUN() calls here */
|
||||
TESTS_END();
|
||||
|
||||
lpm_set(LPM_POWERDOWN);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user