(Event+Time).Variant Operators  2.3
Operators for Timed Discrete Event Systems in Dioids
TestKleene.h
1 #pragma once
2 
3 #include<algorithm>
4 #include<vector>
5 #include "../../etvo/common/etvoException.h"
6 #include "../testException.h"
7 #include "../macros.h"
8 #include<iostream>
9 
10 namespace test
11 {
12  /*************************************************************************************/
13  /*************************************************************************************/
14  template <class T>
15  class TestKleene {
16  public:
17 
19  static bool TestAll(const T & a,const T& b)
20  {
21 
22  bool success = true;
23  try {
26 
27  }
28  catch (const test::testException & e)
29  {
30  std::cout << "Error in TestKleene!" << std::endl;
31  std::cout << "Exception :" << e.Message() << std::endl;
32  success = false;
33  }
34  catch (const etvo::etvoException & e2)
35  {
36  std::cout << "Error in TestKleene!" << 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 TestKleene!" << 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)
50  {
51  PRINT(a);
52  }
53 
54  static void Test1(const T & a)
55  {
56  T stara = a.star();
57  T x = stara*stara;
58  T y = stara.lfrac(stara);
59  T z = stara.rfrac(stara);
60 
61  if (!(x == stara))
62  {
63  print(stara);
64  print(x);
65  throw test::testException(201, "Test1a");
66  }
67 
68  if (!(y==stara))
69  {
70  print(stara);
71  print(y);
72  throw testException(201, "Test1b");
73  }
74 
75  if (!(z == stara))
76  {
77  print(stara);
78  print(z);
79  throw testException(201, "Test1c");
80  }
81  }
82 
83 
84  static void Test2(const T & a)
85  {
86  T alfa = a.lfrac(a);
87  T arfa = a.rfrac(a);
88  T x = a * alfa;
89  T y = arfa*a;
90 
91 
92  if (!(x == a)){
93  print(a);
94  throw testException(205, "Test2a");
95  }
96 
97  if (!(y == a)){
98  print(a);
99  throw testException(205, "Test2b");
100  }
101 
102  x = alfa.star();
103  y = arfa.star();
104 
105  if (!(x == alfa)){
106  print(a);
107  throw testException(205, "Test2c");
108  }
109 
110  if (!(y == arfa)){
111  print(a);
112  throw testException(205, "Test2d");
113  }
114  }
115 
116  };
117 
118 }
Class to describe exceptions in etvo.
Definition: etvoException.h:25
Definition: testException.h:9
Definition: Test.cpp:18
Definition: TestKleene.h:15
static bool TestAll(const T &a, const T &b)
a Gain 1, b Gain free
Definition: TestKleene.h:19