DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testDGtalGMP.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"

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 DGtalGMP.

This file is part of the DGtal library.

Definition in file testDGtalGMP.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 134 of file testDGtalGMP.cpp.

135{
136 trace.beginBlock ( "Testing class DGtalBIGINTEGER" );
137 trace.info() << "Args:";
138 for ( int i = 0; i < argc; ++i )
139 trace.info() << " " << argv[ i ];
140 trace.info() << endl;
141
142 bool res = testDGtalBIGINTEGER() && testBIGINTEGERSpace(); // && ... other tests
143 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
144 trace.endBlock();
145 return res ? 0 : 1;
146}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
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 82 of file testDGtalGMP.cpp.

83{
84 unsigned int nbok = 0;
85 unsigned int nb = 0;
86
87 trace.beginBlock ( "BIGINTEGER Space test..." );
88
89 //This space is weird...
90 typedef SpaceND<2, DGtal::BigInteger> Space2;
91 typedef Space2::Point Point;
92 typedef Space2::Point::Coordinate Coordinate;
94
95 DGtal::BigInteger a, b, c;
96
97 a = 1234;
98 b = "-5678";
99 Point p(a,b);
100
102
103 // Construct the Freeman chain
104 std::stringstream ss(stringstream::in | stringstream::out);
105 ss << "31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
106 Contour theContour( ss );
107
108 Point p1( 0, 0 );
109 Point p2( 31, 31 );
110
111 trace.info() <<"p2.norm()= "<< p2.norm()<<endl;
112
113 Domain domain( p1, p2 );
114 Board2D aBoard;
115 aBoard << SetMode( domain.className(), "Grid" )
116 << domain
117 << theContour;
118
119 aBoard.saveSVG("testgmpcontour.svg");
120
121
122 nbok += true ? 1 : 0;
123 nb++;
124 trace.info() << "(" << nbok << "/" << nb << ") "
125 << "true == true" << std::endl;
126 trace.endBlock();
127
128 return nbok == nb;
129}
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:1012
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition: BasicTypes.h:79
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
MyPointD Point
Definition: testClone2.cpp:383
FreemanChain< int > Contour
Domain domain
HyperRectDomain< Space > Domain

References DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), domain, DGtal::Trace::endBlock(), DGtal::Trace::info(), 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 testDGtalGMP.cpp.

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

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

Referenced by main().