adapted.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2015 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. #include <deque>
  8. #include <vector>
  9. #include <geometry_test_common.hpp>
  10. #include <boost/core/ignore_unused.hpp>
  11. #include <boost/geometry/geometries/geometries.hpp>
  12. #include <boost/geometry/geometries/adapted/c_array.hpp>
  13. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  14. #include <test_common/test_point.hpp>
  15. #define BOOST_GEOMETRY_TEST_RING
  16. #if defined(BOOST_GEOMETRY_TEST_RING)
  17. #include <boost/geometry/geometries/register/ring.hpp>
  18. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  19. BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::vector)
  20. BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
  21. #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
  22. #include <boost/geometry/geometries/register/multi_point.hpp>
  23. #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
  24. BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector)
  25. BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
  26. #else
  27. #include <boost/geometry/geometries/register/linestring.hpp>
  28. #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
  29. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
  30. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
  31. #endif
  32. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  33. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  34. // ----------------------------------------------------------------------------
  35. template <typename G>
  36. void test_geometry(G const& geometry, std::size_t expected_size = 0)
  37. {
  38. #if defined(BOOST_GEOMETRY_TEST_RING)
  39. BOOST_CONCEPT_ASSERT( (bg::concepts::ConstRing<G>) );
  40. #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
  41. BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiPoint<G>) );
  42. #else
  43. BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring<G>) );
  44. #endif
  45. typedef typename bg::point_type<G>::type P;
  46. typedef typename bg::coordinate_type<P>::type C;
  47. boost::ignore_unused<P, C>();
  48. // Check range-like behaviour
  49. BOOST_CHECK_EQUAL(boost::size(geometry), expected_size);
  50. }
  51. template <typename P>
  52. void test_all()
  53. {
  54. test_geometry(std::vector<P>());
  55. test_geometry(std::deque<P>());
  56. //test_geometry(std::list<P>());
  57. /***
  58. double vertices[][3] = {
  59. {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1},
  60. {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}
  61. };
  62. test_geometry(vertices, 8);
  63. ***/
  64. }
  65. int test_main(int, char* [])
  66. {
  67. test_all<test::test_point>();
  68. test_all<boost::tuple<float, float> >();
  69. test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
  70. test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
  71. test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
  72. test_all<bg::model::point<long double, 2, bg::cs::cartesian> >();
  73. test_all<boost::tuple<float, float, float> >();
  74. test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
  75. test_all<bg::model::point<long double, 3, bg::cs::cartesian> >();
  76. test_all<boost::tuple<float, float, float, float, float> >();
  77. return 0;
  78. }