1 /* unit.h unit tests driver */
6 #include <cyassl/test.h> /* thread and tcp stuff */
8 #define Fail(description, result) do { \
9 printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
10 printf("\n\n test: "); printf description; \
11 printf("\n\n result: "); printf result; \
15 #define Assert(test, description, result) if (!(test)) Fail(description, result)
17 #define AssertTrue(x) Assert( (x), ("%s is true", #x), (#x " => FALSE"))
18 #define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE"))
19 #define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
21 #define AssertNull(x) do { \
22 void* _x = (void *) (x); \
24 Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
27 #define AssertInt(x, y, op, er) do { \
31 Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \
34 #define AssertIntEQ(x, y) AssertInt(x, y, ==, !=)
35 #define AssertIntNE(x, y) AssertInt(x, y, !=, ==)
36 #define AssertIntGT(x, y) AssertInt(x, y, >, <=)
37 #define AssertIntLT(x, y) AssertInt(x, y, <, >=)
38 #define AssertIntGE(x, y) AssertInt(x, y, >=, <)
39 #define AssertIntLE(x, y) AssertInt(x, y, <=, >)
41 #define AssertStr(x, y, op, er) do { \
44 int _z = strcmp(_x, _y); \
46 Assert(_z op 0, ("%s " #op " %s", #x, #y), \
47 ("\"%s\" " #er " \"%s\"", _x, _y));\
50 #define AssertStrEQ(x, y) AssertStr(x, y, ==, !=)
51 #define AssertStrNE(x, y) AssertStr(x, y, !=, ==)
52 #define AssertStrGT(x, y) AssertStr(x, y, >, <=)
53 #define AssertStrLT(x, y) AssertStr(x, y, <, >=)
54 #define AssertStrGE(x, y) AssertStr(x, y, >=, <)
55 #define AssertStrLE(x, y) AssertStr(x, y, <=, >)
63 #endif /* CyaSSL_UNIT_H */