mirror of
https://github.com/boostorg/system.git
synced 2025-07-31 21:14:26 +02:00
Add failed_constexpr_test.cpp
This commit is contained in:
@@ -128,6 +128,7 @@ system-run generic_category_test.cpp ;
|
|||||||
system-run system_category_test.cpp ;
|
system-run system_category_test.cpp ;
|
||||||
system-run after_main_test.cpp ;
|
system-run after_main_test.cpp ;
|
||||||
system-run failed_test.cpp ;
|
system-run failed_test.cpp ;
|
||||||
|
system-run- failed_constexpr_test.cpp ;
|
||||||
|
|
||||||
# Quick (CI) test
|
# Quick (CI) test
|
||||||
run quick.cpp ;
|
run quick.cpp ;
|
||||||
|
58
test/failed_constexpr_test.cpp
Normal file
58
test/failed_constexpr_test.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
// Copyright 2018 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using namespace boost::system;
|
||||||
|
|
||||||
|
constexpr error_code ec1( 1, system_category() );
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( ec1.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( ec1 );
|
||||||
|
BOOST_STATIC_ASSERT( !!ec1 );
|
||||||
|
|
||||||
|
constexpr error_code ec2( 2, generic_category() );
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( ec2.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( ec2 );
|
||||||
|
BOOST_STATIC_ASSERT( !!ec2 );
|
||||||
|
|
||||||
|
constexpr error_code ec3;
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( !ec3.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( ec3? false: true );
|
||||||
|
BOOST_STATIC_ASSERT( !ec3 );
|
||||||
|
|
||||||
|
constexpr error_condition en1( 1, system_category() );
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( en1.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( en1 );
|
||||||
|
BOOST_STATIC_ASSERT( !!en1 );
|
||||||
|
|
||||||
|
constexpr error_condition en2( 2, generic_category() );
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( en2.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( en2 );
|
||||||
|
BOOST_STATIC_ASSERT( !!en2 );
|
||||||
|
|
||||||
|
constexpr error_condition en3;
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT( !en3.failed() );
|
||||||
|
BOOST_STATIC_ASSERT( en3? false: true );
|
||||||
|
BOOST_STATIC_ASSERT( !en3 );
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user