Changeset 53 for trunk/IPs/systemC/processor/Morpheo/Common
- Timestamp:
- Sep 6, 2007, 6:30:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Common/include/Test.h
r50 r53 12 12 static uint32_t num_test; 13 13 14 void test_ko_error (void) 15 { 16 string msg = "Test ko : error in test \""+toString(num_test)+"\""; 17 throw (ErrorMorpheo (msg)); 18 } 19 14 20 template <class T> 15 void test_ko ( T exp1, T exp2, char * file, uint32_t line)21 void test_ko (char * file, uint32_t line, T exp1, T exp2) 16 22 { 17 string msg = ("<"+toString(num_test)+"> : Test KO\n" + 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)); 23 cerr << "[" << num_test << "] : Test KO" 24 << "\tline " << line << endl 25 << " * Localisation" << endl 26 << " - File : " << file << endl 27 << " - Line : " << line << endl 28 << " * Expression is different" << endl 29 << " - exp1 : "+toString(exp1) << endl 30 << " - exp2 : "+toString(exp2) << endl; 31 32 test_ko_error (); 26 33 }; 27 34 28 35 void test_ko (char * file, uint32_t line) 29 36 { 30 string msg = ("<"+toString(num_test)+"> : Test KO\n" + 31 " * Localisation\n" + 32 " - File : "+file+"\n" + 33 " - Line : "+toString(line)+"\n"); 37 cerr << "[" << num_test << "] : Test KO" 38 << "\tline " << line << endl 39 << " * Localisation" << endl 40 << " - File : " << file << endl 41 << " - Line : " << line << endl; 34 42 35 t hrow (ErrorMorpheo (msg));43 test_ko_error (); 36 44 }; 37 45 38 46 void test_ok () 39 47 { 40 cout << "{" << num_test << "} : Test OK" << endl; 48 cout << "[" << num_test << "] : Test OK" << endl; 49 50 num_test ++; 51 }; 52 53 void test_ok (char * file, uint32_t line) 54 { 55 cout << "[" << num_test << "] : Test OK" 56 << "\tline " << line << endl 57 // << " * Localisation" << endl 58 // << " - File : " << file << endl 59 // << " - Line : " << line << endl 60 ; 41 61 42 62 num_test ++; … … 44 64 45 65 template <class T> 46 void test(T exp1, T exp2, char * file, uint32_t line) 66 void test_ok (char * file, uint32_t line, T exp) 67 { 68 cout << "[" << num_test << "] : Test OK" 69 << "\tline " << line 70 << "\tvalue : " << toString(exp) << endl 71 // << " * Localisation" << endl 72 // << " - File : " << file << endl 73 // << " - Line : " << line << endl 74 // << " * Expression" << endl 75 // << " - exp : "+toString(exp) << endl 76 ; 77 78 num_test ++; 79 } 80 81 template <class T> 82 void test(char * file, uint32_t line, T exp1, T exp2) 47 83 { 48 84 if (exp1 != exp2) 49 test_ko <T> ( exp1,exp2,file,line);85 test_ko <T> (file,line,exp1,exp2); 50 86 else 51 test_ok ();87 test_ok <T> (file,line,exp1); 52 88 }; 53 89 54 #define TEST(type,exp1,exp2) do {test<type> ( exp1,exp2,__FILE__,__LINE__);} while(0)55 #define TEST_STR(type,exp1,exp2,str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test<type> ( exp1,exp2,__FILE__,__LINE__);} while(0)56 #define TEST_OK(str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test_ok( );} while(0)90 #define TEST(type,exp1,exp2) do {test<type> (__FILE__,__LINE__,exp1,exp2);} while(0) 91 #define TEST_STR(type,exp1,exp2,str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test<type> (__FILE__,__LINE__,exp1,exp2);} while(0) 92 #define TEST_OK(str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test_ok(__FILE__,__LINE__);} while(0) 57 93 #define TEST_KO(str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test_ko(__FILE__,__LINE__);} while(0) 58 94
Note: See TracChangeset
for help on using the changeset viewer.