]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Polygon library polygon_rectangle_test.cpp file |
2 | ||
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) | |
7 | ||
8 | // See http://www.boost.org for updates, documentation, and revision history. | |
9 | ||
92f5a8d4 TL |
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> | |
7c673cae | 14 | |
7c673cae FG |
15 | using namespace boost::polygon; |
16 | ||
7c673cae FG |
17 | template <typename interval_type> |
18 | void CHECK_INTERVAL_EQUAL(const interval_type& i1, const interval_type& i2) { | |
92f5a8d4 TL |
19 | BOOST_TEST_EQ(get(i1, LOW), get(i2, LOW)); |
20 | BOOST_TEST_EQ(get(i1, HIGH), get(i2, HIGH)); | |
7c673cae FG |
21 | } |
22 | ||
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)); | |
27 | } | |
28 | ||
92f5a8d4 TL |
29 | void rectangle_concept_test1() |
30 | { | |
31 | typedef rectangle_data<int> rectangle_type; | |
7c673cae FG |
32 | |
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); | |
36 | ||
37 | scale_down(rectangle1, 2); | |
38 | CHECK_RECT_EQUAL(construct<rectangle_type>(-1, -1, 1, 1), rectangle1); | |
39 | } | |
92f5a8d4 TL |
40 | |
41 | int main() | |
42 | { | |
43 | rectangle_concept_test1(); | |
44 | return boost::report_errors(); | |
45 | } |