point_type.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/variant.hpp>
  15. #include <boost/geometry/geometries/adapted/c_array.hpp>
  16. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  17. #include <boost/geometry/geometries/register/linestring.hpp>
  18. #include <boost/variant/variant.hpp>
  19. #include <vector>
  20. #include <deque>
  21. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  22. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  23. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
  24. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
  25. template <typename G, typename Expected>
  26. void test_geometry()
  27. {
  28. BOOST_CHECK_EQUAL(typeid(typename bg::point_type<G>::type).name(),
  29. typeid(Expected).name());
  30. static const bool is_same = boost::is_same<typename bg::point_type<G>::type, Expected>::value;
  31. BOOST_CHECK(is_same);
  32. }
  33. template <typename P>
  34. void test_all()
  35. {
  36. test_geometry<P, P>();
  37. test_geometry<P const, P>();
  38. test_geometry<P*, P>();
  39. test_geometry<P&, P>();
  40. test_geometry<P*&, P>();
  41. test_geometry<const P *, P>();
  42. test_geometry<bg::model::linestring<P> , P>();
  43. test_geometry<bg::model::linestring<P> *&, P>();
  44. test_geometry<bg::model::ring<P> , P>();
  45. test_geometry<bg::model::polygon<P> , P>();
  46. test_geometry<bg::model::box<P> , P>();
  47. test_geometry<bg::model::segment<P> , P>();
  48. test_geometry<bg::model::referring_segment<P const> , P>();
  49. test_geometry<std::vector<P>, P>();
  50. test_geometry<std::deque<P>, P>();
  51. }
  52. int test_main(int, char* [])
  53. {
  54. test_geometry<int[2], int[2]>();
  55. test_geometry<float[2], float[2]>();
  56. test_geometry<double[2], double[2]>();
  57. test_geometry<int[3], int[3]>();
  58. test_geometry<float[3], float[3]>();
  59. test_geometry<double[3], double[3]>();
  60. test_geometry<boost::tuple<double, double>,
  61. boost::tuple<double, double> >();
  62. test_geometry<boost::tuple<double, double, double>,
  63. boost::tuple<double, double, double> >();
  64. test_geometry<boost::variant<bg::model::box<boost::tuple<double, double> > >,
  65. boost::tuple<double, double> >();
  66. test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
  67. test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
  68. test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
  69. return 0;
  70. }