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 >
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;
93 const double v1 = -3.5;
94 const double v2 = 3.5;
113 std::pointer_to_unary_function<double, double> f(std::floor);
114 std::pointer_to_unary_function<double, double> c(std::ceil);
123 nbok += ( q(d) == 5 ) ? 1 : 0;
127 nbok += ( q2(d) == 6 ) ? 1 : 0;
135 std::function<int(
int)> b = std::bind(std::minus<int>(), std::placeholders::_1, 0);
137 nbok += ( b(i) == -5 ) ? 1 : 0;
140 auto b2 = [](
int v) ->
int {
144 nbok += ( b2(i) == -3 ) ? 1 : 0;
151 nbok += ( t(i) == true ) ? 1 : 0;
154 nbok += ( t1(i) == true ) ? 1 : 0;
157 nbok += ( t2(0) == false ) ? 1 : 0;
160 nbok += ( t3(i) == false ) ? 1 : 0;
163 nbok += ( t4(i) == false ) ? 1 : 0;
171 nbok += ( t(0) == false ) ? 1 : 0;
173 for (
int i = low; i <= up; ++i)
175 nbok += ( t(i) == true ) ? 1 : 0;
178 nbok += ( t(6) == false ) ? 1 : 0;
183 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
192 int main(
int argc,
char** argv )
196 for (
int i = 0; i < argc; ++i )
201 basicFunctorsConceptChecking<functors::Identity,int,int>();
202 basicFunctorsConceptChecking<DGtal::functors::ConstValue<int>,int,
int >();
203 basicFunctorsConceptChecking<functors::Cast<int>,short,
int >();
204 basicFunctorsConceptChecking<DGtal::functors::Thresholder<int>,int,
bool >();
205 basicFunctorsConceptChecking<functors::Composer<functors::ConstValue<double>,
functors::Cast<int>,
int>,char,
int >();
210 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
Aim: Define a new Functor from the composition of two other functors.
Aim: Define a simple functor that returns a constant value (0 by default).
Aim: A small functor with an operator () that compares one value to an interval.
Aim: A small functor with an operator () that compares one value to a threshold value according to tw...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines a unary functor, which associates arguments to results.
Aim: Define a simple functor using the static cast operator.
Functor that rounds down.
Aim: Define a simple default functor that just returns its argument.
Functor that rounds to the nearest integer.
Functor that rounds towards zero.
void basicFunctorsConceptChecking()
int main(int argc, char **argv)