From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/mpl/test/set.cpp | 347 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 src/boost/libs/mpl/test/set.cpp (limited to 'src/boost/libs/mpl/test/set.cpp') diff --git a/src/boost/libs/mpl/test/set.cpp b/src/boost/libs/mpl/test/set.cpp new file mode 100644 index 00000000..0710b41b --- /dev/null +++ b/src/boost/libs/mpl/test/set.cpp @@ -0,0 +1,347 @@ + +// Copyright Aleksey Gurtovoy 2003-2007 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +// Use templates for testing so that GCC will show us the actual types involved + +template< typename s > +void empty_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 0 ); + MPL_ASSERT(( empty )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::type o3; + MPL_ASSERT(( is_same< o1, void_ > )); + MPL_ASSERT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + + typedef BOOST_DEDUCED_TYPENAME begin::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT(( is_same )); + MPL_ASSERT_RELATION( (distance::value), ==, 0 ); +} + + +template< typename s > +void int_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 1 ); + MPL_ASSERT_NOT(( empty )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, void_ > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + + typedef BOOST_DEDUCED_TYPENAME begin::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME deref::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME next::type, last > )); + + MPL_ASSERT_RELATION( (distance::value), ==, 1 ); + MPL_ASSERT(( contains< s, int > )); +} + + +template< typename s > +void int_char_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 2 ); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, char > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT_NOT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + MPL_ASSERT_NOT(( is_same< o1, o2 > )); + + typedef BOOST_DEDUCED_TYPENAME begin::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + + MPL_ASSERT_RELATION( (distance::value), ==, 2 ); + + MPL_ASSERT(( contains< s, int > )); + MPL_ASSERT(( contains< s, char > )); +} + +template< typename s > +void int_char_long_set_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 3 ); + MPL_ASSERT_NOT(( empty )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, char > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at::type, long > )); + + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + + typedef BOOST_DEDUCED_TYPENAME order::type o1; + typedef BOOST_DEDUCED_TYPENAME order::type o2; + typedef BOOST_DEDUCED_TYPENAME order::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT_NOT(( is_same< o2, void_ > )); + MPL_ASSERT_NOT(( is_same< o3, void_ > )); + MPL_ASSERT_NOT(( is_same< o1, o2 > )); + MPL_ASSERT_NOT(( is_same< o1, o3 > )); + MPL_ASSERT_NOT(( is_same< o2, o3 > )); + + typedef BOOST_DEDUCED_TYPENAME begin::type first; + typedef BOOST_DEDUCED_TYPENAME end::type last; + MPL_ASSERT_RELATION( (distance::value), ==, 3 ); + + MPL_ASSERT(( contains< s, int > )); + MPL_ASSERT(( contains< s, char > )); + MPL_ASSERT(( contains< s, long > )); +} + +template< typename S0, typename S1, typename S2, typename S3 > +void basic_set_test() +{ + empty_set_test(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , int + >::type >(); + + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , long + >::type + , int + >::type >(); + + + int_set_test(); + int_set_test< BOOST_DEDUCED_TYPENAME insert::type >(); + + int_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + int_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key::type + , long + >::type >(); + + int_char_set_test(); + int_char_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , int + >::type >(); + + int_char_set_test< BOOST_DEDUCED_TYPENAME insert::type >(); + int_char_set_test< BOOST_DEDUCED_TYPENAME erase_key::type >(); + + int_char_long_set_test(); + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , long + >::type + , int + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert::type + , char + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert::type >(); +} + + +template< typename S1, typename S2 > +void numbered_vs_variadic_set_test() +{ + MPL_ASSERT(( is_same< S1, BOOST_DEDUCED_TYPENAME S1::type > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME S2::type, S1 > )); +} + + +MPL_TEST_CASE() +{ + typedef mpl::set0<> s01; + typedef mpl::set<> s02; + typedef mpl::set1 s11; + typedef mpl::set s12; + typedef mpl::set2 s21; + typedef mpl::set s22; + typedef mpl::set s23; + typedef mpl::set3 s31; + typedef mpl::set s32; + typedef mpl::set s33; + typedef mpl::set s34; + + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + numbered_vs_variadic_set_test(); + + basic_set_test(); + basic_set_test(); + basic_set_test(); + basic_set_test(); + basic_set_test(); +} + + +template< typename s > +void empty_set_types_variety_test() +{ + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); +} + +template< typename s > +void set_types_variety_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 8 ); + + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + MPL_ASSERT(( has_key )); + + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); + MPL_ASSERT_NOT(( has_key )); +} + + +MPL_TEST_CASE() +{ + empty_set_types_variety_test< set<> >(); + empty_set_types_variety_test< set<>::type >(); + + typedef set< + char,int const,long*,UDT* const,incomplete,abstract + , incomplete volatile&,abstract const& + > s; + + set_types_variety_test(); + set_types_variety_test(); +} + + +template +void find_test() +{ + MPL_ASSERT_RELATION( size::value, ==, 3 ); + + typedef typename end::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); + BOOST_MPL_ASSERT(( is_same::type,not_found> )); +} + +MPL_TEST_CASE() +{ + typedef mpl::set s; + find_test(); + find_test(); +} + +MPL_TEST_CASE() +{ + typedef insert< set<>, int >::type little_set; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} + +MPL_TEST_CASE() +{ + typedef erase_key< set< float, int >, float >::type little_set; + + MPL_ASSERT_RELATION(size::value, ==, 1); + MPL_ASSERT_RELATION(size::value, ==, 1); +} -- cgit v1.2.3