DGtal  1.4.beta
testBasicMathFunctions.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/math/BasicMathFunctions.h"
Include dependency graph for testBasicMathFunctions.cpp:

Go to the source code of this file.

Functions

bool testBasicMathFunctions ()
 
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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/10/26

Functions for testing class BasicMathFunctions.

This file is part of the DGtal library.

Definition in file testBasicMathFunctions.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 95 of file testBasicMathFunctions.cpp.

96 {
97  trace.beginBlock ( "Testing class BasicMathFunctions" );
98  trace.info() << "Args:";
99  for ( int i = 0; i < argc; ++i )
100  trace.info() << " " << argv[ i ];
101  trace.info() << endl;
102 
103  bool res = testBasicMathFunctions(); // && ... other tests
104  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
105  trace.endBlock();
106  return res ? 0 : 1;
107 }
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
bool testBasicMathFunctions()

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

◆ testBasicMathFunctions()

bool testBasicMathFunctions ( )

Example of a test. To be completed.

Definition at line 46 of file testBasicMathFunctions.cpp.

47 {
48  unsigned int nbok = 0;
49  unsigned int nb = 0;
50 
51  trace.beginBlock ( "Testing power by squaring ..." );
52 
53  trace.info() << "power(5,4)= "<< functions::power(5,4) <<std::endl;
54  nbok += (functions::power(5,4)==625) ? 1 : 0;
55  nb++;
56  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
57 
58 
59  trace.info() << "power(5.0,4)= "<< functions::power(5.0,4) <<std::endl;
60  nbok += (functions::power(5,4)==625.0) ? 1 : 0;
61  nb++;
62  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
63 
64 
65  trace.endBlock();
66  trace.beginBlock ( "Testing roundToUpperPowerOfTwo ..." );
67 
68  trace.info() << "roundToUpperPowerOfTwo(200)= "<< functions::roundToUpperPowerOfTwo(200) <<std::endl;
69  nbok += (functions::roundToUpperPowerOfTwo(200)==256) ? 1 : 0;
70  nb++;
71 
72  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
73 
74 
75  trace.info() << "roundToUpperPowerOfTwo(1000)= "<< functions::roundToUpperPowerOfTwo(1000) <<std::endl;
76  nbok += (functions::roundToUpperPowerOfTwo(1000)==1024) ? 1 : 0;
77  nb++;
78  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
79 
80 
81  trace.info() << "power(5.0,4)= "<< functions::power(5.0,4) <<std::endl;
82  nbok += (functions::power(5,4)==625.0) ? 1 : 0;
83  nb++;
84  trace.info() << "(" << nbok << "/" << nb << ") " << std::endl;
85 
86 
87  trace.endBlock();
88 
89  return nbok == nb;
90 }

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

Referenced by main().