DGtal 2.1.0
Loading...
Searching...
No Matches
testDGtalBigInteger.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
Include dependency graph for testDGtalBigInteger.cpp:

Go to the source code of this file.

Functions

bool testDGtalBIGINTEGER ()
 
bool testBIGINTEGERSpace ()
 
int main (int argc, char **argv)
 

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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2010/12/13

Functions for testing class BigInteger.

This file is part of the DGtal library.

Definition in file testDGtalBigInteger.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 131 of file testDGtalBigInteger.cpp.

132{
133 trace.beginBlock ( "Testing class DGtalBIGINTEGER" );
134 trace.info() << "Args:";
135 for ( int i = 0; i < argc; ++i )
136 trace.info() << " " << argv[ i ];
137 trace.info() << endl;
138
139 bool res = testDGtalBIGINTEGER() && testBIGINTEGERSpace(); // && ... other tests
140 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
141 trace.endBlock();
142 return res ? 0 : 1;
143}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
bool testDGtalBIGINTEGER()
bool testBIGINTEGERSpace()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testBIGINTEGERSpace(), testDGtalBIGINTEGER(), and DGtal::trace.

◆ testBIGINTEGERSpace()

bool testBIGINTEGERSpace ( )

Example of a test. To be completed.

Definition at line 81 of file testDGtalBigInteger.cpp.

82{
83 unsigned int nbok = 0;
84 unsigned int nb = 0;
85
86 trace.beginBlock ( "BIGINTEGER Space test..." );
87
88 //This space is weird...
89 typedef SpaceND<2, DGtal::BigInteger> Space2;
90 typedef Space2::Point Point;
91 typedef Space2::Point::Coordinate Coordinate;
93
94 DGtal::BigInteger a(1234);
95 DGtal::BigInteger b("-5678");
96 Point p(a,b);
97
99
100 // Construct the Freeman chain
101 std::stringstream ss(stringstream::in | stringstream::out);
102 ss << "31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
103 Contour theContour( ss );
104
105 Point p1( 0, 0 );
106 Point p2( 31, 31 );
107
108 trace.info() <<"p2.norm()= "<< p2.norm()<<endl;
109
110 Domain domain( p1, p2 );
111 Board2D aBoard;
112 aBoard << SetMode( domain.className(), "Grid" )
113 << domain
114 << theContour;
115
116 aBoard.saveSVG("testbigintcontour.svg");
117
118
119 nbok += true ? 1 : 0;
120 nb++;
121 trace.info() << "(" << nbok << "/" << nb << ") "
122 << "true == true" << std::endl;
123 trace.endBlock();
124
125 return nbok == nb;
126}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition Board2D.h:71
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
std::string className() const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:1011
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > BigInteger
Definition BasicTypes.h:75
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition Board2D.h:247
MyPointD Point
FreemanChain< int > Contour
Domain domain
HyperRectDomain< Space > Domain

References DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), domain, DGtal::Trace::endBlock(), DGtal::Trace::info(), MyPointD::norm(), LibBoard::Board::saveSVG(), and DGtal::trace.

Referenced by main().

◆ testDGtalBIGINTEGER()

bool testDGtalBIGINTEGER ( )

Example of a test. To be completed.

Definition at line 53 of file testDGtalBigInteger.cpp.

54{
55 unsigned int nbok = 0;
56 unsigned int nb = 0;
57
58 trace.beginBlock ( "BIGINTEGER linking test..." );
59
60 DGtal::BigInteger a(1234);
61 DGtal::BigInteger b("-5678");
62 DGtal::BigInteger c = a + b;
63
64 trace.info() << "sum is " << c << "\n";
65 trace.info() << "absolute value is " << abs(c) << "\n";
66
67 nbok += (abs(c)==4444) ? 1 : 0;
68 nb++;
69 trace.info() << "(" << nbok << "/" << nb << ") "
70 << "true == true" << std::endl;
72
73 return nbok == nb;
74}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().