diff options
Diffstat (limited to 'src/boost/libs/geometry/test/concepts')
18 files changed, 842 insertions, 0 deletions
diff --git a/src/boost/libs/geometry/test/concepts/Jamfile.v2 b/src/boost/libs/geometry/test/concepts/Jamfile.v2 new file mode 100644 index 00000000..dd1ad4eb --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/Jamfile.v2 @@ -0,0 +1,30 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +# Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +test-suite boost-geometry-concepts + : + [ run linestring_concept.cpp : : : : concepts_linestring_concept ] + [ compile point_array.cpp : : concepts_point_array ] + [ compile point_concept_checker.cpp : : concepts_point_concept_checker ] + [ compile point_well_formed.cpp : : concepts_point_well_formed ] + [ compile point_well_formed_non_cartesian.cpp : : concepts_point_well_formed_non_cartesian ] + [ compile point_well_formed_traits.cpp : : concepts_point_well_formed_traits ] + [ compile-fail point_geographic_custom_with_wrong_units.cpp : : concepts_point_geographic_custom_with_wrong_units ] + [ compile-fail point_geographic_with_wrong_units.cpp : : concepts_point_geographic_with_wrong_units ] + [ compile-fail point_spherical_custom_with_wrong_units.cpp : : concepts_point_spherical_custom_with_wrong_units ] + [ compile-fail point_spherical_with_wrong_units.cpp : : concepts_point_spherical_with_wrong_units ] + [ compile-fail point_with_incorrect_dimension.cpp : : concepts_point_with_incorrect_dimension ] + [ compile-fail point_without_coordinate_type.cpp : : concepts_point_without_coordinate_type ] + [ compile-fail point_without_dimension.cpp : : concepts_point_without_dimension ] + [ compile-fail point_without_getter.cpp : : concepts_point_without_getter ] + [ compile-fail point_without_setter.cpp : : concepts_point_without_setter ] +# [ run polygon_concept.cpp : : : : concepts_polygon_concept ] + ; diff --git a/src/boost/libs/geometry/test/concepts/function_asserting_a_point.hpp b/src/boost/libs/geometry/test/concepts/function_asserting_a_point.hpp new file mode 100644 index 00000000..802d1985 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/function_asserting_a_point.hpp @@ -0,0 +1,30 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) Point concept unit tests +// +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP +#define GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP + +#include <boost/concept/requires.hpp> + +#include <boost/geometry/geometries/concepts/point_concept.hpp> + +namespace bg = boost::geometry; + +namespace test +{ + template <typename P, typename CP> + void function_asserting_a_point(P& p1, const CP& p2) + { + BOOST_CONCEPT_ASSERT((bg::concepts::Point<P>)); + BOOST_CONCEPT_ASSERT((bg::concepts::ConstPoint<P>)); + + bg::get<0>(p1) = bg::get<0>(p2); + } +} + +#endif // GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP diff --git a/src/boost/libs/geometry/test/concepts/function_requiring_a_point.hpp b/src/boost/libs/geometry/test/concepts/function_requiring_a_point.hpp new file mode 100644 index 00000000..d8628e94 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/function_requiring_a_point.hpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) Point concept unit tests +// +// Copyright (c) 2008-2016 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2016 Adam Wulkiewicz, Lodz, Poland. +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP +#define GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP + +#include <boost/geometry/geometries/concepts/point_concept.hpp> + +namespace bg = boost::geometry; + +namespace test +{ + template <typename P, typename C> + inline void function_requiring_a_point(P& p1, const C& p2) + { + BOOST_CONCEPT_ASSERT((bg::concepts::Point<P>)); + BOOST_CONCEPT_ASSERT((bg::concepts::ConstPoint<C>)); + + bg::set<0>(p1, bg::get<0>(p2)); + } +} + +#endif // GEOMETRY_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP diff --git a/src/boost/libs/geometry/test/concepts/linestring_concept.cpp b/src/boost/libs/geometry/test/concepts/linestring_concept.cpp new file mode 100644 index 00000000..06f3dfcf --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/linestring_concept.cpp @@ -0,0 +1,77 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <deque> +#include <vector> + +#include <geometry_test_common.hpp> + +#include <boost/geometry/algorithms/append.hpp> +#include <boost/geometry/algorithms/clear.hpp> +#include <boost/geometry/algorithms/make.hpp> +#include <boost/geometry/core/access.hpp> +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/concepts/linestring_concept.hpp> + +#include <boost/geometry/io/dsv/write.hpp> + + +#include <test_common/test_point.hpp> +#include <test_geometries/all_custom_linestring.hpp> +#include <test_geometries/wrapped_boost_array.hpp> + + + +template <typename Geometry> +void test_linestring() +{ + BOOST_CONCEPT_ASSERT( (bg::concepts::Linestring<Geometry>) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring<Geometry>) ); + + Geometry geometry; + typedef typename bg::point_type<Geometry>::type P; + + bg::clear(geometry); + BOOST_CHECK_EQUAL(boost::size(geometry), 0u); + + bg::append(geometry, bg::make<P>(1, 2)); + BOOST_CHECK_EQUAL(boost::size(geometry), 1u); + + bg::append(geometry, bg::make<P>(3, 4)); + BOOST_CHECK_EQUAL(boost::size(geometry), 2u); + + bg::traits::resize<Geometry>::apply(geometry, 1); + BOOST_CHECK_EQUAL(boost::size(geometry), 1u); + + //std::cout << bg::dsv(geometry) << std::endl; + P p = *boost::begin(geometry); + //std::cout << bg::dsv(p) << std::endl; + BOOST_CHECK_EQUAL(bg::get<0>(p), 1); + BOOST_CHECK_EQUAL(bg::get<1>(p), 2); + + bg::clear(geometry); + BOOST_CHECK_EQUAL(boost::size(geometry), 0u); +} + +template <typename Point> +void test_all() +{ + test_linestring<bg::model::linestring<Point> >(); + test_linestring<test::wrapped_boost_array<Point, 10> >(); + test_linestring<all_custom_linestring<Point> >(); +} + +int test_main(int, char* []) +{ + test_all<bg::model::point<int, 2, bg::cs::cartesian> >(); + test_all<bg::model::point<float, 2, bg::cs::cartesian> >(); + test_all<bg::model::point<double, 2, bg::cs::cartesian> >(); + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_array.cpp b/src/boost/libs/geometry/test/concepts/point_array.cpp new file mode 100644 index 00000000..000deadc --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_array.cpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <test_common/test_point.hpp> + +#include <boost/geometry/geometries/adapted/c_array.hpp> +#include "function_requiring_a_point.hpp" + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) + + +int main() +{ + float p1[3] = { 0, 0, 0 }; + const float p2[3] = { 0, 0, 0 }; + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_concept_checker.cpp b/src/boost/libs/geometry/test/concepts/point_concept_checker.cpp new file mode 100644 index 00000000..ea51a2e9 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_concept_checker.cpp @@ -0,0 +1,76 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + +struct ro_point +{ + float x, y; +}; + + +struct rw_point +{ + float x, y; +}; + + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<ro_point> { typedef point_tag type; }; +template <> struct coordinate_type<ro_point> { typedef float type; }; +template <> struct coordinate_system<ro_point> { typedef cs::cartesian type; }; +template <> struct dimension<ro_point> { enum { value = 2 }; }; + +template <> struct access<ro_point, 0> +{ + static float get(ro_point const& p) { return p.x; } +}; + +template <> struct access<ro_point, 1> +{ + static float get(ro_point const& p) { return p.y; } +}; + + + + +template <> struct tag<rw_point> { typedef point_tag type; }; +template <> struct coordinate_type<rw_point> { typedef float type; }; +template <> struct coordinate_system<rw_point> { typedef cs::cartesian type; }; +template <> struct dimension<rw_point> { enum { value = 2 }; }; + +template <> struct access<rw_point, 0> +{ + static float get(rw_point const& p) { return p.x; } + static void set(rw_point& p, float value) { p.x = value; } +}; + +template <> struct access<rw_point, 1> +{ + static float get(rw_point const& p) { return p.y; } + static void set(rw_point& p, float value) { p.y = value; } +}; + + +}}} // namespace bg::traits + + +int main() +{ + boost::geometry::concepts::check<const ro_point>(); + boost::geometry::concepts::check<rw_point>(); +} diff --git a/src/boost/libs/geometry/test/concepts/point_geographic_custom_with_wrong_units.cpp b/src/boost/libs/geometry/test/concepts/point_geographic_custom_with_wrong_units.cpp new file mode 100644 index 00000000..5ac6e03e --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_geographic_custom_with_wrong_units.cpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include <test_geometries/custom_lon_lat_point.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + + +namespace bg = boost::geometry; + +struct dummy {}; + +int main() +{ + bg::concepts::check + < + ro_lon_lat_point<double, bg::cs::geographic<dummy> > const + >(); + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_geographic_with_wrong_units.cpp b/src/boost/libs/geometry/test/concepts/point_geographic_with_wrong_units.cpp new file mode 100644 index 00000000..9ea42318 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_geographic_with_wrong_units.cpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include <test_geometries/custom_lon_lat_point.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + + +namespace bg = boost::geometry; + + +int main() +{ + bg::concepts::check + < + bg::model::point<double, 2, bg::cs::geographic<int> > + >(); + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_spherical_custom_with_wrong_units.cpp b/src/boost/libs/geometry/test/concepts/point_spherical_custom_with_wrong_units.cpp new file mode 100644 index 00000000..4a44f323 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_spherical_custom_with_wrong_units.cpp @@ -0,0 +1,28 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include <test_geometries/custom_lon_lat_point.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + + +namespace bg = boost::geometry; + + +int main() +{ + bg::concepts::check + < + rw_lon_lat_point<double, bg::cs::spherical_equatorial<double> > + >(); + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_spherical_with_wrong_units.cpp b/src/boost/libs/geometry/test/concepts/point_spherical_with_wrong_units.cpp new file mode 100644 index 00000000..960db4a4 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_spherical_with_wrong_units.cpp @@ -0,0 +1,26 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include <test_geometries/custom_lon_lat_point.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + + +namespace bg = boost::geometry; + + +int main() +{ + bg::model::point<double, 2, bg::cs::spherical_equatorial<double> > p; + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_well_formed.cpp b/src/boost/libs/geometry/test/concepts/point_well_formed.cpp new file mode 100644 index 00000000..20ae39c6 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_well_formed.cpp @@ -0,0 +1,34 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/tuple/tuple.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/register/point.hpp> + +#include "function_requiring_a_point.hpp" + +struct point: public boost::tuple<float, float> +{ +}; + +BOOST_GEOMETRY_REGISTER_POINT_2D(point, float, cs::cartesian, get<0>(), get<1>()) + +int main() +{ + point p1; + point const p2 = point(); + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_well_formed_non_cartesian.cpp b/src/boost/libs/geometry/test/concepts/point_well_formed_non_cartesian.cpp new file mode 100644 index 00000000..adbc14ce --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_well_formed_non_cartesian.cpp @@ -0,0 +1,64 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include <test_geometries/custom_lon_lat_point.hpp> + +#include <boost/geometry/core/cs.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/concepts/check.hpp> + + +namespace bg = boost::geometry; + + +template <typename CoordinateSystem> +inline void test_coordinate_system() +{ + typedef bg::model::point<double, 2, CoordinateSystem> bg_double_point; + typedef bg::model::point<int, 2, CoordinateSystem> bg_int_point; + + typedef rw_lon_lat_point<double, CoordinateSystem> rw_double_point; + typedef ro_lon_lat_point<double, CoordinateSystem> ro_double_point; + + typedef rw_lon_lat_point<int, CoordinateSystem> rw_int_point; + typedef ro_lon_lat_point<int, CoordinateSystem> ro_int_point; + + bg::concepts::check<bg_int_point>(); + bg::concepts::check<bg_int_point const>(); + + bg::concepts::check<bg_double_point>(); + bg::concepts::check<bg_double_point const>(); + + bg::concepts::check<rw_int_point>(); + bg::concepts::check<rw_int_point const>(); + bg::concepts::check<ro_int_point const>(); + + bg::concepts::check<rw_double_point>(); + bg::concepts::check<rw_double_point const>(); + bg::concepts::check<ro_double_point const>(); +} + + +int main() +{ + test_coordinate_system<bg::cs::geographic<bg::degree> >(); + test_coordinate_system<bg::cs::geographic<bg::radian> >(); + + test_coordinate_system<bg::cs::spherical<bg::degree> >(); + test_coordinate_system<bg::cs::spherical<bg::radian> >(); + + test_coordinate_system<bg::cs::spherical_equatorial<bg::degree> >(); + test_coordinate_system<bg::cs::spherical_equatorial<bg::radian> >(); + + test_coordinate_system<bg::cs::polar<bg::degree> >(); + test_coordinate_system<bg::cs::polar<bg::radian> >(); + + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_well_formed_traits.cpp b/src/boost/libs/geometry/test/concepts/point_well_formed_traits.cpp new file mode 100644 index 00000000..fc4ab82f --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_well_formed_traits.cpp @@ -0,0 +1,88 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/geometry/core/cs.hpp> + +#include "function_requiring_a_point.hpp" + +struct point +{ + point(): x(), y() {} + float x, y; +}; + +namespace boost { namespace geometry { namespace traits { + +template <> +struct tag<point> +{ + typedef point_tag type; +}; + +template <> +struct coordinate_type<point> +{ + typedef float type; +}; + +template <> +struct coordinate_system<point> +{ + typedef bg::cs::cartesian type; +}; + +template <> +struct dimension<point> +{ + enum { value = 2 }; +}; + +template <> +struct access<point, 0> +{ + static float get(point const& p) + { + return p.x; + } + + static void set(point& p, float value) + { + p.x = value; + } +}; + +template <> +struct access<point, 1> +{ + static float get(point const& p) + { + return p.y; + } + + static void set(point& p, float value) + { + p.y = value; + } +}; + + +}}} // namespace bg::traits + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_with_incorrect_dimension.cpp b/src/boost/libs/geometry/test/concepts/point_with_incorrect_dimension.cpp new file mode 100644 index 00000000..79ffc8be --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_with_incorrect_dimension.cpp @@ -0,0 +1,59 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include <test_common/test_point.hpp> + +#include "function_asserting_a_point.hpp" +#include "function_requiring_a_point.hpp" + +#include <boost/geometry/core/cs.hpp> + +struct point +{ + point() : x(0), y(0) {} // initialize to suppress warnings + float x, y; +}; + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<point> { typedef point_tag type; }; +template <> struct coordinate_type<point> { typedef float type; }; +template <> struct coordinate_system<point> { typedef bg::cs::cartesian type; }; +template <> struct dimension<point> { enum { value = 3 }; }; + +template <> struct access<point, 0> +{ + static float get(point const& p) { return p.x; } + static void set(point& p, float value) { p.x = value; } +}; + +template <> struct access<point, 1> +{ + static float get(point const& p) { return p.y; } + static void set(point& p, float value) { p.y = value; } +}; + + +}}} // namespace bg::traits + + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + test::function_asserting_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_without_coordinate_type.cpp b/src/boost/libs/geometry/test/concepts/point_without_coordinate_type.cpp new file mode 100644 index 00000000..3896e469 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_without_coordinate_type.cpp @@ -0,0 +1,54 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include "function_requiring_a_point.hpp" + +#include <boost/geometry/core/cs.hpp> + +struct point +{ + point() : x(0), y(0) {} // initialize to suppress warnings + float x, y; +}; + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<point> { typedef point_tag type; }; +//template <> struct coordinate_type<point> { typedef float type; }; +template <> struct coordinate_system<point> { typedef bg::cs::cartesian type; }; +template <> struct dimension<point> { enum { value = 2 }; }; + +template <> struct access<point, 0> +{ + static float get(point const& p) { return p.x; } + static void set(point& p, float value) { p.x = value; } +}; + +template <> struct access<point, 1> +{ + static float get(point const& p) { return p.y; } + static void set(point& p, float value) { p.y = value; } +}; + + +}}} // namespace bg::traits + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_without_dimension.cpp b/src/boost/libs/geometry/test/concepts/point_without_dimension.cpp new file mode 100644 index 00000000..11182ed2 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_without_dimension.cpp @@ -0,0 +1,56 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include "function_requiring_a_point.hpp" + +#include <boost/geometry/core/cs.hpp> + +struct point +{ + point() : x(0), y(0) {} // initialize to suppress warnings + float x, y; +}; + + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<point> { typedef point_tag type; }; +template <> struct coordinate_type<point> { typedef float type; }; +template <> struct coordinate_system<point> { typedef bg::cs::cartesian type; }; +//template <> struct dimension<point> { enum { value = 2 }; }; + +template <> struct access<point, 0> +{ + static float get(point const& p) { return p.x; } + static void set(point& p, float value) { p.x = value; } +}; + +template <> struct access<point, 1> +{ + static float get(point const& p) { return p.y; } + static void set(point& p, float value) { p.y = value; } +}; + + +}}} // namespace bg::traits + + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_without_getter.cpp b/src/boost/libs/geometry/test/concepts/point_without_getter.cpp new file mode 100644 index 00000000..5d19924e --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_without_getter.cpp @@ -0,0 +1,52 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include "function_requiring_a_point.hpp" + +#include <boost/geometry/core/cs.hpp> + +struct point +{ + point() : x(0), y(0) {} // initialize to suppress warnings + float x, y; +}; + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<point> { typedef point_tag type; }; +template <> struct coordinate_type<point> { typedef float type; }; +template <> struct coordinate_system<point> { typedef bg::cs::cartesian type; }; +template <> struct dimension<point> { enum { value = 2 }; }; + +template <> struct access<point, 0> +{ + static void set(point& p, float value) { p.x = value; } +}; + +template <> struct access<point, 1> +{ + static void set(point& p, float value) { p.y = value; } +}; + + +}}} // namespace bg::traits + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + return 0; +} diff --git a/src/boost/libs/geometry/test/concepts/point_without_setter.cpp b/src/boost/libs/geometry/test/concepts/point_without_setter.cpp new file mode 100644 index 00000000..78be8399 --- /dev/null +++ b/src/boost/libs/geometry/test/concepts/point_without_setter.cpp @@ -0,0 +1,52 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include "function_requiring_a_point.hpp" + +#include <boost/geometry/core/cs.hpp> + +struct point +{ + point() : x(0), y(0) {} // initialize to suppress warnings + float x, y; +}; + +namespace boost { namespace geometry { namespace traits { + +template <> struct tag<point> { typedef point_tag type; }; +template <> struct coordinate_type<point> { typedef float type; }; +template <> struct coordinate_system<point> { typedef bg::cs::cartesian type; }; +template <> struct dimension<point> { enum { value = 2 }; }; + +template <> struct access<point, 0> +{ + static float get(point const& p) { return p.x; } +}; + +template <> struct access<point, 1> +{ + static float get(point const& p) { return p.y; } +}; + + +}}} // namespace bg::traits + +int main() +{ + point p1; + const point p2; + test::function_requiring_a_point(p1, p2); + return 0; +} |