source: trunk/IPs/systemC/processor/Morpheo/Include/Test.h @ 2

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

File size: 1012 bytes
Line 
1#ifndef TEST_H
2#define TEST_H
3
4#include <iostream>
5#include <sstream>
6#include <stdint.h>
7using namespace std;
8
9//-----[ Routine de test ]---------------------------------------
10
11static uint32_t num_test;
12
13template <class T>
14void 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
27void test_ok ()
28{
29  cout << "{" << num_test << "} : Test OK" << endl;
30
31  num_test ++;
32};
33
34template <class T>
35void 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.