(Event+Time).Variant Operators  2.3
Operators for Timed Discrete Event Systems in Dioids
TestIS.h
1 #ifndef __TEST_IS__
2 #define __TEST_IS__
3 
4 #include<algorithm>
5 #include<vector>
6 #include "../testException.h"
7 #include "../../etvo/common/etvoException.h"
8 
9 #include "../macros.h"
10 #include "../Test.h"
11 namespace test
12 {
13  /*************************************************************************************/
14  /*************************************************************************************/
15  template <class T>
16  class TestIS {
17  public:
18  static bool TestAll(const T & a,const T& b, const T & c)
19  {
20  bool success = true;
21  try {
23  test::TestIS<T>::Test2(c, a, b);
25  }
26  catch (const test::testException & e)
27  {
28  std::cout << "Error in TestIS!"<< std::endl;
29  std::cout << "Num :" << e.Num() << std::endl;
30  std::cout << "Exception :" << e.Message() << std::endl;
31  success = false;
32  }
33  catch (const etvo::etvoException & e2)
34  {
35  std::cout << "Error in TestIS!" << std::endl;
36  std::cout << "Num :" << e2.Num() << std::endl;
37  std::cout << "Exception :" << e2.Message()<< std::endl;
38  success = false;
39  }
40  catch (const std::exception & ex)
41  {
42  std::cout << "Error in TestIS!" << std::endl;
43  std::cout << "Exception :" << ex.what() << std::endl;
44  success = false;
45  }
46  return success;
47  }
48 
49  static void print(const T & a, const T& b)
50  {
51  PRINT(a);
52  PRINT(b);
53  }
54 
55  static void print(const T & a, const T& b,const T& c)
56  {
57  PRINT(a);
58  PRINT(b);
59  PRINT(c);
60  }
61 
62 
63  static void Test3(const T & a, const T& b)
64  {
65  T r1 = a.inf(b);
66  T r2 = b.inf(a);
67  if (!(r1==r2))
68  {
69  std::cout << "Error in TestIS::Test3" << std::endl;
70  PRINT(r1);
71  PRINT(r2);
72  PRINT(a);
73  PRINT(b);
74  throw test::testException(20, "a^b!=b^a");
75  }
76  }
77 
78  static void Test2(const T & a, const T& b, const T& c)
79  {
80  T tmp1 = b + c;
81  T r1 = a * tmp1;
82  T tmp2 = a * b;
83  T r2 = tmp2 + (a*c);
84  T r3 = (tmp1)*a;
85  T r4 = (b*a) + (c*a);
86  T r5 = (tmp2)*c;
87  T r6 = a * (b*c);
88 
89  if (!(r1 == r2))
90  {
91  std::cout << "Error in TestIS::Test2" << std::endl;
92  PRINT(r1);
93  PRINT(r2);
94  print(a, b, c);
95  throw test::testException(20, "a*(b+c)!=ab + ac");
96  }
97 
98  if (!(r3 == r4))
99  {
100  std::cout << "Error in TestIS::Test2" << std::endl;
101  PRINT(r3);
102  PRINT(r4);
103  print(r3, r4);
104  print(a, b, c);
105  throw test::testException(20, "(b+c)*a!=ba + ca");
106  }
107 
108  if (!(r5 == r6))
109  {
110  std::cout << "Error in TestIS::Test2" << std::endl;
111  PRINT(r5);
112  PRINT(r6);
113  print(a, b, c);
114  throw test::testException(20, "(a*b)*c!=a*(b*c)");
115  }
116  }
117 
118 
119  static void Test1(const T & a, const T& b)
120  {
121  T r1 = a + b;
122  T r2 = b + a;
123  if (!(r1 == r2))
124  {
125  std::cout << "Error in TestIS::Test1" << std::endl;
126  PRINT(r1);
127  PRINT(r2);
128  print(a, b);
129  throw test::testException(20, "a+b!=b + a");
130  }
131  }
132  };
133  }
134 #endif
Class to describe exceptions in etvo.
Definition: etvoException.h:25
Definition: testException.h:9
Definition: Test.cpp:18
Definition: TestIS.h:16