1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-03 10:07:02 +00:00
cc65/test/val/unittest.h

90 lines
4.6 KiB
C
Raw Normal View History

/*****************************************************************************/
/* */
/* unittest.h */
/* */
/* Unit test helper macros */
/* */
/* */
/* */
2017-02-26 21:36:19 +00:00
/* (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 <stdio.h>
#include <stdlib.h>
#ifndef COMMA
#define COMMA ,
#endif
2017-02-26 21:36:19 +00:00
#define TEST int main(void) \
{\
printf("%s: ",__FILE__);
2017-02-26 21:36:19 +00:00
#define ENDTEST printf("Passed\n"); \
return EXIT_SUCCESS; \
}
2017-02-26 21:36:19 +00:00
#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);\
}
2017-02-26 21:36:19 +00:00
#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);\
}
2017-02-26 21:36:19 +00:00
#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);\
}
2017-02-26 21:36:19 +00:00
#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