DGtal 1.4.0
Loading...
Searching...
No Matches
testInteger.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include <string>
33#include "DGtal/base/Common.h"
34#include "DGtal/kernel/CInteger.h"
35#include "DGtal/kernel/CUnsignedNumber.h"
37
38using namespace std;
39using namespace DGtal;
40
42// Functions for testing class Integer.
44
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}
94
96// Standard services - public :
97
98int main( int argc, char** argv )
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}
111// //
void beginBlock(const std::string &keyword="")
std::ostream & warning()
std::ostream & emphase()
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
Aim: The traits class for all models of Cinteger.
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...
int main()
Definition testBits.cpp:56
bool testInteger()