mirror of
https://github.com/boostorg/variant2.git
synced 2025-08-03 05:54:27 +02:00
Fix tests accordingly
This commit is contained in:
@@ -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<variant<Y>, 0>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, float>, 0>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
@@ -80,4 +98,39 @@ int main()
|
||||
constexpr auto w = test<variant<int, int, float, float, X, X>, 5>( 5 );
|
||||
STATIC_ASSERT( w == 5 );
|
||||
}
|
||||
|
||||
#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
|
||||
#else
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 0>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 1>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 2>( 2.0f );
|
||||
STATIC_ASSERT( w == 2.0f );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 3>( 3.0f );
|
||||
STATIC_ASSERT( w == 3.0f );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 4>( 4 );
|
||||
STATIC_ASSERT( w == 4 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y, Y>, 5>( 5 );
|
||||
STATIC_ASSERT( w == 5 );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@@ -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<class V, class T, class A> 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<variant<Y>, Y>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, float>, int>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
@@ -60,4 +78,14 @@ int main()
|
||||
constexpr auto w = test<variant<int, int, float, float, X>, X>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
|
||||
#else
|
||||
|
||||
{
|
||||
constexpr auto w = test<variant<int, int, float, float, Y>, Y>( 1 );
|
||||
STATIC_ASSERT( w == 1 );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user