1 /*****************************************************************************/
5 /* Unit test helper macros */
9 /* (C) 2017 Christian Krueger */
11 /* This software is provided 'as-is', without any expressed or implied */
12 /* warranty. In no event will the authors be held liable for any damages */
13 /* arising from the use of this software. */
15 /* Permission is granted to anyone to use this software for any purpose, */
16 /* including commercial applications, and to alter it and redistribute it */
17 /* freely, subject to the following restrictions: */
19 /* 1. The origin of this software must not be misrepresented; you must not */
20 /* claim that you wrote the original software. If you use this software */
21 /* in a product, an acknowledgment in the product documentation would be */
22 /* appreciated but is not required. */
23 /* 2. Altered source versions must be plainly marked as such, and must not */
24 /* be misrepresented as being the original software. */
25 /* 3. This notice may not be removed or altered from any source */
28 /*****************************************************************************/
40 #define TEST int main(void) \
42 printf("%s: ",__FILE__);
44 #define ENDTEST printf("Passed\n"); \
45 return EXIT_SUCCESS; \
48 #define ASSERT_IsTrue(a,b) if (!(a)) \
50 printf("Fail at line %d:\n",__LINE__);\
53 printf("Expected status should be true but wasn't!\n");\
57 #define ASSERT_IsFalse(a,b) if ((a)) \
59 printf("Fail at line %d:\n",__LINE__);\
62 printf("Expected status should be false but wasn't!\n");\
66 #define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \
68 printf("Fail at line %d:\n",__LINE__);\
71 printf("Expected value: "c", but is "c"!\n", (a), (b));\
75 #define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \
77 printf("Fail at line %d:\n",__LINE__);\
80 printf("Expected value not: "c", but is "c"!\n", (a), (b));\
84 /* End of unittest.h */