From: IrgendwerA8 Date: Tue, 28 Feb 2017 07:05:11 +0000 (+0100) Subject: Changed the location of unittest.h X-Git-Tag: V2.16~8^2~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=09de875330a4ca5eeabf91a21e774758c1de4417;p=cc65 Changed the location of unittest.h --- diff --git a/include/unittest.h b/include/unittest.h deleted file mode 100644 index bd355bb0c..000000000 --- a/include/unittest.h +++ /dev/null @@ -1,89 +0,0 @@ -/*****************************************************************************/ -/* */ -/* unittest.h */ -/* */ -/* Unit test helper macros */ -/* */ -/* */ -/* */ -/* (C) 2017 Christian Krueger */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - -#ifndef _UNITTEST_H -#define _UNITTEST_H - -#include -#include - -#ifndef COMMA -#define COMMA , -#endif - -#define TEST int main(void) \ - {\ - printf("%s: ",__FILE__); - -#define ENDTEST printf("Passed\n"); \ - return EXIT_SUCCESS; \ - } - -#define ASSERT_IsTrue(a,b) if (!(a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be true but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } - -#define ASSERT_IsFalse(a,b) if ((a)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(b);\ - printf("\n");\ - printf("Expected status should be false but wasn't!\n");\ - exit(EXIT_FAILURE);\ - } - -#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } - -#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ - {\ - printf("Fail at line %d:\n",__LINE__);\ - printf(d);\ - printf("\n");\ - printf("Expected value not: "c", but is "c"!\n", (a), (b));\ - exit(EXIT_FAILURE);\ - } - -/* End of unittest.h */ -#endif - - - - diff --git a/testcode/lib/strcat-test.c b/testcode/lib/strcat-test.c index 2e00b80cb..58119e27a 100644 --- a/testcode/lib/strcat-test.c +++ b/testcode/lib/strcat-test.c @@ -1,5 +1,5 @@ -#include #include +#include "unittest.h" #define SourceStringSize 257 // test correct page passing (>256) diff --git a/testcode/lib/strrchr-test.c b/testcode/lib/strrchr-test.c index d2c2a20e4..a72c44db9 100644 --- a/testcode/lib/strrchr-test.c +++ b/testcode/lib/strrchr-test.c @@ -1,5 +1,5 @@ -#include #include +#include "unittest.h" static char TestString[] = "01234567890123456789"; // two times the same string static char Found[256]; diff --git a/testcode/lib/unittest.h b/testcode/lib/unittest.h new file mode 100644 index 000000000..bd355bb0c --- /dev/null +++ b/testcode/lib/unittest.h @@ -0,0 +1,89 @@ +/*****************************************************************************/ +/* */ +/* unittest.h */ +/* */ +/* Unit test helper macros */ +/* */ +/* */ +/* */ +/* (C) 2017 Christian Krueger */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef _UNITTEST_H +#define _UNITTEST_H + +#include +#include + +#ifndef COMMA +#define COMMA , +#endif + +#define TEST int main(void) \ + {\ + printf("%s: ",__FILE__); + +#define ENDTEST printf("Passed\n"); \ + return EXIT_SUCCESS; \ + } + +#define ASSERT_IsTrue(a,b) if (!(a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be true but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_IsFalse(a,b) if ((a)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(b);\ + printf("\n");\ + printf("Expected status should be false but wasn't!\n");\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \ + {\ + printf("Fail at line %d:\n",__LINE__);\ + printf(d);\ + printf("\n");\ + printf("Expected value not: "c", but is "c"!\n", (a), (b));\ + exit(EXIT_FAILURE);\ + } + +/* End of unittest.h */ +#endif + + + +