-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestNode.cpp
99 lines (85 loc) · 2.47 KB
/
TestNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* @file TestNode.cpp
* @brief Unit test of Node class
* @author cromod
* @date july 2015
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE TestNode
#include <boost/test/unit_test.hpp>
#include <iostream>
#include "Node.hpp"
#include "Exception.hpp"
using namespace Cromod::GeomAPI ;
using namespace Cromod::Tools ;
using namespace std ;
BOOST_AUTO_TEST_CASE( BasicTests )
{
cout << "- Default constructor test" << endl;
try {
Node node;
}
catch(...) {
BOOST_FAIL("Default constructor failure");
}
cout << "- Copy constructor test" << endl;
try {
Node node;
Node new_node(node);
}
catch(...) {
BOOST_FAIL("Copy constructor failure");
}
cout << "- Constructor test" << endl;
Point point(0.,2);
Point pointf(0.,4);
bool near(false);
bool inside(false);
BOOST_REQUIRE_THROW(Node(pointf,near,inside), Exception);
try {
Node node(point,near,inside);
}
catch(...) {
BOOST_FAIL("Constructor failure");
}
cout << "- Equality operator test" << endl;
Node node1(point);
Node node2(point);
BOOST_REQUIRE_MESSAGE(node1==node2,"Equality operator failure");
cout << "- Inequality operator test" << endl;
Point point1(-2.,2);
Node node3(point1);
BOOST_REQUIRE_MESSAGE(node1!=node3,"Inequality operator failure");
cout << "- Copy operator test" << endl;
node2 = node3;
BOOST_REQUIRE_MESSAGE(node2==node3,"Copy operator failure");
cout << "- Node::setPosition test" << endl;
Point point2(2.,2);
BOOST_REQUIRE_THROW(node1.setPosition(pointf), Exception);
try {
node1.setPosition(point2);
}
catch(...) {
BOOST_FAIL("Node::setPosition failure");
}
cout << "- Node::getPosition test" << endl;
BOOST_REQUIRE_MESSAGE(node1.getPosition()==point2,"Node::getPosition failure");
cout << "- Node::setNearEdge test" << endl;
try {
node2.setNearEdge(true);
}
catch(...) {
BOOST_FAIL("Node::setNearEdge failure");
}
cout << "- Node::isNearEdge test" << endl;
BOOST_REQUIRE_MESSAGE(node2.isNearEdge(),"Node::isNearEdge failure");
cout << "- Node::setInside test" << endl;
try {
node2.setInside(true);
}
catch(...) {
BOOST_FAIL("Node::setInside failure");
}
cout << "- Node::isInside test" << endl;
BOOST_REQUIRE_MESSAGE(node2.isInside(),"Node::isInside failure");
}