diff --git a/test/util/Jamfile.v2 b/test/util/Jamfile.v2 index 39ef14af2..12adec94b 100644 --- a/test/util/Jamfile.v2 +++ b/test/util/Jamfile.v2 @@ -4,8 +4,8 @@ # Copyright (c) 2008-2015 Bruno Lalande, Paris, France. # Copyright (c) 2009-2015 Mateusz Loskot, London, UK. # -# This file was modified by Oracle on 2014, 2015. -# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015, 2019. +# Modifications copyright (c) 2014-2019, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -25,5 +25,6 @@ test-suite boost-geometry-util [ run range.cpp : : : : util_range ] [ run rational.cpp : : : : util_rational ] [ run select_most_precise.cpp : : : : util_select_most_precise ] + [ run tuples.cpp : : : : util_tuples ] [ run write_dsv.cpp : : : : util_write_dsv ] ; diff --git a/test/util/tuples.cpp b/test/util/tuples.cpp new file mode 100644 index 000000000..19583fb38 --- /dev/null +++ b/test/util/tuples.cpp @@ -0,0 +1,141 @@ +// Boost.Geometry +// Unit Test + +// Copyright (c) 2019 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// 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 + +#include + +namespace bt = boost::tuples; +namespace bgt = boost::geometry::tuples; +namespace bm = boost::mpl; + +template +struct is_double + : boost::is_same +{}; + +template +struct is_float + : boost::is_same +{}; + + +template +struct is_boost_tuple + : boost::integral_constant +{}; + +template +struct is_boost_tuple > + : boost::integral_constant +{}; + +template +struct is_boost_tuples_cons + : boost::integral_constant +{}; + +template +struct is_boost_tuples_cons > + : boost::integral_constant +{}; + +template +struct is_std_pair + : boost::integral_constant +{}; + +template +struct is_std_pair > + : boost::integral_constant +{}; + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES) + +template +struct is_std_tuple + : boost::integral_constant +{}; + +template +struct is_std_tuple > + : boost::integral_constant +{}; + +#endif + +template +void test_all() +{ + typedef Tuple tuple_id; + tuple_id tup_id(1, 2.0); + + BOOST_CHECK_EQUAL((bgt::get<0>(tup_id)), 1); + BOOST_CHECK_EQUAL((bgt::get<1>(tup_id)), 2.0); + + BOOST_CHECK_EQUAL(int(bgt::size::value), 2); + + BOOST_CHECK_EQUAL((bgt::find_index_if::value), 1); + BOOST_CHECK((boost::is_same::type, double>::value)); + + BOOST_CHECK_EQUAL((bgt::find_index_if::value), 2); + BOOST_CHECK((boost::is_same::type, boost::tuples::null_type>::value)); + + typedef typename bgt::push_back::type tuple_idf; + tuple_idf tup_idf = bgt::push_back::apply(tup_id, 3.0f); + + BOOST_CHECK_EQUAL((bgt::get<0>(tup_idf)), 1); + BOOST_CHECK_EQUAL((bgt::get<1>(tup_idf)), 2.0); + BOOST_CHECK_EQUAL((bgt::get<2>(tup_idf)), 3.0f); + + BOOST_CHECK_EQUAL(int(bgt::size::value), 3); + + BOOST_CHECK_EQUAL((bgt::find_index_if::value), 2); + BOOST_CHECK((boost::is_same::type, float>::value)); + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES) + + BOOST_CHECK(( + (is_boost_tuple::value && is_boost_tuples_cons::value) + || (!is_boost_tuple::value && is_std_tuple::value) + )); + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + tup_idf = bgt::push_back::apply(std::move(tup_id), 3.0f); + + BOOST_CHECK_EQUAL((bgt::get<0>(tup_idf)), 1); + BOOST_CHECK_EQUAL((bgt::get<1>(tup_idf)), 2.0); + BOOST_CHECK_EQUAL((bgt::get<2>(tup_idf)), 3.0f); + +#endif + +#else + + BOOST_CHECK((is_boost_tuples_cons::type, float>::value)); + +#endif +} + +int test_main(int, char* []) +{ + test_all >(); + test_all >(); + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_VARIADIC_TEMPLATES) + + test_all >(); + +#endif + + return 0; +}