8 #ifndef BOX_UNIT_TESTS_HPP_
9 #define BOX_UNIT_TESTS_HPP_
11 BOOST_AUTO_TEST_SUITE( box_test )
13 BOOST_AUTO_TEST_CASE( box_use)
15 std::cout <<
"Box unit test start" <<
"\n";
19 float spacing[2] = {0.1,0.1};
24 BOOST_REQUIRE_CLOSE(sp.getLow(0),1.0,0.0001);
25 BOOST_REQUIRE_CLOSE(sp.getLow(1),1.0,0.0001);
27 BOOST_REQUIRE_CLOSE(sp.getHigh(0),2.1,0.0001);
28 BOOST_REQUIRE_CLOSE(sp.getHigh(1),3.1,0.0001);
40 BOOST_REQUIRE_EQUAL(box1.getLow(0),0.1f);
41 BOOST_REQUIRE_EQUAL(box1.getLow(1),0.2f);
42 BOOST_REQUIRE_EQUAL(box1.getLow(2),0.3f);
44 BOOST_REQUIRE_EQUAL(box1.getHigh(0),2.0f);
45 BOOST_REQUIRE_EQUAL(box1.getHigh(1),2.1f);
46 BOOST_REQUIRE_EQUAL(box1.getHigh(2),2.2f);
64 BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.0f,0.0001);
65 BOOST_REQUIRE_CLOSE(box1.getHigh(1),0.1f,0.0001);
66 BOOST_REQUIRE_CLOSE(box1.getHigh(2),1.0f,0.0001);
79 BOOST_REQUIRE_CLOSE(box1.getLow(0),-0.4,0.0001);
80 BOOST_REQUIRE_CLOSE(box1.getLow(1),-0.4,0.0001);
81 BOOST_REQUIRE_CLOSE(box1.getLow(2),-0.4,0.0001);
83 BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.5,0.0001);
84 BOOST_REQUIRE_CLOSE(box1.getHigh(1),1.7,0.0001);
85 BOOST_REQUIRE_CLOSE(box1.getHigh(2),2.0,0.0001);
98 BOOST_REQUIRE_CLOSE(box1.getLow(0),0.1,0.0001);
99 BOOST_REQUIRE_CLOSE(box1.getLow(1),0.2,0.0001);
100 BOOST_REQUIRE_CLOSE(box1.getLow(2),0.3,0.0001);
102 BOOST_REQUIRE_CLOSE(box1.getHigh(0),2.0,0.0001);
103 BOOST_REQUIRE_CLOSE(box1.getHigh(1),2.3,0.0001);
104 BOOST_REQUIRE_CLOSE(box1.getHigh(2),2.7,0.0001);
116 BOOST_REQUIRE_CLOSE(box1.getLow(0),0.1001,0.001);
117 BOOST_REQUIRE_CLOSE(box1.getLow(1),0.2002,0.001);
118 BOOST_REQUIRE_CLOSE(box1.getLow(2),0.3003,0.001);
120 BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.001,0.00001);
121 BOOST_REQUIRE_CLOSE(box1.getHigh(1),1.1011,0.00001);
122 BOOST_REQUIRE_CLOSE(box1.getHigh(2),1.3013,0.00001);
125 BOOST_REQUIRE_CLOSE(box1.getHigh(0) - box1.getLow(0), 1.001 * 0.9 ,0.001);
126 BOOST_REQUIRE_CLOSE(box1.getHigh(1) - box1.getLow(1), 1.001 * 0.9, 0.001);
127 BOOST_REQUIRE_CLOSE(box1.getHigh(2) - box1.getLow(2), 1.001 * 1.0, 0.001);
139 BOOST_REQUIRE_CLOSE(box1.getLow(0),0.1,0.0001);
140 BOOST_REQUIRE_CLOSE(box1.getLow(1),0.2,0.0001);
141 BOOST_REQUIRE_CLOSE(box1.getLow(2),0.3,0.0001);
143 BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.0009,0.00001);
144 BOOST_REQUIRE_CLOSE(box1.getHigh(1),1.1009,0.00001);
145 BOOST_REQUIRE_CLOSE(box1.getHigh(2),1.301,0.00001);
148 BOOST_REQUIRE_CLOSE(box1.getHigh(0) - box1.getLow(0), 1.001 * 0.9 ,0.00001);
149 BOOST_REQUIRE_CLOSE(box1.getHigh(1) - box1.getLow(1), 1.001 * 0.9, 0.00001);
150 BOOST_REQUIRE_CLOSE(box1.getHigh(2) - box1.getLow(2), 1.001 * 1.0, 0.00001);
163 BOOST_REQUIRE_CLOSE(box1.
getLow(0),0.0,0.0001);
164 BOOST_REQUIRE_CLOSE(box1.
getLow(1),0.3,0.0001);
165 BOOST_REQUIRE_CLOSE(box1.
getLow(2),0.3,0.0001);
167 BOOST_REQUIRE_CLOSE(box1.
getHigh(0),0.9,0.0001);
168 BOOST_REQUIRE_CLOSE(box1.
getHigh(1),1.0,0.0001);
169 BOOST_REQUIRE_CLOSE(box1.
getHigh(2),1.1,0.0001);
173 box1 -= box1.getP2();
175 BOOST_REQUIRE_CLOSE(box1.
getLow(0),-0.9,0.0001);
176 BOOST_REQUIRE_CLOSE(box1.
getLow(1),-0.7,0.0001);
177 BOOST_REQUIRE_CLOSE(box1.
getLow(2),-0.8,0.0001);
179 BOOST_REQUIRE_CLOSE(box1.
getHigh(0),0.0,0.0001);
180 BOOST_REQUIRE_CLOSE(box1.
getHigh(1),0.0,0.0001);
181 BOOST_REQUIRE_CLOSE(box1.
getHigh(2),0.0,0.0001);
183 box1 -= box1.getP1();
185 BOOST_REQUIRE_CLOSE(box1.
getLow(0),0.0,0.0001);
186 BOOST_REQUIRE_CLOSE(box1.
getLow(1),0.0,0.0001);
187 BOOST_REQUIRE_CLOSE(box1.
getLow(2),0.0,0.0001);
189 BOOST_REQUIRE_CLOSE(box1.
getHigh(0),0.9,0.0001);
190 BOOST_REQUIRE_CLOSE(box1.
getHigh(1),0.7,0.0001);
191 BOOST_REQUIRE_CLOSE(box1.
getHigh(2),0.8,0.0001);
203 BOOST_REQUIRE_EQUAL(val,
false);
205 BOOST_REQUIRE_EQUAL(invalid2.isValid(),
false);
207 BOOST_REQUIRE_EQUAL(invalid3.isValid(),
false);
208 val = valid1.isValid();
209 BOOST_REQUIRE_EQUAL(valid1.isValid(),
true);
210 val = valid2.isValid();
211 BOOST_REQUIRE_EQUAL(valid2.isValid(),
true);
224 BOOST_REQUIRE_CLOSE(result.
getHigh(0),4.2,0.0001);
225 BOOST_REQUIRE_CLOSE(result.
getHigh(1),5.2,0.0001);
227 BOOST_REQUIRE_CLOSE(result.
getLow(0),1.5,0.0001);
228 BOOST_REQUIRE_CLOSE(result.
getLow(1),2.4,0.0001);
241 BOOST_REQUIRE_EQUAL(box.isInsideNP(p1),
true);
242 BOOST_REQUIRE_EQUAL(box.isInsideNP(p2),
true);
243 BOOST_REQUIRE_EQUAL(box.isInsideNP(p3),
false);
251 bool ret = (b1 == b2);
253 BOOST_REQUIRE_EQUAL(ret,
true);
255 std::cout <<
"Box unit test stop" <<
"\n";
258 BOOST_AUTO_TEST_SUITE_END()
void magnify_fix_P1(T mg)
Magnify the box by a factor keeping fix the point P1.
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
bool isValid() const
Check if the Box is a valid box P2 >= P1.
void magnify(T mg)
Magnify the box.
T getHigh(int i) const
get the high interval of the box
This class implement the point shape in an N-dimensional space.
void enclose(Box< dim, T > &en)
Refine the box to enclose the given box and itself.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
This class represent an N-dimensional box.
void enlarge_fix_P1(Box< dim, S > &gh)
Enlarge the box with ghost margin keeping fix the point P1.
void contained(const Box< dim, T > &en, const bool reset_p1=true)
Refine the box to be contained in the given box and itself.