52 using error::LUMIERA_ERROR_WRONG_TYPE;
53 using error::LUMIERA_ERROR_LOGIC;
57 typedef Variant<Types<bool,int,string,Time>> TestVariant;
94 TestVariant v2(
string(
"lololo"));
95 TestVariant v3(someTime);
105 CHECK (contains (
string(v0),
"Variant"));
106 CHECK (contains (
string(v0),
"bool"));
107 CHECK (contains (
string(v0),
"false"));
109 CHECK (contains (
string(v1),
"Variant"));
110 CHECK (contains (
string(v1),
"int"));
111 CHECK (contains (
string(v1),
"11"));
113 CHECK (contains (
string(v2),
"Variant"));
114 CHECK (contains (
string(v2),
"string"));
115 CHECK (contains (
string(v2),
"lololo"));
117 CHECK (contains (
string(v3),
"Variant"));
118 CHECK (contains (
string(v3),
"Time"));
119 CHECK (contains (
string(v3),
"0:00:00.000"));
126 int someVal = rand() % 10000;
130 TestVariant v3(someTime);
131 TestVariant v2(someStr);
132 TestVariant v1 = someVal;
133 TestVariant v0; v0 =
true;
135 CHECK (
true == v0.get<
bool>() );
136 CHECK (someVal == v1.get<
int>());
137 CHECK (someStr == v2.get<
string>() );
138 CHECK (someTime == v3.get<
Time>() );
168 void handle (
bool& b) { b_ = b; }
169 void handle (
Time& t) { t_ = t; }
171 void handle (
int& i6)
180 CHECK (acs.i_ == 12);
184 CHECK (acs.i_ == 12);
188 CHECK (acs.i_ == 12);
189 CHECK (acs.t_ == someTime);
195 CHECK (acs.i_ == 12);
196 CHECK (acs.t_ == someTime);
200 CHECK (acs.t_ == someTime);
201 CHECK (acs.i_ == someVal);
204 CHECK (someVal+1 == v1.get<
int>());
206 CHECK (someVal+2 == v1.get<
int>());
207 CHECK (someVal+1 == acs.i_);
214 const TestVariant v1(12);
215 const TestVariant v2(
string(
"123"));
221 bool handle (
int const& i) {
return i % 2; }
222 bool handle (
string const& s) {
return s.length() % 2; }
226 CHECK (12 == v1.get<
int>());
227 CHECK (
"123" == v2.get<
string>());
230 CHECK (!v1.accept(check));
231 CHECK ( v2.accept(check));
232 CHECK (!v3.accept(check));
234 CHECK (12 == v1.get<
int>());
235 CHECK (
"123" == v2.get<
string>());
243 TestVariant v1(
string(
"boo"));
250 CHECK (
"booo" == v1.get<
string>());
251 CHECK (42 == v2.get<
int>());
252 CHECK (24 == v3.get<
int>());
258 TestVariant v4 =
Time();
259 TestVariant v44 =
Time(0,4,4,4);
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
#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.
Simple 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