Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
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
41using namespace std;
42using namespace DGtal;
43
45// Functions for testing class Integer.
47
52TEST_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 specilizations"<<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
97TEST_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 is the top-level namespace which contains all DGtal functions and types.
Trace trace
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > BigInteger
Definition BasicTypes.h:75
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...
TEST_CASE("Checking CInteger models")