DGtal  1.5.beta
testBasicBoolFunctors.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/base/BasicBoolFunctors.h"
Include dependency graph for testBasicBoolFunctors.cpp:

Go to the source code of this file.

Macros

#define INBLOCK_TEST(x)
 
#define INBLOCK_TEST2(x, y)
 

Functions

bool testBasicBoolFunctors ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Date
2010/07/10

Functions for testing class BasicBoolFunctors.

This file is part of the DGtal library.

Definition in file testBasicBoolFunctors.cpp.

Macro Definition Documentation

◆ INBLOCK_TEST

#define INBLOCK_TEST (   x)
Value:
nbok += ( x ) ? 1 : 0; \
nb++; \
trace.info() << "(" << nbok << "/" << nb << ") " \
<< #x << std::endl;

Definition at line 40 of file testBasicBoolFunctors.cpp.

◆ INBLOCK_TEST2

#define INBLOCK_TEST2 (   x,
 
)
Value:
nbok += ( x ) ? 1 : 0; \
nb++; \
trace.info() << "(" << nbok << "/" << nb << ") " \
<< y << std::endl;

Definition at line 46 of file testBasicBoolFunctors.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 157 of file testBasicBoolFunctors.cpp.

158 {
159  trace.beginBlock ( "Testing class BasicBoolFunctors" );
160  trace.info() << "Args:";
161  for ( int i = 0; i < argc; ++i )
162  trace.info() << " " << argv[ i ];
163  trace.info() << endl;
164 
165  bool res = testBasicBoolFunctors(); // && ... other tests
166  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
167  trace.endBlock();
168  return res ? 0 : 1;
169 }
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
bool testBasicBoolFunctors()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testBasicBoolFunctors(), and DGtal::trace.

◆ testBasicBoolFunctors()

bool testBasicBoolFunctors ( )

Example of a test. To be completed.

Definition at line 59 of file testBasicBoolFunctors.cpp.

60 {
61  unsigned int nbok = 0;
62  unsigned int nb = 0;
63 
64  trace.beginBlock ( "Testing block ..." );
65  // true()
66  nbok += trueBF0() == true ? 1 : 0;
67  nb++;
68  trace.info() << "(" << nbok << "/" << nb << ") "
69  << "true() == true" << std::endl;
70 
71  // false()
72  nbok += falseBF0() == false ? 1 : 0;
73  nb++;
74  trace.info() << "(" << nbok << "/" << nb << ") "
75  << "false() == false" << std::endl;
76 
77  // id( b )
78  nbok += identityBF1( true ) == true ? 1 : 0;
79  nb++;
80  trace.info() << "(" << nbok << "/" << nb << ") "
81  << "id(true) == true" << std::endl;
82  nbok += identityBF1( false ) == false ? 1 : 0;
83  nb++;
84  trace.info() << "(" << nbok << "/" << nb << ") "
85  << "id(false) == false" << std::endl;
86 
87  // not( b )
88  nbok += notBF1( true ) == false ? 1 : 0;
89  nb++;
90  trace.info() << "(" << nbok << "/" << nb << ") "
91  << "not(true) == false" << std::endl;
92  nbok += notBF1( false ) == true ? 1 : 0;
93  nb++;
94  trace.info() << "(" << nbok << "/" << nb << ") "
95  << "not(false) == true" << std::endl;
96 
97  // and( b1, b2 )
98  nbok += andBF2( true, true ) == true ? 1 : 0;
99  nb++;
100  trace.info() << "(" << nbok << "/" << nb << ") "
101  << "and( true, true ) == true" << std::endl;
102  nbok += andBF2( false, true ) == false ? 1 : 0;
103  nb++;
104  trace.info() << "(" << nbok << "/" << nb << ") "
105  << "and( false, true ) == false" << std::endl;
106  nbok += andBF2( true, false ) == false ? 1 : 0;
107  nb++;
108  trace.info() << "(" << nbok << "/" << nb << ") "
109  << "and( true, false ) == false" << std::endl;
110  nbok += andBF2( false, false ) == false ? 1 : 0;
111  nb++;
112  trace.info() << "(" << nbok << "/" << nb << ") "
113  << "and( false, false ) == false" << std::endl;
114 
115  // or( b1, b2 )
116  nbok += orBF2( true, true ) == true ? 1 : 0;
117  nb++;
118  trace.info() << "(" << nbok << "/" << nb << ") "
119  << "or( true, true ) == true" << std::endl;
120  nbok += orBF2( false, true ) == true ? 1 : 0;
121  nb++;
122  trace.info() << "(" << nbok << "/" << nb << ") "
123  << "or( false, true ) == true" << std::endl;
124  nbok += orBF2( true, false ) == true ? 1 : 0;
125  nb++;
126  trace.info() << "(" << nbok << "/" << nb << ") "
127  << "or( true, false ) == true" << std::endl;
128  nbok += orBF2( false, false ) == false ? 1 : 0;
129  nb++;
130  trace.info() << "(" << nbok << "/" << nb << ") "
131  << "or( false, false ) == true" << std::endl;
132 
133  // xor( b1, b2 )
134  INBLOCK_TEST2( xorBF2( true, true ) == false, "xor( true, true ) == false" );
135  INBLOCK_TEST2( xorBF2( false, true ) == true, "xor( false, true ) == true" );
136  INBLOCK_TEST2( xorBF2( true, false ) == true, "xor( true, false ) == true" );
137  INBLOCK_TEST2( xorBF2( false, false ) == false, "xor( false, false ) == false" );
138 
139  // implies( b1, b2 )
140  INBLOCK_TEST2( impliesBF2( true, true ) == true,
141  "implies( true, true ) == true" );
142  INBLOCK_TEST2( impliesBF2( false, true ) == true,
143  "implies( false, true ) == true" );
144  INBLOCK_TEST2( impliesBF2( true, false ) == false,
145  "implies( true, false ) == false" );
146  INBLOCK_TEST2( impliesBF2( false, false ) == true,
147  "implies( false, false ) == true" );
148 
149  trace.endBlock();
150 
151  return nbok == nb;
152 }
#define INBLOCK_TEST2(x, y)

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), INBLOCK_TEST2, DGtal::Trace::info(), and DGtal::trace.

Referenced by main().