DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
doc-examples/exampleCatch.cpp
DGtal/Catch examples
See also
Unit test in DGtal using Catch
#include <iostream>
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include <vector>
#include <list>
#include <set>
#include "DGtalCatch.h"
using namespace
std
;
using namespace
DGtal
;
TEST_CASE
(
"Point Vector Unit tests"
)
{
//Global variables and init for this test case
typedef
PointVector<4, DGtal::int32_t>
Point
;
typedef
PointVector<4, double>
RealPoint
;
DGtal::int32_t
t1[] = {1,2,3,4};
DGtal::int32_t
t2[]= {5,4,3,2};
double
t3[]= {1.0,-1.0,2.0,-2.0};
Point
p1( t1 );
Point
p1bis( t1 );
Point
p2( t2 );
RealPoint
p3(t3);
SECTION
(
"Comparisons"
)
{
REQUIRE
( (p1 == p1bis) );
REQUIRE
( p1 < p2 );
}
SECTION
(
"Min/Max of vector components"
)
{
REQUIRE
( (p3.max() == 2.0) );
REQUIRE
( (p3.min() == -2.0) );
REQUIRE
( (*p3.maxElement() == 2.0) );
REQUIRE
( (*p3.minElement() == -2.0) );
}
SECTION
(
"Arithmetical Operators"
)
{
REQUIRE
( ((p1 + p2) ==
Point
(6,6,6,6)) );
REQUIRE
( ((p1 - p2) ==
Point
(-4,-2,0,2)) );
REQUIRE
( ((p1*2) ==
Point
(2,4,6,8)) );
REQUIRE
( ((2*p1) ==
Point
(2,4,6,8)) );
REQUIRE
( ((-p1) ==
Point
(-1,-2,-3,-4)) );
REQUIRE
( (p1.inf(p2) ==
Point
(1,2,3,2)) );
REQUIRE
( (p1.sup(p2) ==
Point
(5,4,3,4)) );
REQUIRE
( (p1.dot(p2) == 30) );
}
}
TEMPLATE_TEST_CASE(
"STL Container test"
,
"Description"
,
std::list<int>, std::vector<int>, std::set<int>)
{
TestType defaultConstructed;
SECTION
(
"Size of the default constructed container"
)
{
REQUIRE
( ( defaultConstructed.size() == 0 ) );
}
//Adding a value
defaultConstructed.insert( defaultConstructed.begin(), 5 );
SECTION
(
"Size after one insert"
)
{
REQUIRE
( ( defaultConstructed.size() == 1 ) );
}
}
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
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.
Point
MyPointD Point
Definition
testClone2.cpp:381
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
Generated on
for DGtal by
1.18.0