buffer.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2019 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  6. // This file was modified by Oracle on 2016.
  7. // Modifications copyright (c) 2016, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #include <boost/variant/variant.hpp>
  15. #include "geometry_test_common.hpp"
  16. #include <boost/geometry/algorithms/buffer.hpp>
  17. #include <boost/geometry/algorithms/equals.hpp>
  18. #include <boost/geometry/core/coordinate_type.hpp>
  19. #include <boost/geometry/strategies/strategies.hpp>
  20. #include <boost/geometry/geometries/point.hpp>
  21. #include <boost/geometry/geometries/box.hpp>
  22. #include "test_common/test_point.hpp"
  23. template <typename P>
  24. void test_all()
  25. {
  26. typedef typename bg::coordinate_type<P>::type coordinate_type;
  27. P p1(0, 0);
  28. P p2(2, 2);
  29. typedef bg::model::box<P> box_type;
  30. box_type b1(p1, p2);
  31. box_type b2;
  32. bg::buffer(b1, b2, coordinate_type(2));
  33. box_type expected(P(-2, -2), P(4, 4));
  34. BOOST_CHECK(bg::equals(b2, expected));
  35. boost::variant<box_type> v(b1);
  36. bg::buffer(v, b2, coordinate_type(2));
  37. BOOST_CHECK(bg::equals(b2, expected));
  38. }
  39. int test_main(int, char* [])
  40. {
  41. BoostGeometryWriteTestConfiguration();
  42. test_all<bg::model::point<default_test_type, 2, bg::cs::cartesian> >();
  43. #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
  44. test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
  45. test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
  46. #endif
  47. #ifdef HAVE_TTMATH
  48. test_all<bg::model::point<ttmath_big, 2, bg::cs::cartesian> >();
  49. #endif
  50. return 0;
  51. }