polygon_rectangle_test.cpp 1.4 KB

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