(Event+Time).Variant Operators  2.3
Operators for Timed Discrete Event Systems in Dioids
TestResiduation.h
1 #pragma once
2 
3 
4 #include<algorithm>
5 #include<vector>
6 #include "../../etvo/common/etvoException.h"
7 #include "../testException.h"
8 #include "../macros.h"
9 #include "../Test.h"
10 #include<iostream>
11 
12 namespace test
13 {
14  /*************************************************************************************/
15  /*************************************************************************************/
16  template <class T>
18  public:
19 
21  static bool TestAll(const T & a, const T& b, const T& c,const T& d)
22  {
23 
24  bool success = true;
25  try {
29  //test::TestResiduation<T>::Test78(a); -> moved to TestKleene
30  }
31  catch (const test::testException & e)
32  {
33  std::cout << "Error in TestResiduation!" << std::endl;
34  std::cout << "Exception :" << e.Message() << std::endl;
35  success = false;
36  }
37  catch (const etvo::etvoException & e2)
38  {
39  std::cout << "Error in TestResiduation!" << std::endl;
40  std::cout << "Exception :" << e2.Message() << std::endl;
41  success = false;
42  }
43  catch (const std::exception & ex)
44  {
45  std::cout << "Error in TestResiduation!" << std::endl;
46  std::cout << "Exception :" << ex.what() << std::endl;
47  success = false;
48  }
49  return success;
50  }
51 
52 
53  static void Test1(const T & a, const T& b, const T & c)
54  {
55  T tmpAplusB = a + b;
56  T x = c.lfrac(tmpAplusB);
57  T y = (c.lfrac(a)).inf(c.lfrac(b));
58 
59  if (!(x == y))
60  {
61  std::cout << "Error in TestResiduation::Test1" << std::endl;
62 
63  PRINT(x);
64  PRINT(y);
65  PRINT(a);
66  PRINT(b);
67  PRINT(c);
68  throw test::testException(201, "Test1a");
69 
70  }
71 
72  x = c.rfrac(tmpAplusB);
73  y = (c.rfrac(a)).inf(c.rfrac(b));
74  if (!(x == y))
75  {
76  std::cout << "Error in TestResiduation::Test1" << std::endl;
77 
78  PRINT(x);
79  PRINT(y);
80  PRINT(a);
81  PRINT(b);
82  PRINT(c);
83  throw testException(201, "Test1b");
84 
85  }
86  }
87 
88  static void Test1b(const T & a, const T & b, const T& c)
89  {
90  T tmpAinfB = a.inf(b);
91  T x = (tmpAinfB).lfrac(c);
92  T y = (a.lfrac(c)).inf(b.lfrac(c));
93 
94  if (!(x == y))
95  {
96  std::cout << "Error in TestResiduation::Test1b" << std::endl;
97 
98  PRINT(x);
99  PRINT(y);
100  PRINT(a);
101  PRINT(b);
102  PRINT(c);
103  throw testException(205, "Test1b_a");
104 
105  }
106 
107  x = (tmpAinfB).rfrac(c);
108  y = (a.rfrac(c)).inf(b.rfrac(c));
109 
110  if (!(x == y))
111  {
112  std::cout << "Error in TestResiduation::Test1b" << std::endl;
113 
114  PRINT(x);
115  PRINT(y);
116  PRINT(a);
117  PRINT(b);
118  PRINT(c);
119  throw testException(205, "Test1b_b");
120 
121  }
122  }
123 
124  static void Test2346(const T & a, const T& c, const T & d)
125  {
126  T clfa = c.lfrac(a);
127  T crfa = c.rfrac(a);
128  T x, y;
129 
130  x = clfa.rfrac(d);
131  y = (c.rfrac(d)).lfrac(a);
132 
133  if (!(x == y))
134  {
135  std::cout << "Error in TestResiduation::Test2346" << std::endl;
136  {
137  PRINT(x);
138  PRINT(y);
139  PRINT(a);
140  PRINT(c);
141  PRINT(d);
142  throw testException(202, "Test2a");
143  }
144  }
145 
146  x = c.lfrac(a*d);
147  y = clfa.lfrac(d);
148 
149  if (!(x == y))
150  {
151  std::cout << "Error in TestResiduation::Test2346" << std::endl;
152  {
153  PRINT(x);
154  PRINT(y);
155  PRINT(a);
156  PRINT(c);
157  PRINT(d);
158  throw testException(206, "Test6a");
159  }
160  }
161 
162  x = c.rfrac(d*a);
163  y = crfa.rfrac(d);
164 
165  if (!(x == y))
166  {
167  std::cout << "Error in TestResiduation::Test2346" << std::endl;
168 
169  {
170  PRINT(x);
171  PRINT(y);
172  PRINT(a);
173  PRINT(c);
174  PRINT(d);
175  throw testException(206, "Test6b");
176  }
177  }
178 
179  T ac = a * c;
180  T ca = c*a;
181 
182  y = a * (ac.lfrac(a));
183 
184  if (!(ac == y))
185  {
186  std::cout << "Error in TestResiduation::Test2346" << std::endl;
187 
188  {
189  PRINT(ac);
190  PRINT(y);
191  throw testException(203, "Test3a");
192  }
193  }
194 
195  y = (ca.rfrac(a))*a;
196 
197  if (!(ca == y))
198  {
199  std::cout << "Error in TestResiduation::Test2346" << std::endl;
200 
201  {
202  PRINT(ca);
203  PRINT(y);
204  throw testException(203, "Test3b");
205  }
206  }
207 
208  y = (a * clfa).lfrac(a);
209 
210  if (!(clfa == y))
211  {
212  std::cout << "Error in TestResiduation::Test2346" << std::endl;
213 
214  {
215  PRINT(clfa);
216  PRINT(y);
217  throw testException(204, "Test4a");
218  }
219  }
220 
221  y = (crfa*a).rfrac(a);
222 
223  if (!(crfa == y))
224  {
225  std::cout << "Error in TestResiduation::Test2346" << std::endl;
226 
227  {
228  PRINT(crfa);
229  PRINT(y);
230  throw testException(204, "Test4b");
231  }
232  }
233  }
234 
235  };
236 
237 }
Class to describe exceptions in etvo.
Definition: etvoException.h:25
Definition: testException.h:9
Definition: Test.cpp:18
static bool TestAll(const T &a, const T &b, const T &c, const T &d)
a,b same Gain
Definition: TestResiduation.h:21
Definition: TestResiduation.h:17