test_expand.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_TEST_EXPAND_HPP
  8. #define BOOST_GEOMETRY_TEST_EXPAND_HPP
  9. #include <geometry_test_common.hpp>
  10. #include <boost/geometry/algorithms/expand.hpp>
  11. #include <boost/geometry/strategies/strategies.hpp>
  12. #include <boost/geometry/io/wkt/read.hpp>
  13. #include <boost/geometry/algorithms/assign.hpp>
  14. #include <boost/geometry/io/dsv/write.hpp>
  15. #include <boost/variant/variant.hpp>
  16. template <typename Box>
  17. inline std::string to_dsv(const Box& box)
  18. {
  19. std::ostringstream out;
  20. out << bg::dsv(box, ",", "(", ")", ",", "", "");
  21. return out.str();
  22. }
  23. template <typename Geometry, typename Box>
  24. void test_expand(Box& box,
  25. std::string const& wkt,
  26. std::string const& expected)
  27. {
  28. Geometry geometry;
  29. bg::read_wkt(wkt, geometry);
  30. bg::expand(box, geometry);
  31. BOOST_CHECK_EQUAL(to_dsv(box), expected);
  32. #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
  33. bg::expand(box, boost::variant<Geometry>(geometry));
  34. BOOST_CHECK_EQUAL(to_dsv(box), expected);
  35. #endif
  36. }
  37. template <typename Geometry, typename Box>
  38. void test_expand_other_strategy(Box& box,
  39. std::string const& wkt,
  40. std::string const& expected)
  41. {
  42. Geometry geometry;
  43. bg::read_wkt(wkt, geometry);
  44. bg::expand(box, geometry);
  45. BOOST_CHECK_EQUAL(to_dsv(box), expected);
  46. #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
  47. bg::expand(box, boost::variant<Geometry>(geometry));
  48. BOOST_CHECK_EQUAL(to_dsv(box), expected);
  49. #endif
  50. }
  51. #endif