DGtal  0.9.3
Functions
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")
 
 TEMPLATE_TEST_CASE_3 ("STL Container test", "Description", T, std::list< int >, std::vector< int >, std::set< int >)
 

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_3()

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

[exampleCatch-example1]

[exampleCatch-example2]

Examples:
doc-examples/exampleCatch.cpp.

Definition at line 104 of file exampleCatch.cpp.

References REQUIRE(), and SECTION().

106 {
107  T 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 }
REQUIRE(domain.isInside(aPoint))
SECTION("Testing constant forward iterators")

◆ TEST_CASE()

TEST_CASE ( "Point Vector Unit tests"  )

[exampleCatch-example1]

Definition at line 58 of file exampleCatch.cpp.

References REQUIRE(), and SECTION().

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.
Definition: PointVector.h:141
REQUIRE(domain.isInside(aPoint))
MyPointD Point
Definition: testClone2.cpp:383
Space::RealPoint RealPoint
Definition: StdDefs.h:97
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
SECTION("Testing constant forward iterators")