DGtal
1.1.0
tests
kernel
testInteger.cpp
Go to the documentation of this file.
1
30
#include <iostream>
32
#include <string>
33
#include "DGtal/base/Common.h"
34
#include "DGtal/kernel/CInteger.h"
35
#include "DGtal/kernel/CUnsignedNumber.h"
37
38
using namespace
std;
39
using namespace
DGtal
;
40
42
// Functions for testing class Integer.
44
49
bool
testInteger
()
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
80
trace
.
endBlock
();
81
82
trace
.
beginBlock
(
"Checking CUnsignedInteger models ..."
);
83
BOOST_CONCEPT_ASSERT((
concepts::CUnsignedNumber<unsigned int>
));
84
trace
.
endBlock
();
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;
91
trace
.
endBlock
();
92
return
true
;
93
}
94
96
// Standard services - public :
97
98
int
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
// //
DGtal::concepts::CUnsignedNumber
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...
Definition:
CUnsignedNumber.h:95
DGtal::Trace::endBlock
double endBlock()
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition:
CInteger.h:88
max
int max(int a, int b)
Definition:
testArithmeticalDSS.cpp:1108
DGtal::NumberTraits
Aim: The traits class for all models of Cinteger.
Definition:
NumberTraits.h:533
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::trace
Trace trace
Definition:
Common.h:150
testInteger
bool testInteger()
Definition:
testInteger.cpp:49
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
main
int main(int argc, char **argv)
Definition:
testInteger.cpp:98
DGtal::Trace::info
std::ostream & info()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition:
ClosedIntegerHalfPlane.h:49
DGtal::Trace::warning
std::ostream & warning()
Generated on Fri Oct 9 2020 08:58:21 for DGtal by
1.8.20