28 using lumiera::error::LUMIERA_ERROR_ASSERTION;
37 using std::placeholders::_1;
38 using std::placeholders::_2;
42 typedef FunErasure<StoreFunction> Efun;
43 typedef FunErasure<StoreFunPtr> Efp;
44 typedef FunErasure<StoreUncheckedFunPtr> Evoid;
66 function<void(int,char)> bindFunc = bind (testFunc,_1,_2);
67 function<void(int )> pAplFunc = bind (testFunc,_1,
'x');
70 function<int(void)> getterFunc = &returnIt;
72 check_FunctorContainer( Efun (testFunc)
79 check_FunctPtrHolder(Efp(testFunc),Efp(&testFunc), Efp(returnIt));
80 check_VoidPtrHolder(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt));
82 detect_unboundFunctor(Efun(testFunc), Efun(getterFunc), Efun(membFunc));
83 detect_unboundFunctor(Efp(testFunc),Efp(&testFunc), Efp(returnIt));
84 detect_unboundFunctor(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt));
90 return testFunc(
'a'-
'A', c);
95 check_FunctorContainer (Efun f1, Efun f2, Efun f3, Efun f4, Efun f5)
97 typedef void (Sig1) (int,char);
98 typedef void (Sig2) (int);
99 typedef void (Sig3) (char);
100 typedef int (Sig4) ();
103 f1.getFun<Sig1>() (-11,
'M');
104 CHECK (_sum_ ==
'M'-11);
107 f2.getFun<Sig1>() (-22,
'M');
108 CHECK (_sum_ ==
'M'-22);
111 f3.getFun<Sig2>() (-33);
112 CHECK (_sum_ ==
'x'-33);
115 f4.getFun<Sig3>() (
'U');
116 CHECK (_sum_ ==
'u');
118 CHECK (
'u' == f5.getFun<Sig4>() () );
119 CHECK (
INSTANCEOF (function<Sig4>, &f5.getFun<Sig4>()));
123 VERIFY_ERROR (ASSERTION, f1.getFun<Sig2>() ); 147 check_FunctPtrHolder (Efp f1, Efp f2, Efp f3)
149 typedef void (*FP)(int,char);
150 typedef void (&FR)(int,char);
152 FP fun1 = &f1.getFun<void(
int,
char)>();
153 FP fun2 = &f2.getFun<void(
int,
char)>();
154 FR fun2r = f2.getFun<void(
int,
char)>();
158 CHECK (_sum_ == 10+
'a');
161 CHECK (_sum_ == 10+
'a'+20+
'b');
164 CHECK (_sum_ == 10+
'a'+20+
'b'+30+
'c');
166 CHECK (_sum_ == (f3.getFun<
int(
void)>()) () );
171 check_VoidPtrHolder (Evoid f1, Evoid f2, Evoid f3)
173 typedef void (*FP)(int,char);
174 typedef void (&FR)(int,char);
176 FP fun1 = &f1.getFun<void(
int,
char)>();
177 FP fun2 = &f2.getFun<void(
int,
char)>();
178 FR fun2r = f2.getFun<void(
int,
char)>();
182 CHECK (_sum_ == 10+
'a');
185 CHECK (_sum_ == 10+
'a'+20+
'b');
188 CHECK (_sum_ == 10+
'a'+20+
'b'+30+
'c');
190 CHECK (_sum_ == (f3.getFun<
int(
void)>()) () );
192 FP bad_fun = &f3.getFun<void(
int,
char)>();
193 CHECK ((
void*)bad_fun == &returnIt);
201 detect_unboundFunctor (HOL h1, HOL h2, HOL h3)
205 NoFunc noFunction = NoFunc();
208 HOL emptyHolder (noFunction);
211 CHECK (!emptyHolder);
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Implementation namespace for support and library code.
Simplistic test class runner.
dummy functions to support unit testing of function metaprogramming helpers
A collection of frequently used helper functions to support unit testing.
Generic holder for functor objects, concealing the concrete function type.
Lumiera error handling (C++ interface).