]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/WolfSSL/tests/unit.h
Update WolfSSL library to the latest version.
[freertos] / FreeRTOS-Plus / Source / WolfSSL / tests / unit.h
1 /* unit.h unit tests driver */
2
3 #ifndef CyaSSL_UNIT_H
4 #define CyaSSL_UNIT_H
5
6 #include <wolfssl/ssl.h>
7 #include <wolfssl/test.h>    /* thread and tcp stuff */
8
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;                                 \
13     abort();                                                                   \
14 } while(0)
15
16 #define Assert(test, description, result) if (!(test)) Fail(description, result)
17
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"))
21
22 #define AssertNull(x) do {                                                     \
23     void* _x = (void *) (x);                                                   \
24                                                                                \
25     Assert(!_x, ("%s is null", #x), (#x " => %p", _x));                        \
26 } while(0)
27
28 #define AssertInt(x, y, op, er) do {                                           \
29     int _x = x;                                                                \
30     int _y = y;                                                                \
31                                                                                \
32     Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y));    \
33 } while(0)
34
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, <=,  >)
41
42 #define AssertStr(x, y, op, er) do {                                           \
43     const char* _x = x;                                                        \
44     const char* _y = y;                                                        \
45     int   _z = strcmp(_x, _y);                                                 \
46                                                                                \
47     Assert(_z op 0, ("%s " #op " %s", #x, #y),                                 \
48                                             ("\"%s\" " #er " \"%s\"", _x, _y));\
49 } while(0)
50
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, <=,  >)
57
58
59 void ApiTest(void);
60 int SuiteTest(void);
61 int HashTest(void);
62
63
64 #endif /* CyaSSL_UNIT_H */
65