diff -r 510d5bd079ad boost/test/execution_monitor.hpp
a
|
b
|
|
82 | 82 | |
83 | 83 | // design rationale: fear of being out (or nearly out) of memory. |
84 | 84 | |
85 | | class BOOST_TEST_DECL execution_exception { |
| 85 | class BOOST_TEST_DECL execution_exception : public std::exception { |
86 | 86 | typedef boost::unit_test::const_string const_string; |
87 | 87 | public: |
88 | 88 | enum error_code { |
… |
… |
|
119 | 119 | |
120 | 120 | // access methods |
121 | 121 | error_code code() const { return m_error_code; } |
122 | | const_string what() const { return m_what; } |
| 122 | const char* what() const throw() { return m_what.begin(); } |
123 | 123 | |
124 | 124 | private: |
125 | 125 | // Data members |
… |
… |
|
203 | 203 | { |
204 | 204 | try { |
205 | 205 | return m_next ? (*m_next)( F ) : F(); |
206 | | } catch( Exception const& e ) { |
| 206 | } |
| 207 | #ifndef BOOST_NO_EXCEPTIONS |
| 208 | catch( Exception const& e ) { |
207 | 209 | m_translator( e ); |
208 | 210 | return boost::exit_exception_failure; |
209 | 211 | } |
| 212 | #endif |
210 | 213 | } |
211 | 214 | |
212 | 215 | private: |
… |
… |
|
228 | 231 | // ************** execution_aborted ************** // |
229 | 232 | // ************************************************************************** // |
230 | 233 | |
231 | | struct execution_aborted {}; |
| 234 | struct execution_aborted : public std::exception {}; |
232 | 235 | |
233 | 236 | // ************************************************************************** // |
234 | 237 | // ************** system_error ************** // |
235 | 238 | // ************************************************************************** // |
236 | 239 | |
237 | | class system_error { |
| 240 | class system_error : public std::exception { |
238 | 241 | public: |
239 | 242 | // Constructor |
240 | 243 | explicit system_error( char const* exp ); |
… |
… |
|
243 | 246 | unit_test::readonly_property<char const*> p_failed_exp; |
244 | 247 | }; |
245 | 248 | |
246 | | #define BOOST_TEST_SYS_ASSERT( exp ) if( (exp) ) ; else throw ::boost::system_error( BOOST_STRINGIZE( exp ) ) |
| 249 | #define BOOST_TEST_SYS_ASSERT( exp ) if( (exp) ) ; else boost::throw_exception( ::boost::system_error( BOOST_STRINGIZE( exp ) ) ); |
247 | 250 | |
248 | 251 | } // namespace boost |
249 | 252 | |
diff -r 510d5bd079ad boost/test/impl/cpp_main.ipp
a
|
b
|
|
84 | 84 | result = ::boost::exit_failure; |
85 | 85 | } |
86 | 86 | } |
| 87 | #ifndef BOOST_NO_EXCEPTIONS |
87 | 88 | catch( ::boost::execution_exception const& exex ) { |
88 | 89 | std::cout << "\n**** exception(" << exex.code() << "): " << exex.what() << std::endl; |
89 | 90 | result = ::boost::exit_exception_failure; |
… |
… |
|
94 | 95 | << "\n**** error(" << ex.p_errno << "): " << std::strerror( ex.p_errno ) << std::endl; |
95 | 96 | result = ::boost::exit_exception_failure; |
96 | 97 | } |
| 98 | #endif |
97 | 99 | |
98 | 100 | if( result != ::boost::exit_success ) { |
99 | 101 | std::cerr << "******** errors detected; see standard output for details ********" << std::endl; |
diff -r 510d5bd079ad boost/test/impl/exception_safety.ipp
a
|
b
|
|
17 | 17 | |
18 | 18 | // Boost.Test |
19 | 19 | #include <boost/test/detail/config.hpp> |
| 20 | #include <boost/throw_exception.hpp> |
20 | 21 | |
21 | 22 | #if !BOOST_WORKAROUND(__GNUC__, < 3) && \ |
22 | 23 | !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ |
… |
… |
|
106 | 107 | |
107 | 108 | struct exception_safety_tester : itest::manager, test_observer { |
108 | 109 | // helpers types |
109 | | struct unique_exception {}; |
| 110 | struct unique_exception : std::exception {}; |
110 | 111 | |
111 | 112 | // Constructor |
112 | 113 | explicit exception_safety_tester( const_string test_name ); |
… |
… |
|
393 | 394 | if( m_exec_path_counter == m_break_exec_path ) |
394 | 395 | debug::debugger_break(); |
395 | 396 | |
396 | | throw unique_exception(); |
| 397 | boost::throw_exception(unique_exception()); |
397 | 398 | } |
398 | 399 | |
399 | 400 | //____________________________________________________________________________// |
diff -r 510d5bd079ad boost/test/impl/execution_monitor.ipp
a
|
b
|
|
31 | 31 | #include <boost/test/debug.hpp> |
32 | 32 | |
33 | 33 | // Boost |
| 34 | #include <boost/throw_exception.hpp> |
34 | 35 | #include <boost/cstdlib.hpp> // for exit codes |
35 | 36 | #include <boost/config.hpp> // for workarounds |
36 | 37 | |
… |
… |
|
191 | 192 | BOOST_TEST_VSNPRINTF( buf, sizeof(buf), format, args ); |
192 | 193 | va_end( args ); |
193 | 194 | |
194 | | throw execution_exception( ec, buf ); |
| 195 | boost::throw_exception(execution_exception( ec, buf )); |
195 | 196 | } |
196 | 197 | |
197 | 198 | //____________________________________________________________________________// |
… |
… |
|
219 | 220 | // ************** boost::detail::system_signal_exception ************** // |
220 | 221 | // ************************************************************************** // |
221 | 222 | |
222 | | class system_signal_exception { |
| 223 | class system_signal_exception : public std::exception { |
223 | 224 | public: |
224 | 225 | // Constructor |
225 | 226 | system_signal_exception() |
… |
… |
|
727 | 728 | |
728 | 729 | if( !sigsetjmp( signal_handler::jump_buffer(), 1 ) ) |
729 | 730 | return detail::do_invoke( m_custom_translators , F ); |
730 | | else |
731 | | throw local_signal_handler.sys_sig(); |
| 731 | else { |
| 732 | boost::throw_exception(local_signal_handler.sys_sig()); |
| 733 | return 0; |
| 734 | } |
732 | 735 | } |
733 | 736 | |
734 | 737 | //____________________________________________________________________________// |
… |
… |
|
1063 | 1066 | // required. Programmers ask for const anyhow, so we supply it. That's |
1064 | 1067 | // easier than answering questions about non-const usage. |
1065 | 1068 | |
| 1069 | #ifndef BOOST_NO_EXCEPTIONS |
| 1070 | |
1066 | 1071 | catch( char const* ex ) |
1067 | 1072 | { detail::report_error( execution_exception::cpp_exception_error, "C string: %s", ex ); } |
1068 | 1073 | catch( std::string const& ex ) |
… |
… |
|
1121 | 1126 | catch( ... ) |
1122 | 1127 | { detail::report_error( execution_exception::cpp_exception_error, "unknown type" ); } |
1123 | 1128 | |
| 1129 | #endif // BOOST_NO_EXCEPTIONS |
| 1130 | |
1124 | 1131 | return 0; // never reached; supplied to quiet compiler warnings |
1125 | 1132 | } // execute |
1126 | 1133 | |
diff -r 510d5bd079ad boost/test/impl/framework.ipp
a
|
b
|
|
34 | 34 | #include <boost/test/utils/foreach.hpp> |
35 | 35 | |
36 | 36 | // Boost |
| 37 | #include <boost/throw_exception.hpp> |
37 | 38 | #include <boost/timer.hpp> |
38 | 39 | |
39 | 40 | // STL |
… |
… |
|
88 | 89 | { |
89 | 90 | #ifdef BOOST_TEST_ALTERNATIVE_INIT_API |
90 | 91 | if( !(*m_init_func)() ) |
91 | | throw std::runtime_error( "test module initialization failed" ); |
| 92 | boost::throw_exception(std::runtime_error( "test module initialization failed" )); |
92 | 93 | #else |
93 | 94 | test_suite* manual_test_units = (*m_init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv ); |
94 | 95 | |
… |
… |
|
162 | 163 | m_curr_test_case = bkup; |
163 | 164 | |
164 | 165 | if( unit_test_monitor.is_critical_error( run_result ) ) |
165 | | throw test_being_aborted(); |
| 166 | boost::throw_exception(test_being_aborted()); |
166 | 167 | } |
167 | 168 | |
168 | 169 | bool test_suite_start( test_suite const& ts ) |
… |
… |
|
257 | 258 | |
258 | 259 | em.execute( tic ); |
259 | 260 | } |
| 261 | #ifndef BOOST_NO_EXCEPTIONS |
260 | 262 | catch( execution_exception const& ex ) { |
261 | 263 | throw setup_error( ex.what() ); |
262 | 264 | } |
| 265 | #endif |
263 | 266 | |
264 | 267 | s_frk_impl().m_is_initialized = true; |
265 | 268 | } |
… |
… |
|
278 | 281 | register_test_unit( test_case* tc ) |
279 | 282 | { |
280 | 283 | if( tc->p_id != INV_TEST_UNIT_ID ) |
281 | | throw setup_error( BOOST_TEST_L( "test case already registered" ) ); |
| 284 | boost::throw_exception(setup_error( BOOST_TEST_L( "test case already registered" ) )); |
282 | 285 | |
283 | 286 | test_unit_id new_id = s_frk_impl().m_next_test_case_id; |
284 | 287 | |
285 | 288 | if( new_id == MAX_TEST_CASE_ID ) |
286 | | throw setup_error( BOOST_TEST_L( "too many test cases" ) ); |
| 289 | boost::throw_exception(setup_error( BOOST_TEST_L( "too many test cases" ) )); |
287 | 290 | |
288 | 291 | typedef framework_impl::test_unit_store::value_type map_value_type; |
289 | 292 | |
… |
… |
|
299 | 302 | register_test_unit( test_suite* ts ) |
300 | 303 | { |
301 | 304 | if( ts->p_id != INV_TEST_UNIT_ID ) |
302 | | throw setup_error( BOOST_TEST_L( "test suite already registered" ) ); |
| 305 | boost::throw_exception(setup_error( BOOST_TEST_L( "test suite already registered" ) )); |
303 | 306 | |
304 | 307 | test_unit_id new_id = s_frk_impl().m_next_test_suite_id; |
305 | 308 | |
306 | 309 | if( new_id == MAX_TEST_SUITE_ID ) |
307 | | throw setup_error( BOOST_TEST_L( "too many test suites" ) ); |
| 310 | boost::throw_exception(setup_error( BOOST_TEST_L( "too many test suites" ) )); |
308 | 311 | |
309 | 312 | typedef framework_impl::test_unit_store::value_type map_value_type; |
310 | 313 | s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) ); |
… |
… |
|
364 | 367 | test_unit* res = s_frk_impl().m_test_units[id]; |
365 | 368 | |
366 | 369 | if( (res->p_type & t) == 0 ) |
367 | | throw internal_error( "Invalid test unit type" ); |
| 370 | boost::throw_exception(internal_error( "Invalid test unit type" )); |
368 | 371 | |
369 | 372 | return *res; |
370 | 373 | } |
… |
… |
|
381 | 384 | traverse_test_tree( id, tcc ); |
382 | 385 | |
383 | 386 | if( tcc.p_count == 0 ) |
384 | | throw setup_error( runtime_config::test_to_run().is_empty() |
385 | | ? BOOST_TEST_L( "test tree is empty" ) |
386 | | : BOOST_TEST_L( "no test cases matching filter" ) ); |
| 387 | boost::throw_exception(setup_error( runtime_config::test_to_run().is_empty() |
| 388 | ? BOOST_TEST_L( "test tree is empty" ) |
| 389 | : BOOST_TEST_L( "no test cases matching filter" ) )); |
387 | 390 | |
388 | 391 | bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress; |
389 | 392 | bool was_in_progress = s_frk_impl().m_test_in_progress; |
… |
… |
|
397 | 400 | try { |
398 | 401 | em.execute( ut_detail::test_start_caller( to, tcc.p_count ) ); |
399 | 402 | } |
| 403 | #ifndef BOOST_NO_EXCEPTIONS |
400 | 404 | catch( execution_exception const& ex ) { |
401 | | throw setup_error( ex.what() ); |
| 405 | boost::throw_exception(setup_error( ex.what() )); |
402 | 406 | } |
| 407 | #endif |
403 | 408 | } |
404 | 409 | } |
405 | 410 | |
diff -r 510d5bd079ad boost/test/impl/interaction_based.ipp
a
|
b
|
|
31 | 31 | #include <boost/test/framework.hpp> // for setup_error |
32 | 32 | |
33 | 33 | #include <boost/test/detail/suppress_warnings.hpp> |
| 34 | #include <boost/throw_exception.hpp> |
34 | 35 | |
35 | 36 | // STL |
36 | 37 | #include <stdexcept> |
… |
… |
|
70 | 71 | if( reset ) { |
71 | 72 | if( new_ptr ) { |
72 | 73 | if( ptr != &dummy ) |
73 | | throw unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) ); |
| 74 | boost::throw_exception( unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) )); |
74 | 75 | |
75 | 76 | ptr = new_ptr; |
76 | 77 | } |
diff -r 510d5bd079ad boost/test/impl/test_tools.ipp
a
|
b
|
|
25 | 25 | |
26 | 26 | // Boost |
27 | 27 | #include <boost/config.hpp> |
| 28 | #include <boost/throw_exception.hpp> |
28 | 29 | |
29 | 30 | // STL |
30 | 31 | #include <fstream> |
… |
… |
|
70 | 71 | using namespace unit_test; |
71 | 72 | |
72 | 73 | if( !framework::is_initialized() ) |
73 | | throw std::runtime_error( "can't use testing tools before framework is initialized" ); |
| 74 | boost::throw_exception(std::runtime_error( "can't use testing tools before framework is initialized" )); |
74 | 75 | |
75 | 76 | if( !!pr ) |
76 | 77 | tl = PASS; |
… |
… |
|
319 | 320 | |
320 | 321 | framework::test_unit_aborted( framework::current_test_case() ); |
321 | 322 | |
322 | | throw execution_aborted(); |
| 323 | boost::throw_exception(execution_aborted()); |
323 | 324 | } |
324 | 325 | } |
325 | 326 | |
diff -r 510d5bd079ad boost/test/impl/unit_test_main.ipp
a
|
b
|
|
182 | 182 | ? boost::exit_success |
183 | 183 | : results_collector.results( framework::master_test_suite().p_id ).result_code(); |
184 | 184 | } |
| 185 | #ifndef BOOST_NO_EXCEPTIONS |
185 | 186 | catch( framework::internal_error const& ex ) { |
186 | 187 | results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl; |
187 | 188 | |
… |
… |
|
197 | 198 | |
198 | 199 | return boost::exit_exception_failure; |
199 | 200 | } |
| 201 | #endif |
200 | 202 | } |
201 | 203 | |
202 | 204 | } // namespace unit_test |
diff -r 510d5bd079ad boost/test/impl/unit_test_monitor.ipp
a
|
b
|
|
68 | 68 | |
69 | 69 | execute( callback0<int>( zero_return_wrapper( tc.test_func() ) ) ); |
70 | 70 | } |
| 71 | #ifndef BOOST_NO_EXCEPTIONS |
71 | 72 | catch( execution_exception const& ex ) { |
72 | 73 | framework::exception_caught( ex ); |
73 | 74 | framework::test_unit_aborted( framework::current_test_case() ); |
… |
… |
|
84 | 85 | default: return unexpected_exception; |
85 | 86 | } |
86 | 87 | } |
| 88 | #endif |
87 | 89 | |
88 | 90 | return test_ok; |
89 | 91 | } |
diff -r 510d5bd079ad boost/test/impl/unit_test_suite.ipp
a
|
b
|
|
205 | 205 | BOOST_TEST_FOREACH( test_unit_id, id, members ) |
206 | 206 | traverse_test_tree( id, V ); |
207 | 207 | } |
208 | | |
209 | | } catch( test_being_aborted const& ) { |
| 208 | } |
| 209 | #ifndef BOOST_NO_EXCEPTIONS |
| 210 | catch( test_being_aborted const& ) { |
210 | 211 | V.test_suite_finish( suite ); |
211 | 212 | framework::test_unit_aborted( suite ); |
212 | 213 | |
213 | 214 | throw; |
214 | 215 | } |
| 216 | #endif |
215 | 217 | |
216 | 218 | V.test_suite_finish( suite ); |
217 | 219 | } |
diff -r 510d5bd079ad boost/test/interaction_based.hpp
a
|
b
|
|
18 | 18 | // Boost.Test |
19 | 19 | #include <boost/test/detail/config.hpp> |
20 | 20 | #include <boost/test/detail/global_typedef.hpp> |
| 21 | #include <boost/throw_exception.hpp> |
21 | 22 | |
22 | 23 | #include <boost/test/utils/wrap_stringstream.hpp> |
23 | 24 | |
… |
… |
|
210 | 211 | if( res ) |
211 | 212 | ::boost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s ); |
212 | 213 | else |
213 | | throw std::bad_alloc(); |
| 214 | boost::throw_exception(std::bad_alloc()); |
214 | 215 | |
215 | 216 | return res; |
216 | 217 | } |
… |
… |
|
225 | 226 | if( res ) |
226 | 227 | ::boost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s ); |
227 | 228 | else |
228 | | throw std::bad_alloc(); |
| 229 | boost::throw_exception(std::bad_alloc()); |
229 | 230 | |
230 | 231 | return res; |
231 | 232 | } |
diff -r 510d5bd079ad boost/test/minimal.hpp
a
|
b
|
|
82 | 82 | { |
83 | 83 | report_error( msg, file, line, func_name, is_msg ); |
84 | 84 | |
85 | | throw boost::execution_aborted(); |
| 85 | boost::throw_exception(boost::execution_aborted()); |
86 | 86 | } |
87 | 87 | |
88 | 88 | class caller { |
… |
… |
|
116 | 116 | |
117 | 117 | BOOST_CHECK( run_result == 0 || run_result == boost::exit_success ); |
118 | 118 | } |
| 119 | #ifndef BOOST_NO_EXCEPTIONS |
119 | 120 | catch( boost::execution_exception const& exex ) { |
120 | 121 | if( exex.code() != boost::execution_exception::no_error ) |
121 | 122 | BOOST_ERROR( (std::string( "exception \"" ). |
… |
… |
|
123 | 124 | append( "\" caught" ) ).c_str() ); |
124 | 125 | std::cerr << "\n**** Testing aborted."; |
125 | 126 | } |
| 127 | #endif |
126 | 128 | |
127 | 129 | if( boost::minimal_test::errors_counter() != 0 ) { |
128 | 130 | std::cerr << "\n**** " << errors_counter() |
diff -r 510d5bd079ad boost/test/unit_test_suite_impl.hpp
a
|
b
|
|
214 | 214 | // ************** test_being_aborted ************** // |
215 | 215 | // ************************************************************************** // |
216 | 216 | |
217 | | struct BOOST_TEST_DECL test_being_aborted {}; |
| 217 | struct BOOST_TEST_DECL test_being_aborted : public std::exception {}; |
218 | 218 | |
219 | 219 | // ************************************************************************** // |
220 | 220 | // ************** object generators ************** // |
diff -r 510d5bd079ad boost/test/utils/named_params.hpp
a
|
b
|
|
18 | 18 | // Boost |
19 | 19 | #include <boost/config.hpp> |
20 | 20 | #include <boost/detail/workaround.hpp> |
| 21 | #include <boost/throw_exception.hpp> |
21 | 22 | |
22 | 23 | // Boost.Test |
23 | 24 | #include <boost/test/utils/rtti.hpp> |
… |
… |
|
46 | 47 | // ************** access_to_invalid_parameter ************** // |
47 | 48 | // ************************************************************************** // |
48 | 49 | |
49 | | struct access_to_invalid_parameter {}; |
| 50 | struct access_to_invalid_parameter : public std::exception {}; |
50 | 51 | |
51 | 52 | //____________________________________________________________________________// |
52 | 53 | |
53 | 54 | inline void |
54 | 55 | report_access_to_invalid_parameter() |
55 | 56 | { |
56 | | throw access_to_invalid_parameter(); |
| 57 | boost::throw_exception(access_to_invalid_parameter()); |
57 | 58 | } |
58 | 59 | |
59 | 60 | //____________________________________________________________________________// |