DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testInteger.cpp
Go to the documentation of this file.
1
16
30
32
#include <iostream>
33
#include <string>
34
#include "DGtal/base/Common.h"
35
#include "DGtal/kernel/CInteger.h"
36
#include "DGtal/kernel/CUnsignedNumber.h"
37
38
#include "DGtalCatch.h"
40
41
using namespace
std
;
42
using namespace
DGtal
;
43
45
// Functions for testing class Integer.
47
52
TEST_CASE
(
"Checking CInteger models"
)
53
{
54
trace
.
beginBlock
(
"Checking CInteger models ..."
);
55
BOOST_CONCEPT_ASSERT((
concepts::CInteger<int>
));
56
BOOST_CONCEPT_ASSERT((
concepts::CInteger<DGtal::int16_t>
));
57
58
trace
.
info
() <<
" - max int16 = "
<<
NumberTraits<DGtal::int16_t>::max
()
59
<< std::endl;
60
trace
.
info
() <<
" - min int16 = "
<<
NumberTraits<DGtal::int16_t>::min
()
61
<< std::endl;
62
trace
.
info
() <<
" - max int32 = "
<<
NumberTraits<DGtal::int32_t>::max
()
63
<< std::endl;
64
trace
.
info
() <<
" - min int32 = "
<<
NumberTraits<DGtal::int32_t>::min
()
65
<< std::endl;
66
trace
.
info
() <<
" - max int64 = "
<<
NumberTraits<DGtal::int64_t>::max
()
67
<< std::endl;
68
trace
.
info
() <<
" - min int64 = "
<<
NumberTraits<DGtal::int64_t>::min
()
69
<< std::endl;
70
trace
.
info
() <<
" - max uint16 = "
<<
NumberTraits<DGtal::uint16_t>::max
()
71
<< std::endl;
72
trace
.
info
() <<
" - min uint16 = "
<<
NumberTraits<DGtal::uint16_t>::min
()
73
<< std::endl;
74
trace
.
info
() <<
" - max uint32 = "
<<
NumberTraits<DGtal::uint32_t>::max
()
75
<< std::endl;
76
trace
.
info
() <<
" - min uint32 = "
<<
NumberTraits<DGtal::uint32_t>::min
()
77
<< std::endl;
78
trace
.
info
() <<
" - max uint64 = "
<<
NumberTraits<DGtal::uint64_t>::max
()
79
<< std::endl;
80
trace
.
info
() <<
" - min uint64 = "
<<
NumberTraits<DGtal::uint64_t>::min
()
81
<< std::endl;
82
83
trace
.
endBlock
();
84
85
trace
.
beginBlock
(
"Checking CUnsignedInteger models ..."
);
86
BOOST_CONCEPT_ASSERT((
concepts::CUnsignedNumber<unsigned int>
));
87
trace
.
endBlock
();
88
89
trace
.
beginBlock
(
"Checking NumberTraits on built-in OS dependent types ..."
);
90
trace
.
warning
() <<
"If digits() returns 0, the type is not considered in specializations"
<<endl;
91
trace
.
info
() <<
" - digits int = "
<<
NumberTraits<int>::digits
()<< std::endl;
92
trace
.
info
() <<
" - digits unsigned int = "
<<
NumberTraits<unsigned int>::digits
()<< std::endl;
93
trace
.
info
() <<
" - digits long int = "
<<
NumberTraits<long int>::digits
()<< std::endl;
94
trace
.
endBlock
();
95
}
96
97
TEST_CASE
(
"DGal::BigInteger tests"
)
98
{
99
trace
.
beginBlock
(
"Checking CUnsignedInteger models ..."
);
100
BOOST_CONCEPT_ASSERT((
concepts::CInteger<DGtal::BigInteger>
));
101
trace
.
endBlock
();
102
103
DGtal::BigInteger
big(425);
104
CHECK(big == (
int
)425);
105
106
DGtal::BigInteger
anotherbig(5);
107
DGtal::BigInteger
res = big + anotherbig;
108
CHECK(res == (
int
)430);
109
}
110
111
// //
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::warning
std::ostream & warning()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
DGtal::BigInteger
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > BigInteger
Definition
BasicTypes.h:75
std
STL namespace.
DGtal::NumberTraits
Aim: The traits class for all models of Cinteger.
Definition
NumberTraits.h:562
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition
CInteger.h:88
DGtal::concepts::CUnsignedNumber
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...
Definition
CUnsignedNumber.h:95
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
tests
kernel
testInteger.cpp
Generated on
for DGtal by
1.18.0