34 #include "DGtal/base/Common.h"
36 #include "DGtal/base/CUnaryFunctor.h"
37 #include "DGtal/base/BasicFunctors.h"
42 using namespace DGtal;
48 template <
typename TFunctor,
typename TArg,
typename TRes >
49 void basicFunctorsConceptChecking()
57 bool testBasicFunctors()
59 unsigned int nbok = 0;
68 nbok += ( f(a) == 5 ) ? 1 : 0;
76 nbok += ( f(c) == v ) ? 1 : 0;
79 nbok += ( f(d) == v ) ? 1 : 0;
87 nbok += ( f(c) == 97 ) ? 1 : 0;
96 std::pointer_to_unary_function<double, double> f(std::floor);
97 std::pointer_to_unary_function<double, double> c(std::ceil);
106 nbok += ( q(d) == 5 ) ? 1 : 0;
110 nbok += ( q2(d) == 6 ) ? 1 : 0;
117 std::binder2nd<std::minus<int> > b(std::minus<int>(), 0);
119 nbok += ( b(i) == -5 ) ? 1 : 0;
121 std::binder2nd<std::plus<int> > b2(std::plus<int>(), 2);
123 nbok += ( b2(i) == -3 ) ? 1 : 0;
130 nbok += ( t(i) == true ) ? 1 : 0;
133 nbok += ( t1(i) == true ) ? 1 : 0;
136 nbok += ( t2(0) ==
false ) ? 1 : 0;
139 nbok += ( t3(i) ==
false ) ? 1 : 0;
142 nbok += ( t4(i) ==
false ) ? 1 : 0;
150 nbok += ( t(0) ==
false ) ? 1 : 0;
152 for (
int i = low; i <= up; ++i)
154 nbok += ( t(i) == true ) ? 1 : 0;
157 nbok += ( t(6) ==
false ) ? 1 : 0;
162 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
171 int main(
int argc,
char** argv )
175 for (
int i = 0; i < argc; ++i )
180 basicFunctorsConceptChecking<DefaultFunctor,int,int>();
181 basicFunctorsConceptChecking<ConstValueFunctor<int>,int,
int >();
182 basicFunctorsConceptChecking<CastFunctor<int>,short,
int >();
183 basicFunctorsConceptChecking<Thresholder<int>,int,
bool >();
184 basicFunctorsConceptChecking<Composer<ConstValueFunctor<double>,
CastFunctor<int>,
int>,char,
int >();
188 bool res = testBasicFunctors();
189 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;