]>
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 | ||
10 | #define BOOST_TEST_MODULE POLYGON_RECTANGLE_TEST | |
11 | #include <boost/mpl/list.hpp> | |
12 | #include <boost/test/test_case_template.hpp> | |
13 | ||
14 | #include "boost/polygon/rectangle_concept.hpp" | |
15 | #include "boost/polygon/rectangle_data.hpp" | |
16 | #include "boost/polygon/rectangle_traits.hpp" | |
17 | using namespace boost::polygon; | |
18 | ||
19 | typedef boost::mpl::list<int> test_types; | |
20 | ||
21 | template <typename interval_type> | |
22 | void CHECK_INTERVAL_EQUAL(const interval_type& i1, const interval_type& i2) { | |
23 | BOOST_CHECK_EQUAL(get(i1, LOW), get(i2, LOW)); | |
24 | BOOST_CHECK_EQUAL(get(i1, HIGH), get(i2, HIGH)); | |
25 | } | |
26 | ||
27 | template <typename rectangle_type> | |
28 | void CHECK_RECT_EQUAL(const rectangle_type& r1, const rectangle_type& r2) { | |
29 | CHECK_INTERVAL_EQUAL(horizontal(r1), horizontal(r2)); | |
30 | CHECK_INTERVAL_EQUAL(vertical(r1), vertical(r2)); | |
31 | } | |
32 | ||
33 | BOOST_AUTO_TEST_CASE_TEMPLATE(rectangle_concept_test1, T, test_types) { | |
34 | typedef rectangle_data<T> rectangle_type; | |
35 | ||
36 | rectangle_type rectangle1 = construct<rectangle_type>(-1, -1, 1, 1); | |
37 | scale_up(rectangle1, 2); | |
38 | CHECK_RECT_EQUAL(construct<rectangle_type>(-2, -2, 2, 2), rectangle1); | |
39 | ||
40 | scale_down(rectangle1, 2); | |
41 | CHECK_RECT_EQUAL(construct<rectangle_type>(-1, -1, 1, 1), rectangle1); | |
42 | } |