// Copyright (c) 2018-2019 Emil Dotchevski // Copyright (c) 2018-2019 Second Spectrum, Inc. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include "boost/core/lightweight_test.hpp" namespace leaf = boost::leaf; int check( leaf::catch_, leaf::e_source_location const & x ) { BOOST_TEST(strstr(x.file,"result.hpp")!=0); BOOST_TEST(x.line>0); BOOST_TEST(strstr(x.function,"value")!=0); return 1; } int main() { { int r = leaf::try_( [ ] { leaf::result r = leaf::new_error(); (void) r.value(); return 0; }, check ); BOOST_TEST_EQ(r, 1); } { int r = leaf::try_( [ ] { leaf::result const r = leaf::new_error(); (void) r.value(); return 0; }, check ); BOOST_TEST_EQ(r, 1); } { int r = leaf::try_( [ ] { leaf::result r = leaf::new_error(); (void) *r; return 0; }, check ); BOOST_TEST_EQ(r, 1); } { int r = leaf::try_( [ ] { leaf::result const r = leaf::new_error(); (void) *r; return 0; }, check ); BOOST_TEST_EQ(r, 1); } return boost::report_errors(); }