Skip to content
Snippets Groups Projects
Commit 875efffa authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Explicitly define StatusCode constants (!841)

parents 8b3dd4fa 2dbdafa0
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
// statics // statics
bool StatusCode::s_checking( false ); bool StatusCode::s_checking( false );
constexpr const StatusCode::ErrorCode StatusCode::SUCCESS;
constexpr const StatusCode::ErrorCode StatusCode::FAILURE;
constexpr const StatusCode::ErrorCode StatusCode::RECOVERABLE;
namespace { namespace {
/// Default StatusCode category /// Default StatusCode category
struct DefaultCategory : public StatusCode::Category { struct DefaultCategory : public StatusCode::Category {
......
...@@ -407,3 +407,18 @@ BOOST_AUTO_TEST_CASE( conversions ) { ...@@ -407,3 +407,18 @@ BOOST_AUTO_TEST_CASE( conversions ) {
// sc = 42; // no implicit conversion from int // sc = 42; // no implicit conversion from int
// int i = sc; // no implicit conversion to int // int i = sc; // no implicit conversion to int
} }
/// Function used for testing that the constants in @c StatusCode can be found
/// by constant references.
bool __attribute__( ( noinline ) )
testReferencePassing( const StatusCode::ErrorCode& value, const StatusCode::ErrorCode& reference ) {
return ( value == reference );
}
BOOST_AUTO_TEST_CASE( const_definitions ) {
// Test whether the test can compile/link correctly when passing the
// constants in @c StatusCode into a function by constant reference.
BOOST_CHECK( testReferencePassing( StatusCode::SUCCESS, StatusCode::SUCCESS ) );
BOOST_CHECK( testReferencePassing( StatusCode::FAILURE, StatusCode::FAILURE ) );
BOOST_CHECK( testReferencePassing( StatusCode::RECOVERABLE, StatusCode::RECOVERABLE ) );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment