From 95fff4a6f9ba786cc3ca25ec30c3b8ecd35a43bf Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 9 Dec 2023 18:05:15 -0800 Subject: [PATCH] minor changes in diagnostic_info, plus re-enabled all unit tests --- include/boost/leaf/config.hpp | 10 +- include/boost/leaf/context.hpp | 4 - include/boost/leaf/error.hpp | 17 +- include/boost/leaf/handle_errors.hpp | 250 +++++++++++++---------- include/boost/leaf/result.hpp | 6 +- test/Jamfile.v2 | 13 +- test/_compile-fail-BOOST_LEAF_ASSIGN.cpp | 9 - test/_compile-fail-BOOST_LEAF_AUTO.cpp | 9 - test/capture_exception_state_test.cpp | 9 +- test/capture_result_state_test.cpp | 9 +- test/defer_basic_test.cpp | 7 +- test/diagnostic_info_test1.cpp | 151 +++++++------- test/diagnostic_info_test2.cpp | 15 +- test/diagnostic_info_test3.cpp | 9 +- test/diagnostic_info_test4.cpp | 11 +- test/diagnostic_info_test5.cpp | 37 ++-- test/dynamic_capture_print_test.cpp | 15 +- test/e_LastError_test.cpp | 2 +- test/e_errno_test.cpp | 2 +- test/preload_basic_test.cpp | 11 - test/print_test.cpp | 2 +- test/result_print_test.cpp | 39 ++-- test/tls_array_alloc_test1.cpp | 18 +- test/tls_array_alloc_test2.cpp | 18 +- test/tls_array_alloc_test3.cpp | 18 +- test/visibility_test.cpp | 30 +-- 26 files changed, 368 insertions(+), 353 deletions(-) diff --git a/include/boost/leaf/config.hpp b/include/boost/leaf/config.hpp index bf3118f7..24c0f3c6 100644 --- a/include/boost/leaf/config.hpp +++ b/include/boost/leaf/config.hpp @@ -102,10 +102,6 @@ # error BOOST_LEAF_CFG_CAPTURE must be 0 or 1. #endif -#if BOOST_LEAF_CFG_DIAGNOSTICS && !BOOST_LEAF_CFG_STD_STRING -# error BOOST_LEAF_CFG_DIAGNOSTICS requires the use of std::string -#endif - #if BOOST_LEAF_CFG_WIN32!=0 && BOOST_LEAF_CFG_WIN32!=1 # error BOOST_LEAF_CFG_WIN32 must be 0 or 1. #endif @@ -114,8 +110,12 @@ # error BOOST_LEAF_CFG_GNUC_STMTEXPR must be 0 or 1. #endif +#if BOOST_LEAF_CFG_DIAGNOSTICS && !BOOST_LEAF_CFG_STD_STRING +# error BOOST_LEAF_CFG_DIAGNOSTICS requires BOOST_LEAF_CFG_STD_STRING, which has been disabled. +#endif + #if BOOST_LEAF_CFG_STD_SYSTEM_ERROR && !BOOST_LEAF_CFG_STD_STRING -# error BOOST_LEAF_CFG_STD_SYSTEM_ERROR != 0 requires BOOST_LEAF_CFG_STD_STRING != 0 +# error BOOST_LEAF_CFG_STD_SYSTEM_ERROR requires BOOST_LEAF_CFG_STD_STRING, which has been disabled. #endif //////////////////////////////////////// diff --git a/include/boost/leaf/context.hpp b/include/boost/leaf/context.hpp index d1704f51..ca08e7bb 100644 --- a/include/boost/leaf/context.hpp +++ b/include/boost/leaf/context.hpp @@ -17,9 +17,7 @@ namespace boost { namespace leaf { class error_info; class diagnostic_info; -#if BOOST_LEAF_CFG_DIAGNOSTICS class verbose_diagnostic_info; -#endif template struct is_predicate: std::false_type @@ -60,9 +58,7 @@ namespace leaf_detail static_assert(!is_predicate::value, "Handlers must take predicate arguments by value"); static_assert(!std::is_same::value, "Handlers must take leaf::error_info arguments by const &"); static_assert(!std::is_same::value, "Handlers must take leaf::diagnostic_info arguments by const &"); -#if BOOST_LEAF_CFG_DIAGNOSTICS static_assert(!std::is_same::value, "Handlers must take leaf::verbose_diagnostic_info arguments by const &"); -#endif }; template diff --git a/include/boost/leaf/error.hpp b/include/boost/leaf/error.hpp index 82dbaf2c..90582b7d 100644 --- a/include/boost/leaf/error.hpp +++ b/include/boost/leaf/error.hpp @@ -189,7 +189,6 @@ namespace leaf_detail template void print( std::basic_ostream & os, int err_id_to_print ) const { -#if BOOST_LEAF_CFG_DIAGNOSTICS if( !diagnostic::is_invisible ) if( int k = this->key() ) { @@ -201,12 +200,7 @@ namespace leaf_detail else os << '[' << k << "] "; diagnostic::print(os, value(k)); - (os << '\n').flush(); } -#else - (void) os; - (void) err_id_to_print; -#endif } using impl::load; @@ -400,6 +394,17 @@ namespace leaf_detail using capture_list::print; }; + template <> + struct diagnostic + { + static constexpr bool is_invisible = true; + + template + BOOST_LEAF_CONSTEXPR static void print( std::basic_ostream &, dynamic_allocator const & ) + { + } + }; + template <> inline void slot::deactivate() const noexcept { diff --git a/include/boost/leaf/handle_errors.hpp b/include/boost/leaf/handle_errors.hpp index e99c7d49..a9d58697 100644 --- a/include/boost/leaf/handle_errors.hpp +++ b/include/boost/leaf/handle_errors.hpp @@ -14,6 +14,8 @@ namespace boost { namespace leaf { template class result; +//////////////////////////////////////// + class BOOST_LEAF_SYMBOL_VISIBLE error_info { error_info & operator=( error_info const & ) = delete; @@ -35,20 +37,6 @@ class BOOST_LEAF_SYMBOL_VISIBLE error_info error_info( error_info const & ) noexcept = default; - template - void print( std::basic_ostream & os ) const - { - os << "Error ID = " << err_id_.value(); -#ifndef BOOST_LEAF_NO_EXCEPTIONS - if( ex_ ) - { - os << - "\nException dynamic type: " << leaf_detail::demangle(typeid(*ex_).name()) << - "\nstd::exception::what(): " << ex_->what(); - } -#endif - } - public: BOOST_LEAF_CONSTEXPR explicit error_info( error_id id ) noexcept: @@ -84,18 +72,27 @@ class BOOST_LEAF_SYMBOL_VISIBLE error_info template friend std::ostream & operator<<( std::basic_ostream & os, error_info const & x ) { - os << "leaf::error_info: "; - x.print(os); + os << "Error ID: " << x.err_id_.value(); +#ifndef BOOST_LEAF_NO_EXCEPTIONS + if( x.ex_ ) + { + os << + "\nException dynamic type: " << leaf_detail::demangle(typeid(*x.ex_).name()) << + "\nstd::exception::what(): " << x.ex_->what(); + } +#endif return os << '\n'; } }; //////////////////////////////////////// +#if BOOST_LEAF_CFG_DIAGNOSTICS + class diagnostic_info: public error_info { void const * tup_; - void (*print_)( std::ostream &, void const * tup, int err_id_to_print ); + void (*print_context_content_)( std::ostream &, void const * tup, int err_id_to_print ); protected: @@ -105,19 +102,15 @@ class diagnostic_info: public error_info BOOST_LEAF_CONSTEXPR diagnostic_info( error_info const & ei, Tup const & tup ) noexcept: error_info(ei), tup_(&tup), - print_(&leaf_detail::tuple_for_each::value, Tup>::print) + print_context_content_(&leaf_detail::tuple_for_each::value, Tup>::print) { } -public: - template friend std::ostream & operator<<( std::basic_ostream & os, diagnostic_info const & x ) { - os << "leaf::diagnostic_info for "; - x.print(os); - os << ":\n"; - x.print_(os, x.tup_, x.error().value()); + os << static_cast(x); + x.print_context_content_(os, x.tup_, x.error().value()); return os; } }; @@ -144,78 +137,43 @@ namespace leaf_detail }; } -//////////////////////////////////////// - -#if BOOST_LEAF_CFG_CAPTURE +#else -class dynamic_capture +class diagnostic_info: public error_info { - template - friend class ::boost::leaf::result; - - dynamic_capture( dynamic_capture const & ) = delete; - dynamic_capture & operator=( dynamic_capture const & ) = delete; - - leaf_detail::dynamic_allocator * const da_; - error_id err_; - protected: - dynamic_capture( dynamic_capture && ) = default; - - BOOST_LEAF_CONSTEXPR dynamic_capture( leaf_detail::dynamic_allocator * da, error_id err ) noexcept: - da_(da), - err_(err) - { - } - -public: - - BOOST_LEAF_CONSTEXPR bool empty() const noexcept - { - return !da_ || da_->empty(); - } - - BOOST_LEAF_CONSTEXPR int size() const noexcept - { - return da_ ? da_->size() : 0; - } + diagnostic_info( diagnostic_info const & ) noexcept = default; - template - operator result() const noexcept + BOOST_LEAF_CONSTEXPR diagnostic_info( error_info const & ei ) noexcept: + error_info(ei) { - if( da_ ) - return da_->extract_capture_list(); - else - return { error_id() }; } template - friend std::ostream & operator<<( std::basic_ostream & os, dynamic_capture const & x ) + friend std::ostream & operator<<( std::basic_ostream & os, diagnostic_info const & x ) { - if( x.da_ ) - x.da_->print(os, "Captured error objects:\n", x.err_.value()); - return os; + return os << "diagnostic_info not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0. Basic error_info follows.\n" << static_cast(x); } }; namespace leaf_detail { - struct dynamic_capture_: dynamic_capture + struct diagnostic_info_: diagnostic_info { - BOOST_LEAF_CONSTEXPR dynamic_capture_( leaf_detail::dynamic_allocator * da, error_id err ) noexcept: - dynamic_capture(da, err) + BOOST_LEAF_CONSTEXPR diagnostic_info_( error_info const & ei ) noexcept: + diagnostic_info(ei) { } }; template <> - struct handler_argument_traits: handler_argument_always_available + struct handler_argument_traits: handler_argument_always_available { template - BOOST_LEAF_CONSTEXPR static dynamic_capture_ get( Tup & tup, error_info const & ei ) noexcept + BOOST_LEAF_CONSTEXPR static diagnostic_info_ get( Tup const &, error_info const & ei ) noexcept { - return dynamic_capture_(handler_argument_traits_defaults::check(tup, ei), ei.error()); + return diagnostic_info_(ei); } }; } @@ -224,60 +182,35 @@ namespace leaf_detail //////////////////////////////////////// -#if BOOST_LEAF_CFG_DIAGNOSTICS +#if BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_CAPTURE -class verbose_diagnostic_info: public error_info +class verbose_diagnostic_info: public diagnostic_info { - void const * const tup_; -#if BOOST_LEAF_CFG_CAPTURE leaf_detail::dynamic_allocator const * const da_; -#endif - void (* const print_)( std::ostream &, void const * tup, int err_id_to_print ); protected: verbose_diagnostic_info( verbose_diagnostic_info const & ) noexcept = default; -#if BOOST_LEAF_CFG_CAPTURE template BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei, Tup const & tup, leaf_detail::dynamic_allocator const * da ) noexcept: - error_info(ei), - tup_(&tup), - da_(da), - print_(&leaf_detail::tuple_for_each::value, Tup>::print) - { - } -#else - template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei, Tup const & tup ) noexcept: - error_info(ei), - tup_(&tup), - print_(&leaf_detail::tuple_for_each::value, Tup>::print) + diagnostic_info(ei, tup), + da_(da) { } -#endif - -public: template friend std::ostream & operator<<( std::basic_ostream & os, verbose_diagnostic_info const & x ) { - os << "leaf::verbose_diagnostic_info for "; - error_id err = x.error(); - x.print(os); - os << ":\n"; - x.print_(os, x.tup_, err.value()); -#if BOOST_LEAF_CFG_CAPTURE + os << static_cast(x); if( x.da_ ) x.da_->print(os, "Unhandled error objects:\n", x.error().value()); -#endif return os; } }; namespace leaf_detail { -#if BOOST_LEAF_CFG_CAPTURE struct verbose_diagnostic_info_: verbose_diagnostic_info { template @@ -286,6 +219,7 @@ namespace leaf_detail { } }; + template <> struct handler_argument_traits: handler_argument_always_available { @@ -295,30 +229,126 @@ namespace leaf_detail return verbose_diagnostic_info_(ei, tup, handler_argument_traits_defaults::check(tup, ei)); } }; +} + #else + +class verbose_diagnostic_info: public diagnostic_info +{ +protected: + + verbose_diagnostic_info( verbose_diagnostic_info const & ) noexcept = default; + + BOOST_LEAF_CONSTEXPR verbose_diagnostic_info( error_info const & ei ) noexcept: + diagnostic_info(ei) + { + } + + template + friend std::ostream & operator<<( std::basic_ostream & os, verbose_diagnostic_info const & x ) + { + return os << "verbose_diagnostic_info not available due to BOOST_LEAF_CFG_DIAGNOSTICS=0 or BOOST_LEAF_CFG_CAPTURE=0. Basic error_info follows.\n" << static_cast(x); + } +}; + +namespace leaf_detail +{ struct verbose_diagnostic_info_: verbose_diagnostic_info { - template - BOOST_LEAF_CONSTEXPR verbose_diagnostic_info_( error_info const & ei, Tup const & tup ) noexcept: - verbose_diagnostic_info(ei, tup) + BOOST_LEAF_CONSTEXPR verbose_diagnostic_info_( error_info const & ei ) noexcept: + verbose_diagnostic_info(ei) { } }; + template <> struct handler_argument_traits: handler_argument_always_available { template - BOOST_LEAF_CONSTEXPR static verbose_diagnostic_info_ get( Tup const & tup, error_info const & ei ) noexcept + BOOST_LEAF_CONSTEXPR static verbose_diagnostic_info_ get( Tup const &, error_info const & ei ) noexcept { - return verbose_diagnostic_info_(ei, tup); + return verbose_diagnostic_info_(ei); } }; -#endif } -#else +#endif + +//////////////////////////////////////// + +#if BOOST_LEAF_CFG_CAPTURE + +class dynamic_capture +{ + template + friend class ::boost::leaf::result; + + dynamic_capture( dynamic_capture const & ) = delete; + dynamic_capture & operator=( dynamic_capture const & ) = delete; + + leaf_detail::dynamic_allocator * const da_; + error_id err_; + +protected: + + dynamic_capture( dynamic_capture && ) = default; + + BOOST_LEAF_CONSTEXPR dynamic_capture( leaf_detail::dynamic_allocator * da, error_id err ) noexcept: + da_(da), + err_(err) + { + } + +public: -using verbose_diagnostic_info = diagnostic_info; + BOOST_LEAF_CONSTEXPR bool empty() const noexcept + { + return !da_ || da_->empty(); + } + + BOOST_LEAF_CONSTEXPR int size() const noexcept + { + return da_ ? da_->size() : 0; + } + + template + operator result() const noexcept + { + if( da_ ) + return da_->extract_capture_list(); + else + return { error_id() }; + } + + template + friend std::ostream & operator<<( std::basic_ostream & os, dynamic_capture const & x ) + { + if( x.da_ ) + x.da_->print(os, "Captured error objects:\n", x.err_.value()); + return os; + } +}; + +namespace leaf_detail +{ + struct dynamic_capture_: dynamic_capture + { + BOOST_LEAF_CONSTEXPR dynamic_capture_( leaf_detail::dynamic_allocator * da, error_id err ) noexcept: + dynamic_capture(da, err) + { + } + }; + + template <> + struct handler_argument_traits: handler_argument_always_available + { + template + BOOST_LEAF_CONSTEXPR static dynamic_capture_ get( Tup & tup, error_info const & ei ) noexcept + { + return dynamic_capture_(handler_argument_traits_defaults::check(tup, ei), ei.error()); + } + }; +} #endif diff --git a/include/boost/leaf/result.hpp b/include/boost/leaf/result.hpp index 0d3c0325..57a4df4a 100644 --- a/include/boost/leaf/result.hpp +++ b/include/boost/leaf/result.hpp @@ -579,11 +579,15 @@ class BOOST_LEAF_NODISCARD BOOST_LEAF_SYMBOL_VISIBLE result error_id const err_id = what.get_error_id(); os << "Error ID " << err_id; if( what.kind() == result_discriminant::err_id_capture_list ) -#if BOOST_LEAF_CFG_CAPTURE && BOOST_LEAF_CFG_DIAGNOSTICS + { +#if BOOST_LEAF_CFG_CAPTURE +# if BOOST_LEAF_CFG_DIAGNOSTICS cap_.print(os, ". Captured error objects:\n", err_id.value()); +# endif #else BOOST_LEAF_ASSERT(0); // Possible ODR violation. #endif + } } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d6a922e0..fe4aaeb8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -31,7 +31,6 @@ project ../../.. ; -compile _hpp_capture_test.cpp ; compile _hpp_common_test.cpp ; compile _hpp_config_test.cpp ; compile _hpp_context_test.cpp ; @@ -61,6 +60,8 @@ run capture_exception_state_test.cpp ; run capture_exception_unload_test.cpp ; run capture_result_async_test.cpp ; run capture_result_state_test.cpp ; +run context_activator_test.cpp ; +run context_deduction_test.cpp ; run capture_result_unload_test.cpp ; run ctx_handle_all_test.cpp ; run ctx_handle_some_test.cpp ; @@ -78,6 +79,7 @@ run diagnostic_info_test2.cpp ; run diagnostic_info_test3.cpp ; run diagnostic_info_test4.cpp ; run diagnostic_info_test5.cpp ; +run dynamic_capture_print_test.cpp ; run e_errno_test.cpp ; run e_LastError_test.cpp ; run error_code_test.cpp ; @@ -112,13 +114,13 @@ run result_load_test.cpp ; run result_print_test.cpp ; run result_ref_test.cpp ; run result_state_test.cpp ; -run context_deduction_test.cpp ; run tls_array_alloc_test1.cpp ; run tls_array_alloc_test2.cpp ; run tls_array_alloc_test3.cpp ; run tls_array_test.cpp ; run to_variant_test.cpp ; run try_catch_error_id_test.cpp ; +run try_catch_system_error_test.cpp ; run try_catch_test.cpp ; run try_exception_and_result_test.cpp ; @@ -146,14 +148,11 @@ compile-fail _compile-fail-result_3.cpp ; compile-fail _compile-fail-result_4.cpp ; compile-fail _compile-fail-verbose_diagnostic_info.cpp ; -exe capture_in_exception : ../example/capture_in_exception.cpp : single:no off:no leaf_debug_capture0:no leaf_release_capture0:no ; -exe capture_in_result : ../example/capture_in_result.cpp : single:no leaf_debug_capture0:no leaf_release_capture0:no leaf_debug_embedded:no leaf_release_embedded:no ; +exe dynamic_capture_eh : ../example/dynamic_capture_eh.cpp : single:no off:no leaf_debug_capture0:no leaf_release_capture0:no ; +exe dynamic_capture_result : ../example/dynamic_capture_result.cpp : single:no leaf_debug_capture0:no leaf_release_capture0:no leaf_debug_embedded:no leaf_release_embedded:no ; exe error_log : ../example/error_log.cpp : off:no ; exe error_trace : ../example/error_trace.cpp : off:no ; exe exception_to_result : ../example/exception_to_result.cpp : off:no ; -# exe lua_callback_result : ../example/lua_callback_result.cpp : off:no ; -# exe lua_callback_eh : ../example/lua_callback_eh.cpp : off:no ; exe print_file_eh : ../example/print_file/print_file_eh.cpp : off:no ; -# exe print_file_outcome_result : ../example/print_file/print_file_outcome_result.cpp : off:no 11:no ; exe print_file_result : ../example/print_file/print_file_result.cpp : off:no ; exe print_half : ../example/print_half.cpp : off:no ; diff --git a/test/_compile-fail-BOOST_LEAF_ASSIGN.cpp b/test/_compile-fail-BOOST_LEAF_ASSIGN.cpp index d8ec91f7..df3579f1 100644 --- a/test/_compile-fail-BOOST_LEAF_ASSIGN.cpp +++ b/test/_compile-fail-BOOST_LEAF_ASSIGN.cpp @@ -17,15 +17,6 @@ struct my_result explicit operator bool() const; }; -#if 0 -namespace boost { namespace leaf { - template - struct is_result_type>: std::true_type - { - }; -} } -#endif - my_result f(); my_result g() diff --git a/test/_compile-fail-BOOST_LEAF_AUTO.cpp b/test/_compile-fail-BOOST_LEAF_AUTO.cpp index eaafbbb8..8b0838d8 100644 --- a/test/_compile-fail-BOOST_LEAF_AUTO.cpp +++ b/test/_compile-fail-BOOST_LEAF_AUTO.cpp @@ -17,15 +17,6 @@ struct my_result explicit operator bool() const; }; -#if 0 -namespace boost { namespace leaf { - template - struct is_result_type>: std::true_type - { - }; -} } -#endif - my_result f(); my_result g() diff --git a/test/capture_exception_state_test.cpp b/test/capture_exception_state_test.cpp index 4f94f2ab..72a9d7b7 100644 --- a/test/capture_exception_state_test.cpp +++ b/test/capture_exception_state_test.cpp @@ -82,10 +82,11 @@ int main() st << r; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("info<1> instance"), s.npos); - BOOST_TEST_NE(s.find("info<3> instance"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("info<1> instance"), s.npos); + BOOST_TEST_NE(s.find("info<3> instance"), s.npos); + } } #endif diff --git a/test/capture_result_state_test.cpp b/test/capture_result_state_test.cpp index a6743c18..6839949d 100644 --- a/test/capture_result_state_test.cpp +++ b/test/capture_result_state_test.cpp @@ -80,10 +80,11 @@ int main() st << r; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("info<1> instance"), s.npos); - BOOST_TEST_NE(s.find("info<3> instance"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("info<1> instance"), s.npos); + BOOST_TEST_NE(s.find("info<3> instance"), s.npos); + } } #endif diff --git a/test/defer_basic_test.cpp b/test/defer_basic_test.cpp index ff15d8c5..12063633 100644 --- a/test/defer_basic_test.cpp +++ b/test/defer_basic_test.cpp @@ -57,13 +57,12 @@ int main() { BOOST_TEST_EQ(i42.value, 42); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << di; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST(s.find("info<42>")!=s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST(s.find("info<42>")!=s.npos); #endif return 1; }, diff --git a/test/diagnostic_info_test1.cpp b/test/diagnostic_info_test1.cpp index e8152c9b..d9a21df6 100644 --- a/test/diagnostic_info_test1.cpp +++ b/test/diagnostic_info_test1.cpp @@ -111,9 +111,7 @@ int main() st << unmatched; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); -#endif + BOOST_TEST_NE(s.find("Error ID: "), s.npos); #endif }, []() @@ -121,8 +119,7 @@ int main() BOOST_ERROR("Bad error dispatch"); } ); - std::cout << __LINE__ << " ----\n"; - + std::cout << __LINE__ << " ---- diagnostic_info\n"; leaf::try_handle_all( []() -> leaf::result { @@ -149,18 +146,18 @@ int main() st << unmatched; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::diagnostic_info for Error ID = "), s.npos); - BOOST_TEST_NE(s.find("e_source_location"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); - BOOST_TEST_NE(s.find(": {not printable}"), s.npos); - BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); -#else - BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos); - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); -#endif + BOOST_TEST_NE(s.find("Error ID: "), s.npos); + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("e_source_location"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); + BOOST_TEST_NE(s.find(": {not printable}"), s.npos); + BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); + } + else + BOOST_TEST_NE(s.find("diagnostic_info not available"), s.npos); #endif }, []() @@ -168,8 +165,7 @@ int main() BOOST_ERROR("Bad error dispatch"); } ); - std::cout << __LINE__ << " ----\n"; - + std::cout << __LINE__ << " ---- verbose_diagnostic_info\n"; leaf::try_handle_all( []() -> leaf::result { @@ -198,23 +194,24 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info for Error ID = "), s.npos); - BOOST_TEST_NE(s.find("e_source_location"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); - BOOST_TEST_NE(s.find(": {not printable}"), s.npos); - BOOST_TEST_NE(s.find("enum_class"), s.npos); - BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); - BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); - BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); - BOOST_TEST_NE(s.find(": 1"), s.npos); - BOOST_TEST_NE(s.find(": 2"), s.npos); -#else - BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos); - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); -#endif + BOOST_TEST_NE(s.find("Error ID: "), s.npos); + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("e_source_location"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); + BOOST_TEST_NE(s.find(": {not printable}"), s.npos); + BOOST_TEST_NE(s.find("enum_class"), s.npos); + BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); + BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); + BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); + BOOST_TEST_NE(s.find(": 1"), s.npos); + BOOST_TEST_NE(s.find(": 2"), s.npos); + BOOST_TEST_EQ(s.find("dynamic_allocator"), s.npos); + } + else + BOOST_TEST_NE(s.find("verbose_diagnostic_info not available"), s.npos); #endif }, []() @@ -226,8 +223,7 @@ int main() #ifndef BOOST_LEAF_NO_EXCEPTIONS - std::cout << __LINE__ << " ----\n"; - + std::cout << __LINE__ << " ---- error_info\n"; leaf::try_catch( [] { @@ -254,16 +250,15 @@ int main() st << unmatched; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); - BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); - BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); + BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); + } #endif } ); - std::cout << __LINE__ << " ----\n"; - + std::cout << __LINE__ << " ---- diagnostic_info\n"; leaf::try_catch( [] { @@ -290,27 +285,24 @@ int main() st << unmatched; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::diagnostic_info for Error ID = "), s.npos); + BOOST_TEST_NE(s.find("Error ID: "), s.npos); BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); - BOOST_TEST_NE(s.find("e_source_location"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); - BOOST_TEST_NE(s.find(": {not printable}"), s.npos); - BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); -#else - BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos); - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); - BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); - BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("e_source_location"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); + BOOST_TEST_NE(s.find(": {not printable}"), s.npos); + BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); + } + else + BOOST_TEST_NE(s.find("diagnostic_info not available"), s.npos); #endif } ); - std::cout << __LINE__ << " ----\n"; - + std::cout << __LINE__ << " ---- verbose_diagnostic_info\n"; leaf::try_catch( [] { @@ -339,27 +331,26 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info for Error ID = "), s.npos); + BOOST_TEST_NE(s.find("Error ID: "), s.npos); BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); - BOOST_TEST_NE(s.find("e_source_location"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); - BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); - BOOST_TEST_NE(s.find(": {not printable}"), s.npos); - BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); - BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); - BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); - BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); - BOOST_TEST_NE(s.find(": 1"), s.npos); - BOOST_TEST_NE(s.find(": 2"), s.npos); -#else - BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos); - BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos); - BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos); - BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("e_source_location"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos); + BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos); + BOOST_TEST_NE(s.find(": {not printable}"), s.npos); + BOOST_TEST_NE(s.find("enum_class_payload"), s.npos); + BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos); + BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos); + BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos); + BOOST_TEST_NE(s.find(": 1"), s.npos); + BOOST_TEST_NE(s.find(": 2"), s.npos); + BOOST_TEST_EQ(s.find("dynamic_allocator"), s.npos); + } + else + BOOST_TEST_NE(s.find("verbose_diagnostic_info not available"), s.npos); #endif } ); diff --git a/test/diagnostic_info_test2.cpp b/test/diagnostic_info_test2.cpp index 3e8bdd14..32089d37 100644 --- a/test/diagnostic_info_test2.cpp +++ b/test/diagnostic_info_test2.cpp @@ -59,9 +59,8 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("info<2>"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_NE(s.find("info<2>"), s.npos); #endif } ); @@ -96,9 +95,8 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("info<2>"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_NE(s.find("info<2>"), s.npos); #endif } ); @@ -133,9 +131,8 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("info<2>"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_NE(s.find("info<2>"), s.npos); #endif } ); diff --git a/test/diagnostic_info_test3.cpp b/test/diagnostic_info_test3.cpp index 0b3cdc9d..2de8e833 100644 --- a/test/diagnostic_info_test3.cpp +++ b/test/diagnostic_info_test3.cpp @@ -48,10 +48,11 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("41"), s.npos); - BOOST_TEST_EQ(s.find("42"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("41"), s.npos); + BOOST_TEST_EQ(s.find("42"), s.npos); + } #endif } ); diff --git a/test/diagnostic_info_test4.cpp b/test/diagnostic_info_test4.cpp index d93c10b8..18a7bf47 100644 --- a/test/diagnostic_info_test4.cpp +++ b/test/diagnostic_info_test4.cpp @@ -63,11 +63,12 @@ int main() st << e; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("new_error"), s.npos); - BOOST_TEST_NE(s.find("appended: 42"), s.npos); - BOOST_TEST_NE(s.find("appended: 43"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("new_error"), s.npos); + BOOST_TEST_NE(s.find("appended: 42"), s.npos); + BOOST_TEST_NE(s.find("appended: 43"), s.npos); + } #endif } ); diff --git a/test/diagnostic_info_test5.cpp b/test/diagnostic_info_test5.cpp index 75b336e2..142c1d79 100644 --- a/test/diagnostic_info_test5.cpp +++ b/test/diagnostic_info_test5.cpp @@ -94,25 +94,26 @@ int main() st << di; std::string s = st.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - auto const n1 = s.find("info<1>: acc=0"); - auto const n2 = s.find("info<2>: acc=0"); - auto const n3 = s.find("info<3>: acc=0"); - auto const n4 = s.find("info<4>: acc=2"); - auto const nd = s.find("Unhandled"); - BOOST_TEST_NE(n1, s.npos); - BOOST_TEST_NE(n2, s.npos); - BOOST_TEST_NE(n3, s.npos); - BOOST_TEST_NE(n4, s.npos); - BOOST_TEST_NE(nd, s.npos); - BOOST_TEST_LT(n1, nd); - BOOST_TEST_GT(n2, nd); - BOOST_TEST_GT(n3, nd); - BOOST_TEST_GT(n4, nd); - BOOST_TEST_EQ(counter, 4); -#else + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + auto const n1 = s.find("info<1>: acc=0"); + auto const n2 = s.find("info<2>: acc=0"); + auto const n3 = s.find("info<3>: acc=0"); + auto const n4 = s.find("info<4>: acc=2"); + auto const nd = s.find("Unhandled"); + BOOST_TEST_NE(n1, s.npos); + BOOST_TEST_NE(n2, s.npos); + BOOST_TEST_NE(n3, s.npos); + BOOST_TEST_NE(n4, s.npos); + BOOST_TEST_NE(nd, s.npos); + BOOST_TEST_LT(n1, nd); + BOOST_TEST_GT(n2, nd); + BOOST_TEST_GT(n3, nd); + BOOST_TEST_GT(n4, nd); + BOOST_TEST_EQ(counter, 4); + } + else BOOST_TEST_EQ(counter, 1); -#endif #endif }, [] diff --git a/test/dynamic_capture_print_test.cpp b/test/dynamic_capture_print_test.cpp index 1534f8c5..9b480403 100644 --- a/test/dynamic_capture_print_test.cpp +++ b/test/dynamic_capture_print_test.cpp @@ -48,21 +48,20 @@ struct e_err int main() { - std::string s; - (void) leaf::try_handle_all( + leaf::try_handle_all( []() -> leaf::result { return leaf::new_error(e_err{ }); }, [&]( leaf::dynamic_capture const & cap ) { - std::stringstream ss; - ss << cap; - s = ss.str(); + std::ostringstream st; + st << cap; + std::string s = st.str(); + std::cout << s << std::endl; + BOOST_TEST_NE(s.find("Captured error objects"), s.npos); + BOOST_TEST_NE(s.find("e_err"), s.npos); } ); - std::cout << s << std::endl; - BOOST_TEST_NE(s.find("Captured error objects"), s.npos); - BOOST_TEST_NE(s.find("e_err"), s.npos); return boost::report_errors(); } diff --git a/test/e_LastError_test.cpp b/test/e_LastError_test.cpp index 1f9b334f..53454818 100644 --- a/test/e_LastError_test.cpp +++ b/test/e_LastError_test.cpp @@ -38,7 +38,7 @@ int main() { SetLastError(ERROR_FILE_NOT_FOUND); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << leaf::windows::e_LastError{}; std::string s = ss.str(); std::cout << s << std::endl; diff --git a/test/e_errno_test.cpp b/test/e_errno_test.cpp index e9faa8fb..41ef6bf3 100644 --- a/test/e_errno_test.cpp +++ b/test/e_errno_test.cpp @@ -24,7 +24,7 @@ int main() { errno = ENOENT; #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << leaf::e_errno{}; std::string s = ss.str(); std::cout << s << std::endl; diff --git a/test/preload_basic_test.cpp b/test/preload_basic_test.cpp index 0a5504e4..31964589 100644 --- a/test/preload_basic_test.cpp +++ b/test/preload_basic_test.cpp @@ -11,11 +11,6 @@ # include #endif -#if BOOST_LEAF_CFG_STD_STRING -# include -# include -#endif - #include "lightweight_test.hpp" namespace leaf = boost::leaf; @@ -43,12 +38,6 @@ void test( G && g ) []( info<42> const & i42, leaf::diagnostic_info const & di ) { BOOST_TEST_EQ(i42.value, 42); -#if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; - ss << di; - std::string s = ss.str(); - std::cout << s << std::endl; -#endif return 1; }, [] diff --git a/test/print_test.cpp b/test/print_test.cpp index 57c1fa33..07cdaba4 100644 --- a/test/print_test.cpp +++ b/test/print_test.cpp @@ -5,7 +5,7 @@ #include -#if !BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_STD_STRING +#if !BOOST_LEAF_CFG_DIAGNOSTICS || !BOOST_LEAF_CFG_STD_STRING #include diff --git a/test/result_print_test.cpp b/test/result_print_test.cpp index 4131cc23..c1d70bf8 100644 --- a/test/result_print_test.cpp +++ b/test/result_print_test.cpp @@ -38,13 +38,12 @@ int main() leaf::result r = 42; BOOST_TEST(r); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << r; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_EQ(s, "42"); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_EQ(s, "42"); #endif } @@ -52,13 +51,12 @@ int main() leaf::result r; BOOST_TEST(r); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << r; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_EQ(s, "{not printable}"); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_EQ(s, "{not printable}"); #endif } @@ -66,13 +64,12 @@ int main() leaf::result r; BOOST_TEST(r); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << r; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_EQ(s, "No error"); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_EQ(s, "No error"); #endif } @@ -80,14 +77,13 @@ int main() leaf::result r = leaf::new_error(e_err{ }); BOOST_TEST(!r); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << r; std::string s = ss.str(); std::cout << s << std::endl; leaf::error_id err = r.error(); -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_EQ(s, "Error ID " + std::to_string(err.value())); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + BOOST_TEST_EQ(s, "Error ID " + std::to_string(err.value())); #endif } @@ -103,16 +99,17 @@ int main() return cap; } ); #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; + std::ostringstream ss; ss << r; std::string s = ss.str(); std::cout << s << std::endl; leaf::error_id err = r.error(); BOOST_TEST_NE(s.find("Error ID " + std::to_string(err.value())), s.npos); -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("Captured error objects"), s.npos); - BOOST_TEST_NE(s.find("e_err"), s.npos); -#endif + if( BOOST_LEAF_CFG_DIAGNOSTICS ) + { + BOOST_TEST_NE(s.find("Captured error objects"), s.npos); + BOOST_TEST_NE(s.find("e_err"), s.npos); + } #endif } #endif diff --git a/test/tls_array_alloc_test1.cpp b/test/tls_array_alloc_test1.cpp index f092bc35..be19364c 100644 --- a/test/tls_array_alloc_test1.cpp +++ b/test/tls_array_alloc_test1.cpp @@ -3,9 +3,25 @@ // 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) -#define BOOST_LEAF_NO_EXCEPTIONS +#ifndef BOOST_LEAF_NO_EXCEPTIONS +# define BOOST_LEAF_NO_EXCEPTIONS +#endif + +#ifdef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +# undef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +#endif #define BOOST_LEAF_CFG_STD_SYSTEM_ERROR 0 + +#ifdef BOOST_LEAF_CFG_DIAGNOSTICS +# undef BOOST_LEAF_CFG_DIAGNOSTICS +#endif +#define BOOST_LEAF_CFG_DIAGNOSTICS 0 + +#ifdef BOOST_LEAF_CFG_CAPTURE +# undef BOOST_LEAF_CFG_CAPTURE +#endif #define BOOST_LEAF_CFG_CAPTURE 0 + #define BOOST_LEAF_USE_TLS_ARRAY #define BOOST_LEAF_CFG_TLS_ARRAY_SIZE 64 #define BOOST_LEAF_CFG_TLS_ARRAY_START_INDEX 10 diff --git a/test/tls_array_alloc_test2.cpp b/test/tls_array_alloc_test2.cpp index dea5e936..07b8885f 100644 --- a/test/tls_array_alloc_test2.cpp +++ b/test/tls_array_alloc_test2.cpp @@ -3,9 +3,25 @@ // 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) -#define BOOST_LEAF_NO_EXCEPTIONS +#ifndef BOOST_LEAF_NO_EXCEPTIONS +# define BOOST_LEAF_NO_EXCEPTIONS +#endif + +#ifdef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +# undef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +#endif #define BOOST_LEAF_CFG_STD_SYSTEM_ERROR 0 + +#ifdef BOOST_LEAF_CFG_DIAGNOSTICS +# undef BOOST_LEAF_CFG_DIAGNOSTICS +#endif +#define BOOST_LEAF_CFG_DIAGNOSTICS 0 + +#ifdef BOOST_LEAF_CFG_CAPTURE +# undef BOOST_LEAF_CFG_CAPTURE +#endif #define BOOST_LEAF_CFG_CAPTURE 0 + #define BOOST_LEAF_USE_TLS_ARRAY #define BOOST_LEAF_CFG_TLS_ARRAY_SIZE 64 #define BOOST_LEAF_CFG_TLS_ARRAY_START_INDEX 10 diff --git a/test/tls_array_alloc_test3.cpp b/test/tls_array_alloc_test3.cpp index fdfc777f..01042766 100644 --- a/test/tls_array_alloc_test3.cpp +++ b/test/tls_array_alloc_test3.cpp @@ -3,9 +3,25 @@ // 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) -#define BOOST_LEAF_NO_EXCEPTIONS +#ifndef BOOST_LEAF_NO_EXCEPTIONS +# define BOOST_LEAF_NO_EXCEPTIONS +#endif + +#ifdef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +# undef BOOST_LEAF_CFG_STD_SYSTEM_ERROR +#endif #define BOOST_LEAF_CFG_STD_SYSTEM_ERROR 0 + +#ifdef BOOST_LEAF_CFG_DIAGNOSTICS +# undef BOOST_LEAF_CFG_DIAGNOSTICS +#endif +#define BOOST_LEAF_CFG_DIAGNOSTICS 0 + +#ifdef BOOST_LEAF_CFG_CAPTURE +# undef BOOST_LEAF_CFG_CAPTURE +#endif #define BOOST_LEAF_CFG_CAPTURE 0 + #define BOOST_LEAF_USE_TLS_ARRAY #define BOOST_LEAF_CFG_TLS_ARRAY_SIZE 64 #define BOOST_LEAF_CFG_TLS_ARRAY_START_INDEX 10 diff --git a/test/visibility_test.cpp b/test/visibility_test.cpp index c02756cb..5304fea3 100644 --- a/test/visibility_test.cpp +++ b/test/visibility_test.cpp @@ -40,23 +40,10 @@ int main() if( BOOST_LEAF_CFG_DIAGNOSTICS ) { #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; ss << info; + std::ostringstream ss; ss << vinfo; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("1 attempt to communicate an unexpected error object"), std::string::npos); -#endif -#endif - } - if( BOOST_LEAF_CFG_DIAGNOSTICS ) - { -#if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; ss << vinfo; - std::string s = ss.str(); - std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS BOOST_TEST_NE(s.find("Test my_info<3>::value = 3"), std::string::npos); -#endif #endif } return 1; @@ -83,23 +70,10 @@ int main() if( BOOST_LEAF_CFG_DIAGNOSTICS ) { #if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; ss << info; + std::ostringstream ss; ss << vinfo; std::string s = ss.str(); std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS - BOOST_TEST_NE(s.find("1 attempt to communicate an unexpected error object"), std::string::npos); -#endif -#endif - } - if( BOOST_LEAF_CFG_DIAGNOSTICS ) - { -#if BOOST_LEAF_CFG_STD_STRING - std::stringstream ss; ss << vinfo; - std::string s = ss.str(); - std::cout << s << std::endl; -#if BOOST_LEAF_CFG_DIAGNOSTICS BOOST_TEST_NE(s.find("Test my_info<3>::value = 3"), std::string::npos); -#endif #endif } return 1;