aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests.h')
-rw-r--r--tests/tests.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/tests.h b/tests/tests.h
index 6bd8e4d..72e7801 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -5,14 +5,15 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
extern unsigned stack_depth;
#define delta(a, b) (((a) >= (b)) ? (a) - (b) : (b) - (a))
#define COMMENT(x) printf("\n----" x "----\n");
-#define STR(x) #x
-#define STR2(x) STR(x)
+#define STR(x) #x
+#define STR2(x) STR(x)
#define TEST(x) \
do \
{ \
@@ -71,6 +72,34 @@ extern unsigned stack_depth;
} \
} while (0)
+#define ASSERT_EQ_STR(a, b) \
+ do \
+ { \
+ size_t la = strlen(a); \
+ size_t lb = strlen(b); \
+ if (la != lb) \
+ { \
+ fflush(stdout); \
+ fflush(stderr); \
+ fprintf(stderr, \
+ "\033[31;1m FAILED:\033[22;39m%*sASSERT_EQ a: %s, b: " \
+ "%s\033[0m at: %s(), " __FILE__ ":" STR2(__LINE__) "\n", \
+ stack_depth, "", (a), (b), __func__); \
+ return 1; \
+ } \
+ int res = strncmp((a), (b), la); \
+ if (res != 0) \
+ { \
+ fflush(stdout); \
+ fflush(stderr); \
+ fprintf(stderr, \
+ "\033[31;1m FAILED:\033[22;39m%*sASSERT_EQ a: %s, b: " \
+ "%s\033[0m at: %s(), " __FILE__ ":" STR2(__LINE__) "\n", \
+ stack_depth, "", (a), (b), __func__); \
+ return 1; \
+ } \
+ } while (0)
+
extern const fix16_t testcases[102];
#define TESTCASES_COUNT (sizeof(testcases) / sizeof(testcases[0]))