(Event+Time).Variant Operators  2.3
Operators for Timed Discrete Event Systems in Dioids
TestResiduationIneq.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 
11 namespace test
12 {
13  /*************************************************************************************/
14  /*************************************************************************************/
15  template <class T>
17  public:
18 
19  static bool TestAll(const T & a,const T& b, const T& c,const T& d)
20  {
21  bool success = true;
22  try {
26  }
27  catch (const test::testException & e)
28  {
29  std::cout << "Error in TestResiduationIneq!" << 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 TestResiduationIneq!" << std::endl;
36  std::cout << "Exception :" << e2.Message() << std::endl;
37  success = false;
38  }
39  catch (const std::exception & ex)
40  {
41  std::cout << "Error in TestResiduationIneq!" << std::endl;
42  std::cout << "Exception :" << ex.what() << std::endl;
43  success = false;
44  }
45  return success;
46  }
47 
48 
49  static void Test1(const T & a, const T& b)
50  {
51  T x = (a*b).lfrac(a);
52  if (!(b <= x))
53  {
54  std::cout << "Error in TestResiduationIneq::Test1" << std::endl;
55 
56  {
57  PRINT(b);
58  PRINT(x);
59  PRINT(a);
60  throw testException(302, "Test1a");
61  }
62  }
63 
64  x = (b*a).rfrac(a);
65  if (!(b <= x))
66 
67  {
68  std::cout << "Error in TestResiduationIneq::Test1" << std::endl;
69 
70  {
71  PRINT(b);
72  PRINT(x);
73  PRINT(a);
74  throw testException(302, "Test1b ");
75  }
76  }
77  }
78 
79  static void Test23(const T & a, const T& b, const T&c)
80  {
81  T blfc = b.lfrac(c);
82  T brfc = b.rfrac(c);
83 
84  T x = c * blfc;
85 
86  if (!(x <= b))
87  {
88  std::cout << "Error in TestResiduationIneq::Test23" << std::endl;
89 
90  {
91  PRINT(x);
92  PRINT(b);
93  PRINT(a);
94  PRINT(c);
95  throw testException(301, "Test2a");
96  }
97  }
98 
99  x = brfc*c;
100  if (!(x <= b))
101  {
102  std::cout << "Error in TestResiduationIneq::Test23" << std::endl;
103 
104  {
105  PRINT(x);
106  PRINT(b);
107  PRINT(a);
108  PRINT(c);
109  throw testException(301, "Test2b ");
110  }
111  }
112 
113  T aplusb = a + b;
114  x = aplusb.lfrac(c);
115  T y = a.lfrac(c) + b.lfrac(c);
116 
117  if (!(y <= x))
118  {
119  std::cout << "Error in TestResiduationIneq::Test23" << std::endl;
120 
121  {
122  PRINT(y);
123  PRINT(x);
124  PRINT(a);
125  PRINT(b);
126  PRINT(c);
127  throw testException(303, "Test3a");
128  }
129  }
130 
131  x = aplusb.rfrac(c);
132  y = a.rfrac(c) + b.rfrac(c);
133  if (!(y <= x))
134  {
135  std::cout << "Error in TestResiduationIneq::Test23" << std::endl;
136 
137  {
138  PRINT(y);
139  PRINT(x);
140  PRINT(a);
141  PRINT(b);
142  PRINT(c);
143  throw testException(303, "Test3b ");
144  }
145  }
146  }
147 
148  static void Test45(const T&a,const T & b, const T& c, const T& d)
149  {
150  T ainfb = a.inf(b);
151  T x = c.lfrac(ainfb);
152  T clfb = c.lfrac(b);
153  T crfb = c.rfrac(b);
154 
155  T y = c.lfrac(a) + clfb;
156 
157  if (!(y <= x))
158  {
159  std::cout << "Error in TestResiduationIneq::Test45" << std::endl;
160 
161  {
162  PRINT(y);
163  PRINT(x);
164  PRINT(a);
165  PRINT(b);
166  PRINT(c);
167  PRINT(d);
168  throw testException(304, "Test4a");
169  }
170  }
171 
172  x = c.rfrac(ainfb);
173  y = c.rfrac(a) + crfb;
174 
175  if (!(y <= x))
176  {
177  std::cout << "Error in TestResiduationIneq::Test45" << std::endl;
178 
179  {
180  PRINT(y);
181  PRINT(x);
182  PRINT(a);
183  PRINT(b);
184  PRINT(c);
185  PRINT(d);
186  throw testException(304, "Test4b ");
187  }
188  }
189  x = clfb*d;
190  y = (c*d).lfrac(b);
191 
192  if (!(x <= y))
193  {
194  std::cout << "Error in TestResiduationIneq::Test45" << std::endl;
195 
196  {
197  PRINT(x);
198  PRINT(y);
199  PRINT(a);
200  PRINT(b);
201  PRINT(c);
202  PRINT(d);
203  throw testException(305, "Test5a");
204  }
205  }
206 
207  x = d*crfb;
208  y = (d*c).rfrac(b);
209 
210  if (!(x <= y))
211  {
212  std::cout << "Error in TestResiduationIneq::Test45" << std::endl;
213 
214  {
215  PRINT(x);
216  PRINT(y);
217  PRINT(a);
218  PRINT(b);
219  PRINT(c);
220  PRINT(d);
221  throw testException(305, "Test5b ");
222  }
223  }
224  }
225  };
226 
227 }
Class to describe exceptions in etvo.
Definition: etvoException.h:25
Definition: testException.h:9
Definition: TestResiduationIneq.h:16
Definition: Test.cpp:18