Last change
on this file since 36 was
15,
checked in by rosiere, 17 years ago
|
Interface normalisé
Début du banc de registres multi niveaux
|
File size:
1016 bytes
|
Rev | Line | |
---|
[2] | 1 | #ifndef TEST_H |
---|
| 2 | #define TEST_H |
---|
| 3 | |
---|
| 4 | #include <iostream> |
---|
| 5 | #include <sstream> |
---|
| 6 | #include <stdint.h> |
---|
[3] | 7 | #include "Include/ErrorMorpheo.h" |
---|
[2] | 8 | using namespace std; |
---|
| 9 | |
---|
| 10 | //-----[ Routine de test ]--------------------------------------- |
---|
| 11 | |
---|
| 12 | static uint32_t num_test; |
---|
| 13 | |
---|
| 14 | template <class T> |
---|
| 15 | void test_ko (T exp1, T exp2, char * file, uint32_t line) |
---|
| 16 | { |
---|
[15] | 17 | string msg = ("<"+toString(num_test)+"> : Test KO\n" + |
---|
[3] | 18 | " * Localisation\n" + |
---|
| 19 | " - File : "+file+"\n" + |
---|
| 20 | " - Line : "+toString(line)+"\n" + |
---|
| 21 | " * Expression is different\n" + |
---|
| 22 | " - exp1 : "+toString(exp1)+"\n" + |
---|
| 23 | " - exp2 : "+toString(exp2)+"\n"); |
---|
| 24 | |
---|
| 25 | throw (ErrorMorpheo (msg)); |
---|
[2] | 26 | }; |
---|
| 27 | |
---|
| 28 | void test_ok () |
---|
| 29 | { |
---|
| 30 | cout << "{" << num_test << "} : Test OK" << endl; |
---|
| 31 | |
---|
| 32 | num_test ++; |
---|
| 33 | }; |
---|
| 34 | |
---|
| 35 | template <class T> |
---|
| 36 | void test(T exp1, T exp2, char * file, uint32_t line) |
---|
| 37 | { |
---|
| 38 | if (exp1 != exp2) |
---|
| 39 | test_ko <T> (exp1,exp2,file,line); |
---|
| 40 | else |
---|
| 41 | test_ok (); |
---|
| 42 | }; |
---|
| 43 | |
---|
| 44 | #define TEST(type,exp1,exp2) do { test<type> (exp1,exp2,__FILE__,__LINE__);} while(0) |
---|
| 45 | |
---|
| 46 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.