37 using lumiera::error::LUMIERA_ERROR_ASSERTION;
46 using std::placeholders::_1;
47 using std::placeholders::_2;
51 typedef FunErasure<StoreFunction> Efun;
52 typedef FunErasure<StoreFunPtr> Efp;
53 typedef FunErasure<StoreUncheckedFunPtr> Evoid;
75 function<void(int,char)> bindFunc = bind (testFunc,_1,_2);
76 function<void(int )> pAplFunc = bind (testFunc,_1,
'x');
79 function<int(void)> getterFunc = &returnIt;
81 check_FunctorContainer( Efun (testFunc)
88 check_FunctPtrHolder(Efp(testFunc),Efp(&testFunc), Efp(returnIt));
89 check_VoidPtrHolder(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt));
91 detect_unboundFunctor(Efun(testFunc), Efun(getterFunc), Efun(membFunc));
92 detect_unboundFunctor(Efp(testFunc),Efp(&testFunc), Efp(returnIt));
93 detect_unboundFunctor(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt));
99 return testFunc(
'a'-
'A', c);
104 check_FunctorContainer (Efun f1, Efun f2, Efun f3, Efun f4, Efun f5)
106 typedef void (Sig1) (int,char);
107 typedef void (Sig2) (int);
108 typedef void (Sig3) (char);
109 typedef int (Sig4) ();
112 f1.getFun<Sig1>() (-11,
'M');
113 CHECK (_sum_ ==
'M'-11);
116 f2.getFun<Sig1>() (-22,
'M');
117 CHECK (_sum_ ==
'M'-22);
120 f3.getFun<Sig2>() (-33);
121 CHECK (_sum_ ==
'x'-33);
124 f4.getFun<Sig3>() (
'U');
125 CHECK (_sum_ ==
'u');
127 CHECK (
'u' == f5.getFun<Sig4>() () );
128 CHECK (
INSTANCEOF (function<Sig4>, &f5.getFun<Sig4>()));
132 VERIFY_ERROR (ASSERTION, f1.getFun<Sig2>() ); 156 check_FunctPtrHolder (Efp f1, Efp f2, Efp f3)
158 typedef void (*FP)(int,char);
159 typedef void (&FR)(int,char);
161 FP fun1 = &f1.getFun<void(
int,
char)>();
162 FP fun2 = &f2.getFun<void(
int,
char)>();
163 FR fun2r = f2.getFun<void(
int,
char)>();
167 CHECK (_sum_ == 10+
'a');
170 CHECK (_sum_ == 10+
'a'+20+
'b');
173 CHECK (_sum_ == 10+
'a'+20+
'b'+30+
'c');
175 CHECK (_sum_ == (f3.getFun<
int(
void)>()) () );
180 check_VoidPtrHolder (Evoid f1, Evoid f2, Evoid f3)
182 typedef void (*FP)(int,char);
183 typedef void (&FR)(int,char);
185 FP fun1 = &f1.getFun<void(
int,
char)>();
186 FP fun2 = &f2.getFun<void(
int,
char)>();
187 FR fun2r = f2.getFun<void(
int,
char)>();
191 CHECK (_sum_ == 10+
'a');
194 CHECK (_sum_ == 10+
'a'+20+
'b');
197 CHECK (_sum_ == 10+
'a'+20+
'b'+30+
'c');
199 CHECK (_sum_ == (f3.getFun<
int(
void)>()) () );
201 FP bad_fun = &f3.getFun<void(
int,
char)>();
202 CHECK ((
void*)bad_fun == &returnIt);
210 detect_unboundFunctor (HOL h1, HOL h2, HOL h3)
214 NoFunc noFunction = NoFunc();
217 HOL emptyHolder (noFunction);
220 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.
Simple 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).