DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testInteger.cpp File Reference
#include <iostream>
#include <string>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CInteger.h"
#include "DGtal/kernel/CUnsignedNumber.h"

Go to the source code of this file.

Functions

bool testInteger ()
 
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/02

Functions for testing class Integer.

This file is part of the DGtal library.

Definition in file testInteger.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 98 of file testInteger.cpp.

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

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

◆ testInteger()

bool testInteger ( )

Example of a test. To be completed.

Definition at line 49 of file testInteger.cpp.

50{
51 trace.beginBlock ( "Checking CInteger models ..." );
52 BOOST_CONCEPT_ASSERT(( concepts::CInteger<int> ));
53 BOOST_CONCEPT_ASSERT(( concepts::CInteger<DGtal::int16_t> ));
54
55 trace.info() << " - max int16 = " << NumberTraits<DGtal::int16_t>::max()
56 << std::endl;
57 trace.info() << " - min int16 = " << NumberTraits<DGtal::int16_t>::min()
58 << std::endl;
59 trace.info() << " - max int32 = " << NumberTraits<DGtal::int32_t>::max()
60 << std::endl;
61 trace.info() << " - min int32 = " << NumberTraits<DGtal::int32_t>::min()
62 << std::endl;
63 trace.info() << " - max int64 = " << NumberTraits<DGtal::int64_t>::max()
64 << std::endl;
65 trace.info() << " - min int64 = " << NumberTraits<DGtal::int64_t>::min()
66 << std::endl;
67 trace.info() << " - max uint16 = " << NumberTraits<DGtal::uint16_t>::max()
68 << std::endl;
69 trace.info() << " - min uint16 = " << NumberTraits<DGtal::uint16_t>::min()
70 << std::endl;
71 trace.info() << " - max uint32 = " << NumberTraits<DGtal::uint32_t>::max()
72 << std::endl;
73 trace.info() << " - min uint32 = " << NumberTraits<DGtal::uint32_t>::min()
74 << std::endl;
75 trace.info() << " - max uint64 = " << NumberTraits<DGtal::uint64_t>::max()
76 << std::endl;
77 trace.info() << " - min uint64 = " << NumberTraits<DGtal::uint64_t>::min()
78 << std::endl;
79
81
82 trace.beginBlock ( "Checking CUnsignedInteger models ..." );
83 BOOST_CONCEPT_ASSERT(( concepts::CUnsignedNumber<unsigned int> ));
85
86 trace.beginBlock ( "Checking NumberTraits on built-in OS dependent types ..." );
87 trace.warning() << "If digits() returns 0, the type is not considered in specilizations"<<endl;
88 trace.info() << " - digits int = " << NumberTraits<int>::digits()<< std::endl;
89 trace.info() << " - digits unsigned int = " << NumberTraits<unsigned int>::digits()<< std::endl;
90 trace.info() << " - digits long int = " << NumberTraits<long int>::digits()<< std::endl;
92 return true;
93}
std::ostream & warning()
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...

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

Referenced by main().