1 /* unit.h unit tests driver */
6 #include <wolfssl/ssl.h>
7 #include <wolfssl/test.h> /* thread and tcp stuff */
9 #define Fail(description, result) do { \
10 printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
11 printf("\n\n test: "); printf description; \
12 printf("\n\n result: "); printf result; \
16 #define Assert(test, description, result) if (!(test)) Fail(description, result)
18 #define AssertTrue(x) Assert( (x), ("%s is true", #x), (#x " => FALSE"))
19 #define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE"))
20 #define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
22 #define AssertNull(x) do { \
23 void* _x = (void *) (x); \
25 Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
28 #define AssertInt(x, y, op, er) do { \
32 Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \
35 #define AssertIntEQ(x, y) AssertInt(x, y, ==, !=)
36 #define AssertIntNE(x, y) AssertInt(x, y, !=, ==)
37 #define AssertIntGT(x, y) AssertInt(x, y, >, <=)
38 #define AssertIntLT(x, y) AssertInt(x, y, <, >=)
39 #define AssertIntGE(x, y) AssertInt(x, y, >=, <)
40 #define AssertIntLE(x, y) AssertInt(x, y, <=, >)
42 #define AssertStr(x, y, op, er) do { \
45 int _z = strcmp(_x, _y); \
47 Assert(_z op 0, ("%s " #op " %s", #x, #y), \
48 ("\"%s\" " #er " \"%s\"", _x, _y));\
51 #define AssertStrEQ(x, y) AssertStr(x, y, ==, !=)
52 #define AssertStrNE(x, y) AssertStr(x, y, !=, ==)
53 #define AssertStrGT(x, y) AssertStr(x, y, >, <=)
54 #define AssertStrLT(x, y) AssertStr(x, y, <, >=)
55 #define AssertStrGE(x, y) AssertStr(x, y, >=, <)
56 #define AssertStrLE(x, y) AssertStr(x, y, <=, >)
64 #endif /* CyaSSL_UNIT_H */