Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
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
52using namespace std;
53using namespace DGtal;
54
55
57TEST_CASE( "Point Vector Unit tests" )
58{
59
60 //Global variables and init for this test case
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
103TEMPLATE_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
122
123
Aim: Implements basic operations that will be used in Point and Vector classes.
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.
std::int32_t int32_t
signed 32-bit integer.
Definition BasicTypes.h:71
STL namespace.
MyPointD Point
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))
PointVector< 3, double > RealPoint