1 // Boost.Polygon library polygon_rectangle_test.cpp file
3 // Copyright Andrii Sydorchuk 2014.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org for updates, documentation, and revision history.
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/polygon/rectangle_concept.hpp>
12 #include <boost/polygon/rectangle_data.hpp>
13 #include <boost/polygon/rectangle_traits.hpp>
15 using namespace boost::polygon
;
17 template <typename interval_type
>
18 void CHECK_INTERVAL_EQUAL(const interval_type
& i1
, const interval_type
& i2
) {
19 BOOST_TEST_EQ(get(i1
, LOW
), get(i2
, LOW
));
20 BOOST_TEST_EQ(get(i1
, HIGH
), get(i2
, HIGH
));
23 template <typename rectangle_type
>
24 void CHECK_RECT_EQUAL(const rectangle_type
& r1
, const rectangle_type
& r2
) {
25 CHECK_INTERVAL_EQUAL(horizontal(r1
), horizontal(r2
));
26 CHECK_INTERVAL_EQUAL(vertical(r1
), vertical(r2
));
29 void rectangle_concept_test1()
31 typedef rectangle_data
<int> rectangle_type
;
33 rectangle_type rectangle1
= construct
<rectangle_type
>(-1, -1, 1, 1);
34 scale_up(rectangle1
, 2);
35 CHECK_RECT_EQUAL(construct
<rectangle_type
>(-2, -2, 2, 2), rectangle1
);
37 scale_down(rectangle1
, 2);
38 CHECK_RECT_EQUAL(construct
<rectangle_type
>(-1, -1, 1, 1), rectangle1
);
43 rectangle_concept_test1();
44 return boost::report_errors();