test_correct.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #ifndef BOOST_GEOMETRY_TEST_CORRECT_HPP
  12. #define BOOST_GEOMETRY_TEST_CORRECT_HPP
  13. // Test-functionality, shared between single and multi tests
  14. #include <sstream>
  15. #include <geometry_test_common.hpp>
  16. #include <boost/geometry/algorithms/correct.hpp>
  17. #include <boost/geometry/io/wkt/read.hpp>
  18. #include <boost/geometry/io/wkt/write.hpp>
  19. #include <boost/variant/variant.hpp>
  20. template <typename Geometry>
  21. void check_geometry(Geometry const& geometry, std::string const& expected)
  22. {
  23. std::ostringstream out;
  24. out << bg::wkt_manipulator<Geometry>(geometry, false);
  25. BOOST_CHECK_EQUAL(out.str(), expected);
  26. }
  27. template <typename Geometry>
  28. void test_geometry(std::string const& wkt, std::string const& expected)
  29. {
  30. Geometry geometry;
  31. bg::read_wkt(wkt, geometry);
  32. boost::variant<Geometry> v(geometry);
  33. bg::correct(geometry);
  34. check_geometry(geometry, expected);
  35. bg::correct(v);
  36. check_geometry(v, expected);
  37. }
  38. #endif