41 using error::LUMIERA_ERROR_WRONG_TYPE;
42 using error::LUMIERA_ERROR_LOGIC;
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);
125 CHECK (
true == v0.get<
bool>() );
126 CHECK (someVal == v1.get<
int>());
127 CHECK (someStr == v2.get<
string>() );
128 CHECK (someTime == v3.get<
Time>() );
152 : TestVariant::Visitor
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_);
209 : TestVariant::Predicate
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>());
240 CHECK (
"booo" == v1.get<
string>());
241 CHECK (42 == v2.get<
int>());
242 CHECK (24 == v3.get<
int>());
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
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 ... 10min + 500ms
Variant< Types< bool, int, string, Time > > TestVariant
string randStr(size_t len)
create garbage string of given length
Implementation namespace for support and library code.
int rani(uint bound=_iBOUND())
Test runner and basic definitions for tests.
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
a family of time value like entities and their relationships.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A typesafe union record to carry embedded values of unrelated type.