(Event+Time).Variant Operators  2.3
Operators for Timed Discrete Event Systems in Dioids
TestXIS.h
1 #ifndef __TEST_XIS__
2 #define __TEST_XIS__
3 
4 #include<algorithm>
5 #include<vector>
6 #include "../../etvo/common/etvoException.h"
7 #include "../macros.h"
8 #include "../Test.h"
9 namespace test
10 {
11  /*************************************************************************************/
12  /*************************************************************************************/
13  template <class T>
14  class TestXIS {
15  public:
16  static bool TestAll(const T & a)
17  {
18  bool success = true;
19  try {
22  }
23  catch (const test::testException & e)
24  {
25  std::cout << "Exception #" << e.Num();
26  std::cout << " Msg :" << e.Message() << std::endl;
27  success = false;
28  }
29  return success;
30  }
31 
32  static void print(const T & a)
33  {
34  std::cout << "a=" << a << std::endl;
35  }
36 
37 
38  static void Test0()
39  {
40 
41  T eps = T::Epsilon();
42  T top = T::Top();
43  if (!(eps + eps == eps))
44  {
45  throw test::testException(500, "eps+eps!=eps");
46  }
47 
48  if (!(eps * eps == eps))
49  {
50  throw test::testException(500, "eps*eps!=eps");
51  }
52 
53  if (!(eps * top == eps))
54  {
55  throw test::testException(500, "eps*Top!=eps");
56  }
57 
58  if (!(top*eps == eps))
59  {
60  throw test::testException(500, "Top*eps!=eps");
61  }
62 
63  if (!(top*top == top))
64  {
65  throw test::testException(500, "Top*Top!=Top");
66  }
67 
68  if (!(top + top == top))
69  {
70  throw test::testException(500, "Top*Top!=Top");
71  }
72  if (!(eps + top == top))
73  {
74  throw test::testException(500, "eps+Top!=Top");
75  }
76 
77  if (!(top + eps == top))
78  {
79  throw test::testException(500, "Top+eps!=Top");
80  }
81  }
82 
83  static void Test1(const T & a)
84  {
85  T eps = T::Epsilon();
86  T top = T::Top();
87  if (!(a + eps == a))
88  {
89  PRINT(a);
90  PRINT(a+eps);
91  throw test::testException(501, "a+eps!=a");
92  }
93 
94  if (!(eps + a == a))
95  {
96  PRINT(eps+a);
97  PRINT(a);
98  throw test::testException(502, "eps+a!=a");
99  }
100 
101  if (!(a * eps == eps))
102  {
103  PRINT(a*eps);
104  PRINT(eps);
105  throw test::testException(503, "a*eps!=eps");
106  }
107 
108  if (!(eps * a == eps))
109  {
110  PRINT(eps*a);
111  PRINT(a);
112  throw test::testException(504, "eps*a!=eps");
113  }
114 
115  if (!((a + top) == top))
116  {
117  PRINT(a+top);
118  PRINT(a);
119  throw test::testException(505, "a+top!=top");
120  }
121 
122  if (!((top + a) == top))
123  {
124  PRINT((top + a));
125  PRINT(a);
126  throw test::testException(506, "top+a!=top");
127  }
128 
129  if (!(a==eps) && !(a * top == top))
130  {
131  PRINT(a);
132  throw test::testException(507, "a*top!=top");
133  }
134 
135  if (!(a == eps) && !(top*a == top))
136  {
137  PRINT(a);
138  throw test::testException(508, "top*a!=top");
139  }
140  }
141  };
142 }
143 #endif
Definition: testException.h:9
Definition: TestXIS.h:14
Definition: Test.cpp:18