35#include "DGtal/base/Common.h"
37#include "DGtal/base/CUnaryFunctor.h"
38#include "DGtal/base/BasicFunctors.h"
49template <
typename TFunctor,
typename TArg,
typename TRes >
60 unsigned int nbok = 0;
69 nbok += ( f(a) == 5 ) ? 1 : 0;
77 nbok += ( f(c) == v ) ? 1 : 0;
80 nbok += ( f(d) == v ) ? 1 : 0;
88 nbok += ( f(c) == 97 ) ? 1 : 0;
94 const double v1 = -3.5;
95 const double v2 = 3.5;
115 double (*pF)(double) = &floor;
116 double (*pC)(double) = &ceil;
117 std::function<double(
double)> f = pF;
118 std::function<double(
double)> c = pC;
127 nbok += ( q(d) == 5 ) ? 1 : 0;
131 nbok += ( q2(d) == 6 ) ? 1 : 0;
139 std::function<int(
int)> b = std::bind(std::minus<int>(), std::placeholders::_1, 0);
141 nbok += ( b(i) == -5 ) ? 1 : 0;
144 auto b2 = [](
int v) ->
int {
148 nbok += ( b2(i) == -3 ) ? 1 : 0;
155 nbok += ( t(i) == true ) ? 1 : 0;
158 nbok += ( t1(i) == true ) ? 1 : 0;
161 nbok += ( t2(0) == false ) ? 1 : 0;
164 nbok += ( t3(i) == false ) ? 1 : 0;
167 nbok += ( t4(i) == false ) ? 1 : 0;
175 nbok += ( t(0) == false ) ? 1 : 0;
177 for (
int i = low; i <= up; ++i)
179 nbok += ( t(i) == true ) ? 1 : 0;
182 nbok += ( t(6) == false ) ? 1 : 0;
187 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
196int main(
int argc,
char** argv )
200 for (
int i = 0; i < argc; ++i )
205 basicFunctorsConceptChecking<functors::Identity,int,int>();
206 basicFunctorsConceptChecking<DGtal::functors::ConstValue<int>,int,
int >();
207 basicFunctorsConceptChecking<functors::Cast<int>,short,
int >();
208 basicFunctorsConceptChecking<DGtal::functors::Thresholder<int>,int,
bool >();
209 basicFunctorsConceptChecking<functors::Composer<functors::ConstValue<double>,
functors::Cast<int>,
int>,char,
int >();
214 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()