tag.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // This file was modified by Oracle on 2014.
  5. // Modifications copyright (c) 2014 Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #include <geometry_test_common.hpp>
  11. #include <boost/type_traits/is_same.hpp>
  12. #include <boost/geometry/core/tag.hpp>
  13. #include <boost/geometry/geometries/geometries.hpp>
  14. #include <boost/geometry/geometries/adapted/c_array.hpp>
  15. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  16. #include <boost/geometry/geometries/register/linestring.hpp>
  17. #include <vector>
  18. #include <deque>
  19. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  20. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  21. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
  22. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
  23. template <typename G, typename Expected>
  24. void test_geometry()
  25. {
  26. BOOST_CHECK_EQUAL(typeid(typename bg::tag<G>::type).name(),
  27. typeid(Expected).name());
  28. static const bool is_same = boost::is_same<typename bg::tag<G>::type, Expected>::value;
  29. BOOST_CHECK(is_same);
  30. }
  31. template <typename P, size_t D>
  32. void test_all()
  33. {
  34. test_geometry<P, bg::point_tag>();
  35. test_geometry<P const, bg::point_tag>();
  36. test_geometry<P*, bg::point_tag>();
  37. test_geometry<P&, bg::point_tag>();
  38. test_geometry<P*&, bg::point_tag>();
  39. test_geometry<const P *, bg::point_tag>();
  40. test_geometry<bg::model::linestring<P> , bg::linestring_tag>();
  41. test_geometry<bg::model::linestring<P> *&, bg::linestring_tag>();
  42. test_geometry<bg::model::ring<P> , bg::ring_tag>();
  43. test_geometry<bg::model::polygon<P> , bg::polygon_tag>();
  44. test_geometry<bg::model::box<P> , bg::box_tag>();
  45. test_geometry<bg::model::segment<P> , bg::segment_tag>();
  46. test_geometry<bg::model::referring_segment<P const> , bg::segment_tag>();
  47. test_geometry<std::vector<P>, bg::linestring_tag>();
  48. test_geometry<std::deque<P>, bg::linestring_tag>();
  49. }
  50. int test_main(int, char* [])
  51. {
  52. test_geometry<int[2], bg::point_tag>();
  53. test_geometry<float[2], bg::point_tag>();
  54. test_geometry<double[2], bg::point_tag>();
  55. test_geometry<int[3], bg::point_tag>();
  56. test_geometry<float[3], bg::point_tag>();
  57. test_geometry<double[3], bg::point_tag>();
  58. test_geometry<boost::tuple<double, double>, bg::point_tag>();
  59. test_geometry<boost::tuple<double, double, double>, bg::point_tag>();
  60. test_all<bg::model::point<int, 2, bg::cs::cartesian>, 2 >();
  61. test_all<bg::model::point<float, 2, bg::cs::cartesian>, 2 >();
  62. test_all<bg::model::point<double, 2, bg::cs::cartesian>, 2 >();
  63. return 0;
  64. }