test_reverse.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2010-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_REVERSE_HPP
  8. #define BOOST_GEOMETRY_TEST_REVERSE_HPP
  9. // Test-functionality, shared between single and multi tests
  10. #include <geometry_test_common.hpp>
  11. #include <boost/geometry/algorithms/reverse.hpp>
  12. #include <boost/geometry/io/wkt/wkt.hpp>
  13. #include <boost/variant/variant.hpp>
  14. template <typename Geometry>
  15. void check_geometry(Geometry& geometry, std::string const& wkt, std::string const& expected)
  16. {
  17. bg::reverse(geometry);
  18. std::ostringstream out;
  19. out << bg::wkt(geometry);
  20. BOOST_CHECK_MESSAGE(out.str() == expected,
  21. "reverse: " << wkt
  22. << " expected " << expected
  23. << " got " << out.str());
  24. }
  25. template <typename Geometry>
  26. void test_geometry(std::string const& wkt, std::string const& expected)
  27. {
  28. Geometry geometry;
  29. bg::read_wkt(wkt, geometry);
  30. boost::variant<Geometry> v(geometry);
  31. check_geometry(geometry, wkt, expected);
  32. check_geometry(v, wkt, expected);
  33. }
  34. #endif