diff --git a/test/regress/main.cpp b/test/regress/main.cpp index 0fcd0921..f9527e41 100644 --- a/test/regress/main.cpp +++ b/test/regress/main.cpp @@ -184,19 +184,6 @@ const int* make_array(int first, ...) return data; } -#ifdef BOOST_NO_EXCEPTIONS - -namespace boost{ - -void throw_exception(std::exception const & e) -{ - std::abort(); -} - -} - -#endif - void test(const char& c, const test_regex_replace_tag& tag) { do_test(c, tag); @@ -225,7 +212,7 @@ void test(const wchar_t& c, const test_invalid_regex_tag& tag) } #endif -#ifdef BOOST_NO_EXCETIONS +#ifdef BOOST_NO_EXCEPTIONS namespace boost{ void throw_exception( std::exception const & e ) @@ -235,6 +222,14 @@ void throw_exception( std::exception const & e ) } } -#endif + +int main(int argc, char * argv[]) +{ + return cpp_main(argc, argv); +} + +#else #include + +#endif diff --git a/test/regress/test_deprecated.cpp b/test/regress/test_deprecated.cpp index 276fa599..493c02b2 100644 --- a/test/regress/test_deprecated.cpp +++ b/test/regress/test_deprecated.cpp @@ -136,7 +136,10 @@ void test_deprecated(const char&, const test_regex_search_tag&) // if(test_info::syntax_options() & ~boost::regex::icase) return; - try{ +#ifndef BOOST_NO_EXCEPTIONS + try +#endif + { boost::RegEx e(expression, (test_info::syntax_options() & boost::regex::icase) != 0); if(e.error_code()) { @@ -180,6 +183,7 @@ void test_deprecated(const char&, const test_regex_search_tag&) } } } +#ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression& r) { BOOST_REGEX_TEST_ERROR("Expression did not compile with RegEx class: " << r.what(), char); @@ -196,7 +200,7 @@ void test_deprecated(const char&, const test_regex_search_tag&) { BOOST_REGEX_TEST_ERROR("Unexpected exception of unknown type", char); } - +#endif } void test_deprecated(const wchar_t&, const test_regex_search_tag&) @@ -302,11 +306,15 @@ void test_deprecated(const char&, const test_invalid_regex_tag&) if(test_info::syntax_options() & ~boost::regex::icase) return; bool have_catch = false; - try{ +#ifndef BOOST_NO_EXCEPTIONS + try +#endif + { boost::RegEx e(expression, (test_info::syntax_options() & boost::regex::icase) != 0); if(e.error_code()) have_catch = true; } +#ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression&) { have_catch = true; @@ -326,6 +334,7 @@ void test_deprecated(const char&, const test_invalid_regex_tag&) have_catch = true; BOOST_REGEX_TEST_ERROR("Expected a bad_expression exception, but got an exception of unknown type instead", char); } +#endif if(!have_catch) { // oops expected exception was not thrown: diff --git a/test/regress/test_locale.cpp b/test/regress/test_locale.cpp index 7bbefa4e..20fbc004 100644 --- a/test/regress/test_locale.cpp +++ b/test/regress/test_locale.cpp @@ -47,7 +47,7 @@ test_locale::test_locale(const char* c_name, boost::uint32_t lcid) #else s_c_locale = no_test; #endif -#ifndef BOOST_NO_STD_LOCALE +#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_EXCEPTIONS) // back up the C++ locale and create the new one: m_old_cpp_locale = s_cpp_locale_inst; m_old_cpp_state = s_cpp_locale; @@ -55,7 +55,8 @@ test_locale::test_locale(const char* c_name, boost::uint32_t lcid) s_cpp_locale_inst = std::locale(c_name); s_cpp_locale = test_with_locale; std::cout << "Testing the C++ locale: " << c_name << std::endl; - }catch(std::runtime_error const &) + } + catch(std::runtime_error const &) { s_cpp_locale = no_test; std::cout << "The C++ locale: " << c_name << " is not available and will not be tested." << std::endl; diff --git a/test/regress/test_not_regex.hpp b/test/regress/test_not_regex.hpp index 18dfccfb..24c22ff3 100644 --- a/test/regress/test_not_regex.hpp +++ b/test/regress/test_not_regex.hpp @@ -62,7 +62,9 @@ void test(boost::basic_regex& r, const test_invalid_regex_tag&) // // try it with exceptions disabled first: // +#ifndef BOOST_NO_EXCEPTIONS try +#endif { if(0 == r.assign(expression, syntax_options | boost::regex_constants::no_except).status()) { @@ -70,21 +72,27 @@ void test(boost::basic_regex& r, const test_invalid_regex_tag&) } test_empty(r); } +#ifndef BOOST_NO_EXCEPTIONS catch(...) { BOOST_REGEX_TEST_ERROR("Unexpected exception thrown.", charT); } +#endif // // now try again with exceptions: // bool have_catch = false; - try{ +#ifndef BOOST_NO_EXCEPTIONS + try +#endif + { r.assign(expression, syntax_options); #ifdef BOOST_NO_EXCEPTIONS if(r.status()) have_catch = true; #endif } +#ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression&) { have_catch = true; @@ -105,6 +113,7 @@ void test(boost::basic_regex& r, const test_invalid_regex_tag&) have_catch = true; BOOST_REGEX_TEST_ERROR("Expected a bad_expression exception, but got an exception of unknown type instead", charT); } +#endif if(!have_catch) { // oops expected exception was not thrown: diff --git a/test/regress/test_regex_replace.hpp b/test/regress/test_regex_replace.hpp index 2165d7d1..cc029748 100644 --- a/test/regress/test_regex_replace.hpp +++ b/test/regress/test_regex_replace.hpp @@ -44,7 +44,10 @@ void test(boost::basic_regex& r, const test_regex_replace_tag&) { const std::basic_string& expression = test_info::expression(); boost::regex_constants::syntax_option_type syntax_options = test_info::syntax_options(); - try{ +#ifndef BOOST_NO_EXCEPTIONS + try +#endif + { r.assign(expression, syntax_options); if(r.status()) { @@ -52,6 +55,7 @@ void test(boost::basic_regex& r, const test_regex_replace_tag&) } test_regex_replace(r); } +#ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression& e) { BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done: " << e.what(), charT); @@ -68,6 +72,7 @@ void test(boost::basic_regex& r, const test_regex_replace_tag&) { BOOST_REGEX_TEST_ERROR("Received an unexpected exception of unknown type", charT); } +#endif } diff --git a/test/regress/test_regex_search.hpp b/test/regress/test_regex_search.hpp index 66cb248b..411d943a 100644 --- a/test/regress/test_regex_search.hpp +++ b/test/regress/test_regex_search.hpp @@ -476,7 +476,10 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) { const std::basic_string& expression = test_info::expression(); boost::regex_constants::syntax_option_type syntax_options = test_info::syntax_options(); - try{ +#ifndef BOOST_NO_EXCEPTIONS + try +#endif + { r.assign(expression, syntax_options); if(r.status()) { @@ -494,6 +497,7 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) // // Verify sub-expression locations: // +#ifndef BOOST_NO_EXCEPTIONS if((syntax_options & boost::regbase::save_subexpression_location) == 0) { bool have_except = false; @@ -510,6 +514,7 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) BOOST_REGEX_TEST_ERROR("Expected std::out_of_range error was not found.", charT); } } +#endif r.assign(expression, syntax_options | boost::regbase::save_subexpression_location); for(std::size_t i = 0; i < r.mark_count(); ++i) { @@ -524,6 +529,7 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) } } } +#ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression& e) { BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done: " << e.what(), charT); @@ -540,7 +546,7 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) { BOOST_REGEX_TEST_ERROR("Received an unexpected exception of unknown type", charT); } - +#endif }