DGtal 1.4.0
Loading...
Searching...
No Matches
exampleCatch.cpp File Reference
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include <vector>
#include <list>
#include <set>
#include "DGtalCatch.h"
Include dependency graph for exampleCatch.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Point Vector Unit tests")
 [exampleCatch-example1]
 
 TEMPLATE_TEST_CASE ("STL Container test", "Description", std::list< int >, std::vector< int >, std::set< int >)
 [exampleCatch-example1]
 

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 Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2015/09/20

An example file named exampleCatch.

This file is part of the DGtal library.

Definition in file exampleCatch.cpp.

Function Documentation

◆ TEMPLATE_TEST_CASE()

TEMPLATE_TEST_CASE ( "STL Container test" ,
"Description" ,
std::list< int > ,
std::vector< int > ,
std::set< int >  )

[exampleCatch-example1]

[exampleCatch-example2]

Definition at line 104 of file exampleCatch.cpp.

106{
107 TestType defaultConstructed;
108
109 SECTION("Size of the default constructed container")
110 {
111 REQUIRE( ( defaultConstructed.size() == 0 ) );
112 }
113
114 //Adding a value
115 defaultConstructed.insert( defaultConstructed.begin(), 5 );
116
117 SECTION("Size after one insert")
118 {
119 REQUIRE( ( defaultConstructed.size() == 1 ) );
120 }
121}
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References REQUIRE(), and SECTION().

◆ TEST_CASE()

TEST_CASE ( "Point Vector Unit tests" )

[exampleCatch-example1]

Definition at line 58 of file exampleCatch.cpp.

59{
60
61 //Global variables and init for this test case
64
65 DGtal::int32_t t1[] = {1,2,3,4};
66 DGtal::int32_t t2[]= {5,4,3,2};
67 double t3[]= {1.0,-1.0,2.0,-2.0};
68
69 Point p1( t1 );
70 Point p1bis( t1 );
71 Point p2( t2 );
72 RealPoint p3(t3);
73
74 SECTION("Comparisons")
75 {
76 REQUIRE( (p1 == p1bis) );
77 REQUIRE( p1 < p2 );
78 }
79
80 SECTION("Min/Max of vector components")
81 {
82 REQUIRE( (p3.max() == 2.0) );
83 REQUIRE( (p3.min() == -2.0) );
84 REQUIRE( (*p3.maxElement() == 2.0) );
85 REQUIRE( (*p3.minElement() == -2.0) );
86 }
87 SECTION("Arithmetical Operators")
88 {
89 REQUIRE( ((p1 + p2) == Point(6,6,6,6)) );
90 REQUIRE( ((p1 - p2) == Point(-4,-2,0,2)) );
91 REQUIRE( ((p1*2) == Point(2,4,6,8)) );
92 REQUIRE( ((2*p1) == Point(2,4,6,8)) );
93 REQUIRE( ((-p1) == Point(-1,-2,-3,-4)) );
94 REQUIRE( (p1.inf(p2) == Point(1,2,3,2)) );
95 REQUIRE( (p1.sup(p2) == Point(5,4,3,4)) );
96 REQUIRE( (p1.dot(p2) == 30) );
97 }
98
99}
Aim: Implements basic operations that will be used in Point and Vector classes.
boost::int32_t int32_t
signed 32-bit integer.
Definition BasicTypes.h:72
MyPointD Point
PointVector< 3, double > RealPoint

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::max(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::maxElement(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::min(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::minElement(), REQUIRE(), and SECTION().