Rev | Line | |
---|
[2] | 1 | #ifndef TEST_H |
---|
| 2 | #define TEST_H |
---|
| 3 | |
---|
| 4 | #include <iostream> |
---|
| 5 | #include <sstream> |
---|
| 6 | #include <stdint.h> |
---|
| 7 | using namespace std; |
---|
| 8 | |
---|
| 9 | //-----[ Routine de test ]--------------------------------------- |
---|
| 10 | |
---|
| 11 | static uint32_t num_test; |
---|
| 12 | |
---|
| 13 | template <class T> |
---|
| 14 | void test_ko (T exp1, T exp2, char * file, uint32_t line) |
---|
| 15 | { |
---|
| 16 | cout << "{" << num_test << "} : Test KO" << endl |
---|
| 17 | << " * Localisation" << endl |
---|
| 18 | << " - File : " << file << endl |
---|
| 19 | << " - Line : " << line << endl |
---|
| 20 | << " * Expression is different " << endl |
---|
| 21 | << " - exp1 : " << exp1 << endl |
---|
| 22 | << " - exp2 : " << exp2 << endl; |
---|
| 23 | |
---|
| 24 | exit (line); |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | void test_ok () |
---|
| 28 | { |
---|
| 29 | cout << "{" << num_test << "} : Test OK" << endl; |
---|
| 30 | |
---|
| 31 | num_test ++; |
---|
| 32 | }; |
---|
| 33 | |
---|
| 34 | template <class T> |
---|
| 35 | void test(T exp1, T exp2, char * file, uint32_t line) |
---|
| 36 | { |
---|
| 37 | if (exp1 != exp2) |
---|
| 38 | test_ko <T> (exp1,exp2,file,line); |
---|
| 39 | else |
---|
| 40 | test_ok (); |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | #define TEST(type,exp1,exp2) do { test<type> (exp1,exp2,__FILE__,__LINE__);} while(0) |
---|
| 44 | |
---|
| 45 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.