mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 20:47:14 +02:00
Add test/result_error_construct4.cpp. Refs #103.
This commit is contained in:
@ -154,7 +154,10 @@ boost_test(TYPE run SOURCES result_eq.cpp)
|
||||
boost_test(TYPE run SOURCES result_range_for.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct2.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct2.cpp)
|
||||
boost_test(TYPE run SOURCES result_errc_construct.cpp)
|
||||
boost_test(TYPE run SOURCES result_convert_construct.cpp)
|
||||
boost_test(TYPE run SOURCES result_typedefs.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct3.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct3.cpp)
|
||||
boost_test(TYPE run SOURCES result_emplace.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct4.cpp)
|
||||
|
@ -190,3 +190,4 @@ run result_typedefs.cpp : : : $(CPP11) ;
|
||||
run result_value_construct3.cpp : : : $(CPP11) ;
|
||||
run result_error_construct3.cpp : : : $(CPP11) ;
|
||||
run result_emplace.cpp : : : $(CPP11) ;
|
||||
run result_error_construct4.cpp : : : $(CPP11) ;
|
||||
|
49
test/result_error_construct4.cpp
Normal file
49
test/result_error_construct4.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
// Eigen::Matrix4d has an explicit templated constructor
|
||||
// https://github.com/boostorg/system/issues/103
|
||||
// https://github.com/boostorg/json/issues/843
|
||||
|
||||
struct X
|
||||
{
|
||||
X() {}
|
||||
template<class T> explicit X( T const& ) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<X> r = ec;
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
auto ec = make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result<X> r = ec;
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user