DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleCatch.cpp
Go to the documentation of this file.
1
16
36
38
#include <iostream>
39
#include "DGtal/helpers/StdDefs.h"
40
#include "DGtal/base/Common.h"
41
42
#include <vector>
43
#include <list>
44
#include <set>
45
47
#include "DGtalCatch.h"
49
51
52
using namespace
std
;
53
using namespace
DGtal
;
54
55
57
TEST_CASE
(
"Point Vector Unit tests"
)
58
{
59
60
//Global variables and init for this test case
61
typedef
PointVector<4, DGtal::int32_t>
Point
;
62
typedef
PointVector<4, double>
RealPoint
;
63
64
DGtal::int32_t
t1[] = {1,2,3,4};
65
DGtal::int32_t
t2[]= {5,4,3,2};
66
double
t3[]= {1.0,-1.0,2.0,-2.0};
67
68
Point
p1( t1 );
69
Point
p1bis( t1 );
70
Point
p2( t2 );
71
RealPoint
p3(t3);
72
73
SECTION
(
"Comparisons"
)
74
{
75
REQUIRE
( (p1 == p1bis) );
76
REQUIRE
( p1 < p2 );
77
}
78
79
SECTION
(
"Min/Max of vector components"
)
80
{
81
REQUIRE
( (p3.
max
() == 2.0) );
82
REQUIRE
( (p3.
min
() == -2.0) );
83
REQUIRE
( (*p3.
maxElement
() == 2.0) );
84
REQUIRE
( (*p3.
minElement
() == -2.0) );
85
}
86
SECTION
(
"Arithmetical Operators"
)
87
{
88
REQUIRE
( ((p1 + p2) ==
Point
(6,6,6,6)) );
89
REQUIRE
( ((p1 - p2) ==
Point
(-4,-2,0,2)) );
90
REQUIRE
( ((p1*2) ==
Point
(2,4,6,8)) );
91
REQUIRE
( ((2*p1) ==
Point
(2,4,6,8)) );
92
REQUIRE
( ((-p1) ==
Point
(-1,-2,-3,-4)) );
93
REQUIRE
( (p1.inf(p2) ==
Point
(1,2,3,2)) );
94
REQUIRE
( (p1.sup(p2) ==
Point
(5,4,3,4)) );
95
REQUIRE
( (p1.dot(p2) == 30) );
96
}
97
98
}
99
100
101
103
TEMPLATE_TEST_CASE(
"STL Container test"
,
"Description"
,
104
std::list<int>, std::vector<int>, std::set<int>)
105
{
106
TestType defaultConstructed;
107
108
SECTION
(
"Size of the default constructed container"
)
109
{
110
REQUIRE
( ( defaultConstructed.size() == 0 ) );
111
}
112
113
//Adding a value
114
defaultConstructed.insert( defaultConstructed.begin(), 5 );
115
116
SECTION
(
"Size after one insert"
)
117
{
118
REQUIRE
( ( defaultConstructed.size() == 1 ) );
119
}
120
}
121
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
DGtal::PointVector::max
Component max() const
DGtal::PointVector::maxElement
Iterator maxElement()
DGtal::PointVector::min
Component min() const
DGtal::PointVector::minElement
Iterator minElement()
DGtal::Point
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::int32_t
std::int32_t int32_t
signed 32-bit integer.
Definition
BasicTypes.h:71
std
STL namespace.
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
SECTION
SECTION("Testing constant forward iterators")
Definition
testSimpleRandomAccessRangeFromPoint.cpp:66
REQUIRE
REQUIRE(domain.isInside(aPoint))
RealPoint
PointVector< 3, double > RealPoint
Definition
testTriangulatedSurface.cpp:51
examples
doc-examples
exampleCatch.cpp
Generated on
for DGtal by
1.18.0