From 870dcee0a8329b89658af01158224e8546ce2380 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 9 Jun 2017 05:29:22 +0300 Subject: [PATCH] Fix tests accordingly --- test/variant_emplace_index_cx.cpp | 57 +++++++++++++++++++++++++++++-- test/variant_emplace_type_cx.cpp | 30 +++++++++++++++- 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/test/variant_emplace_index_cx.cpp b/test/variant_emplace_index_cx.cpp index 3a5d73d..f66f99f 100644 --- a/test/variant_emplace_index_cx.cpp +++ b/test/variant_emplace_index_cx.cpp @@ -13,9 +13,17 @@ using namespace boost::variant2; struct X { int v; - constexpr X(): v( 0 ) {} + X() = default; constexpr explicit X( int v ): v( v ) {} - constexpr operator int() const { return v; } + constexpr operator int() const { return v; } +}; + +struct Y +{ + int v; + constexpr Y(): v() {} + constexpr explicit Y( int v ): v( v ) {} + constexpr operator int() const { return v; } }; #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) @@ -41,6 +49,16 @@ int main() STATIC_ASSERT( w == 1 ); } +#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000 +#else + + { + constexpr auto w = test, 0>( 1 ); + STATIC_ASSERT( w == 1 ); + } + +#endif + { constexpr auto w = test, 0>( 1 ); STATIC_ASSERT( w == 1 ); @@ -80,4 +98,39 @@ int main() constexpr auto w = test, 5>( 5 ); STATIC_ASSERT( w == 5 ); } + +#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000 +#else + + { + constexpr auto w = test, 0>( 1 ); + STATIC_ASSERT( w == 1 ); + } + + { + constexpr auto w = test, 1>( 1 ); + STATIC_ASSERT( w == 1 ); + } + + { + constexpr auto w = test, 2>( 2.0f ); + STATIC_ASSERT( w == 2.0f ); + } + + { + constexpr auto w = test, 3>( 3.0f ); + STATIC_ASSERT( w == 3.0f ); + } + + { + constexpr auto w = test, 4>( 4 ); + STATIC_ASSERT( w == 4 ); + } + + { + constexpr auto w = test, 5>( 5 ); + STATIC_ASSERT( w == 5 ); + } + +#endif } diff --git a/test/variant_emplace_type_cx.cpp b/test/variant_emplace_type_cx.cpp index 4162484..2449b12 100644 --- a/test/variant_emplace_type_cx.cpp +++ b/test/variant_emplace_type_cx.cpp @@ -13,11 +13,19 @@ using namespace boost::variant2; struct X { int v; - constexpr X(): v( 0 ) {} + X() = default; constexpr explicit X( int v ): v( v ) {} constexpr operator int() const { return v; } }; +struct Y +{ + int v; + constexpr Y(): v() {} + constexpr explicit Y( int v ): v( v ) {} + constexpr operator int() const { return v; } +}; + #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) template constexpr A test( A const& a ) @@ -41,6 +49,16 @@ int main() STATIC_ASSERT( w == 1 ); } +#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000 +#else + + { + constexpr auto w = test, Y>( 1 ); + STATIC_ASSERT( w == 1 ); + } + +#endif + { constexpr auto w = test, int>( 1 ); STATIC_ASSERT( w == 1 ); @@ -60,4 +78,14 @@ int main() constexpr auto w = test, X>( 1 ); STATIC_ASSERT( w == 1 ); } + +#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000 +#else + + { + constexpr auto w = test, Y>( 1 ); + STATIC_ASSERT( w == 1 ); + } + +#endif }