DGtal  1.5.beta
exampleCatch.cpp
Go to the documentation of this file.
1 
38 #include <iostream>
39 #include "ConfigExamples.h"
40 #include "DGtal/helpers/StdDefs.h"
41 #include "DGtal/base/Common.h"
42 
43 #include <vector>
44 #include <list>
45 #include <set>
46 
48 #include "DGtalCatch.h"
50 
52 
53 using namespace std;
54 using namespace DGtal;
55 
56 
58 TEST_CASE( "Point Vector Unit tests" )
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 }
101 
102 
104 TEMPLATE_TEST_CASE("STL Container test", "Description",
105  std::list<int>, std::vector<int>, std::set<int>)
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 }
123 
124 
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Component max() const
Iterator maxElement()
Component min() const
Iterator minElement()
TEMPLATE_TEST_CASE("STL Container test", "Description", std::list< int >, std::vector< int >, std::set< int >)
[exampleCatch-example1]
TEST_CASE("Point Vector Unit tests")
[exampleCatch-example1]
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
MyPointD Point
Definition: testClone2.cpp:383
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))
PointVector< 3, double > RealPoint