Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: release
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
posix:
Expand Down
23 changes: 23 additions & 0 deletions include/boost/test/tools/detail/print_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#if !defined(BOOST_NO_CXX11_NULLPTR)
#include <cstddef>
#endif
#if !defined(BOOST_NO_CXX17_HDR_OPTIONAL)
#include <optional>
#endif

#include <boost/test/detail/suppress_warnings.hpp>

Expand Down Expand Up @@ -184,6 +187,26 @@ struct print_log_value<std::nullptr_t> {

//____________________________________________________________________________//

#if !defined(BOOST_NO_CXX17_HDR_OPTIONAL)
template<typename T>
struct print_log_value<std::optional<T>> {
void operator()( std::ostream& ostr, std::optional<T> const& t ) {
if( t )
ostr << ' ' << *t;
else
ostr << "--";
}
};
template<>
struct print_log_value<std::nullopt_t> {
void operator()( std::ostream& ostr, std::nullopt_t /*t*/ ) {
ostr << "--";
}
};
#endif

//____________________________________________________________________________//

// ************************************************************************** //
// ************** print_helper ************** //
// ************************************************************************** //
Expand Down
2 changes: 1 addition & 1 deletion test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test-suite "writing-test-ts"
# [ boost.test-self-test run-fail : writing-test-ts : test-timeout-fail : : : : : : [ requires cxx11_hdr_thread cxx11_hdr_chrono ] ]
# [ boost.test-self-test run : writing-test-ts : test-timeout-suite : : : : : : $(requirements_datasets) [ requires cxx11_hdr_thread cxx11_hdr_chrono ] ]
# [ boost.test-self-test run-fail : writing-test-ts : test-timeout-suite-fail : : : : : : $(requirements_datasets) [ requires cxx11_hdr_thread cxx11_hdr_chrono ] ]
[ boost.test-self-test run : writing-test-ts : github_issue_475 : : : : : : [ requires cxx17_hdr_optional ] ]
[ boost.test-self-test run : writing-test-ts : cxx17-optional-support : : : : : : [ requires cxx17_hdr_optional ] ]
;

#_________________________________________________________________________________________________#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#define BOOST_TEST_MODULE github_issue_475
#define BOOST_TEST_MODULE cxx_std_optional_support
#include <optional>
#include <boost/test/unit_test.hpp>

BOOST_TEST_DONT_PRINT_LOG_VALUE(std::optional<int>)

BOOST_AUTO_TEST_CASE(test1)
{
std::optional<int> a,b;
BOOST_TEST(a==b);
std::optional<int> a = 1, b = 2;
BOOST_TEST(a != b);
}

BOOST_AUTO_TEST_CASE(test2)
{
std::optional<int> o;
BOOST_CHECK_EQUAL(o, std::nullopt);
}
Loading