41 using error::LUMIERA_ERROR_WRONG_TYPE;
42 using error::LUMIERA_ERROR_LOGIC;
46 typedef Variant<Types<bool,int,string,Time>> TestVariant;
84 TestVariant v2(
string(
"lololo"));
85 TestVariant v3(someTime);
95 CHECK (contains (
string(v0),
"Variant"));
96 CHECK (contains (
string(v0),
"bool"));
97 CHECK (contains (
string(v0),
"false"));
99 CHECK (contains (
string(v1),
"Variant"));
100 CHECK (contains (
string(v1),
"int"));
101 CHECK (contains (
string(v1),
"11"));
103 CHECK (contains (
string(v2),
"Variant"));
104 CHECK (contains (
string(v2),
"string"));
105 CHECK (contains (
string(v2),
"lololo"));
107 CHECK (contains (
string(v3),
"Variant"));
108 CHECK (contains (
string(v3),
"Time"));
109 CHECK (contains (
string(v3),
"0:00:00.000"));
116 int someVal =
rani(10000);
120 TestVariant v3(someTime);
121 TestVariant v2(someStr);
122 TestVariant v1 = someVal;
123 TestVariant v0; v0 =
true;
125 CHECK (
true == v0.get<
bool>() );
126 CHECK (someVal == v1.get<
int>());
127 CHECK (someStr == v2.get<
string>() );
128 CHECK (someTime == v3.get<
Time>() );
158 void handle (
bool& b) { b_ = b; }
159 void handle (
Time& t) { t_ = t; }
161 void handle (
int& i6)
170 CHECK (acs.i_ == 12);
174 CHECK (acs.i_ == 12);
178 CHECK (acs.i_ == 12);
179 CHECK (acs.t_ == someTime);
185 CHECK (acs.i_ == 12);
186 CHECK (acs.t_ == someTime);
190 CHECK (acs.t_ == someTime);
191 CHECK (acs.i_ == someVal);
194 CHECK (someVal+1 == v1.get<
int>());
196 CHECK (someVal+2 == v1.get<
int>());
197 CHECK (someVal+1 == acs.i_);
204 const TestVariant v1(12);
205 const TestVariant v2(
string(
"123"));
211 bool handle (
int const& i) {
return i % 2; }
212 bool handle (
string const& s) {
return s.length() % 2; }
216 CHECK (12 == v1.get<
int>());
217 CHECK (
"123" == v2.get<
string>());
220 CHECK (!v1.accept(check));
221 CHECK ( v2.accept(check));
222 CHECK (!v3.accept(check));
224 CHECK (12 == v1.get<
int>());
225 CHECK (
"123" == v2.get<
string>());
233 TestVariant v1(
string(
"boo"));
240 CHECK (
"booo" == v1.get<
string>());
241 CHECK (42 == v2.get<
int>());
242 CHECK (24 == v3.get<
int>());
248 TestVariant v4 =
Time();
249 TestVariant v44 =
Time(0,4,4,4);
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
int rani(uint bound=_iBOUND())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Implementation namespace for support and library code.
string randStr(size_t len)
create garbage string of given length
Lumiera's internal time value datatype.
A typesafe union record to carry embedded values of unrelated type.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
to be implemented by the client for visitation
static const Time NEVER
border condition marker value. NEVER >= any time value
lib::time::Time randTime()
create a random but not insane Time value between 1s ...
a family of time value like entities and their relationships.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container