File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
testInteger.cpp File Reference
#include <iostream>
#include <string>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CInteger.h"
#include "DGtal/kernel/CUnsignedNumber.h"
#include "DGtalCatch.h"
Include dependency graph for testInteger.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Checking CInteger models")
 TEST_CASE ("DGal::BigInteger tests")

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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@c.nosp@m.nrs.f.nosp@m.r ), LIRIS (CNRS, UMR 5205),
Date
2010/07/02

Functions for testing class Integer.

This file is part of the DGtal library.

Definition in file testInteger.cpp.

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "Checking CInteger models" )

Example of a test. To be completed.

Definition at line 52 of file testInteger.cpp.

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}
Trace trace
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...

References DGtal::trace.

◆ TEST_CASE() [2/2]

TEST_CASE ( "DGal::BigInteger tests" )

Definition at line 97 of file testInteger.cpp.

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}
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > BigInteger
Definition BasicTypes.h:75

References DGtal::trace.