#ifndef __BSL_TEST_EXCEPTION_H_ #define __BSL_TEST_EXCEPTION_H_ #include #include "bsl/exception/bsl_exception.h" #include "bsl_test_exception_prepare.h_" class test_exception : public CxxTest::TestSuite { public: void test_UnknownException_info_a(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(true); }catch( bsl::UnknownException& ex ){ const char * what = "true"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_b(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(true); }catch( bsl::Exception& ex ){ const char * what = "true"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_c(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(true); }catch( bsl::UnknownException& ex ){ const char * what = "true"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_d(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(true); }catch( bsl::Exception& ex ){ const char * what = "true"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_e(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(false); }catch( bsl::UnknownException& ex ){ const char * what = "false"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_f(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(false); }catch( bsl::Exception& ex ){ const char * what = "false"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_g(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(false); }catch( bsl::UnknownException& ex ){ const char * what = "false"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_h(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(false); }catch( bsl::Exception& ex ){ const char * what = "false"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_i(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(true).push(false).push(true); }catch( bsl::UnknownException& ex ){ const char * what = "truefalsetrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_j(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(true).push(false).push(true); }catch( bsl::Exception& ex ){ const char * what = "truefalsetrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ba(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(true).push(false).push(true); }catch( bsl::UnknownException& ex ){ const char * what = "truefalsetrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bb(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(true).push(false).push(true); }catch( bsl::Exception& ex ){ const char * what = "truefalsetrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bc(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123); }catch( bsl::UnknownException& ex ){ const char * what = "123"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bd(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123); }catch( bsl::Exception& ex ){ const char * what = "123"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_be(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123); }catch( bsl::UnknownException& ex ){ const char * what = "123"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bf(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123); }catch( bsl::Exception& ex ){ const char * what = "123"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bg(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123).push(-456).push(+789).push(0); }catch( bsl::UnknownException& ex ){ const char * what = "123-4567890"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bh(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123).push(-456).push(+789).push(0); }catch( bsl::Exception& ex ){ const char * what = "123-4567890"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bi(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123).push(-456).push(+789).push(0); }catch( bsl::UnknownException& ex ){ const char * what = "123-4567890"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_bj(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123).push(-456).push(+789).push(0); }catch( bsl::Exception& ex ){ const char * what = "123-4567890"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ca(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123.456).push(-1.2e+100).push(3.14e-50); }catch( bsl::UnknownException& ex ){ const char * what = "123.456-1.2e+1003.14e-50"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cb(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(123.456).push(-1.2e+100).push(3.14e-50); }catch( bsl::Exception& ex ){ const char * what = "123.456-1.2e+1003.14e-50"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cc(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123.456).push(-1.2e+100).push(3.14e-50); }catch( bsl::UnknownException& ex ){ const char * what = "123.456-1.2e+1003.14e-50"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cd(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(123.456).push(-1.2e+100).push(3.14e-50); }catch( bsl::Exception& ex ){ const char * what = "123.456-1.2e+1003.14e-50"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ce(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push('a').push(char(0)).push('b').push(4,'x'); }catch( bsl::UnknownException& ex ){ const char * what = "abxxxx"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cf(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push('a').push(char(0)).push('b').push(4,'x'); }catch( bsl::Exception& ex ){ const char * what = "abxxxx"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cg(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push('a').push(char(0)).push('b').push(4,'x'); }catch( bsl::UnknownException& ex ){ const char * what = "abxxxx"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ch(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push('a').push(char(0)).push('b').push(4,'x'); }catch( bsl::Exception& ex ){ const char * what = "abxxxx"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ci(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push("abc"); }catch( bsl::UnknownException& ex ){ const char * what = "abc"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_cj(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push("abc"); }catch( bsl::Exception& ex ){ const char * what = "abc"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_da(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push("abc"); }catch( bsl::UnknownException& ex ){ const char * what = "abc"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_db(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push("abc"); }catch( bsl::Exception& ex ){ const char * what = "abc"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_dc(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(""); }catch( bsl::UnknownException& ex ){ const char * what = ""; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_dd(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push(""); }catch( bsl::Exception& ex ){ const char * what = ""; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_de(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(""); }catch( bsl::UnknownException& ex ){ const char * what = ""; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_df(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push(""); }catch( bsl::Exception& ex ){ const char * what = ""; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_dg(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push("abc").push("").push("def"); }catch( bsl::UnknownException& ex ){ const char * what = "abcdef"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_dh(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).push("abc").push("").push("def"); }catch( bsl::Exception& ex ){ const char * what = "abcdef"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_di(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push("abc").push("").push("def"); }catch( bsl::UnknownException& ex ){ const char * what = "abcdef"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_dj(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).push("abc").push("").push("def"); }catch( bsl::Exception& ex ){ const char * what = "abcdef"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ea(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).pushf("%d%s",123,"abc").push(true); }catch( bsl::UnknownException& ex ){ const char * what = "123abctrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_eb(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_DEFAULT).pushf("%d%s",123,"abc").push(true); }catch( bsl::Exception& ex ){ const char * what = "123abctrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_DEFAULT; const char * level_str = "EXCEPTION_LEVEL_DEBUG"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ec(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).pushf("%d%s",123,"abc").push(true); }catch( bsl::UnknownException& ex ){ const char * what = "123abctrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ed(){ int line; try{ line = __LINE__, throw bsl::UnknownException().push(BSL_EARG).push(bsl::EXCEPTION_LEVEL_SILENT).pushf("%d%s",123,"abc").push(true); }catch( bsl::Exception& ex ){ const char * what = "123abctrue"; bsl::exception_level_t level = bsl::EXCEPTION_LEVEL_SILENT; const char * level_str = "EXCEPTION_LEVEL_SILENT"; TS_ASSERT( 0 == strcmp( ex.what(), what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), __func__ ) ); TS_ASSERT( 0 == strcmp( ex.file(), __FILE__ ) ); TS_ASSERT( 0 == strcmp( ex.function(), __PRETTY_FUNCTION__ ) ); TS_ASSERT( ex.line() == line ); TS_ASSERT( ex.level() == level ); TS_ASSERT( 0 == strcmp( ex.level_str(), level_str ) ); } } void test_UnknownException_info_ee(){ int line; try{ line = __LINE__, throw bsl::UnknownException()<(1); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bgj(){ try{ throw_func_push(1); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bha(){ try{ throw_func_push(3); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhb(){ try{ throw_func_push(3); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhc(){ try{ throw_func_push(10000); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhd(){ try{ throw_func_push(10000); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhe(){ try{ throw_func_shift(1); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhf(){ try{ throw_func_shift(1); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhg(){ try{ throw_func_shift(3); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhh(){ try{ throw_func_shift(3); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhi(){ try{ throw_func_shift(10000); }catch( bsl::UnknownException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_depth_bhj(){ try{ throw_func_shift(10000); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "UnknownException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::UnknownException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bia(){ try{ throw_func_push(1); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bib(){ try{ throw_func_push(1); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bic(){ try{ throw_func_push(3); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bid(){ try{ throw_func_push(3); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bie(){ try{ throw_func_push(10000); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bif(){ try{ throw_func_push(10000); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_push" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_big(){ try{ throw_func_shift(1); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bih(){ try{ throw_func_shift(1); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bii(){ try{ throw_func_shift(3); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bij(){ try{ throw_func_shift(3); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bja(){ try{ throw_func_shift(10000); }catch( bsl::BadCastException& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_BadCastException_depth_bjb(){ try{ throw_func_shift(10000); }catch( bsl::Exception& ex ){ TS_ASSERT( strlen( ex.what() ) == 1000000 || 0 == strcmp( ex.what(), throw_func_what ) ); #if __GNUC__ <= 2 TS_ASSERT( 0 != strstr( ex.name(), "BadCastException" ) ); #else TS_ASSERT( 0 == strcmp( ex.name(), "bsl::BadCastException" ) ); #endif TS_ASSERT( 0 != strstr( ex.stack(), "throw_func_shift" ) ); TS_ASSERT( 0 == strcmp( ex.file(), "bsl_test_exception_prepare.h_" ) ); //test BSL_EARG TS_ASSERT( ex.level() == throw_func_level ); } } void test_UnknownException_e2no_bjc(){ { int errno = 123; BSL_E2NO( errno, call_nothrow() ); assert( errno == 0 ); } { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } try{ call_throw(); }catch(bsl::Exception& e){ see(e.what()); } size_t old_level = bsl::Exception::set_stack_trace_level(1); printf("bsl::Exception::set_stack_trace_level(1)\n"); { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } assert( 1 == bsl::Exception::set_stack_trace_level(0) ); printf("bsl::Exception::set_stack_trace_level(0)\n"); { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } assert( bsl::Exception::set_stack_trace_level(old_level) == 0 ); printf("bsl::Exception::set_stack_trace_level(%d)\n", int(old_level)); { int errno = 123; BSL_E2NO( errno, throw std::out_of_range("this is message") ); assert( errno == -1 ); } { int errno = 123; BSL_E2NO( errno, call_throw_int(456) ); assert( errno == -1 ); } { int errno = 123; BSL_E2NO( errno, errno = 789 ); assert( errno == 0 ); } } void test_BadCastException_e2no_bjd(){ { int errno = 123; BSL_E2NO( errno, call_nothrow() ); assert( errno == 0 ); } { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } try{ call_throw(); }catch(bsl::Exception& e){ see(e.what()); } size_t old_level = bsl::Exception::set_stack_trace_level(1); printf("bsl::Exception::set_stack_trace_level(1)\n"); { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } assert( 1 == bsl::Exception::set_stack_trace_level(0) ); printf("bsl::Exception::set_stack_trace_level(0)\n"); { int errno = 123; BSL_E2NO( errno, call_throw() ); assert( errno == -1 ); } assert( bsl::Exception::set_stack_trace_level(old_level) == 0 ); printf("bsl::Exception::set_stack_trace_level(%d)\n", int(old_level)); { int errno = 123; BSL_E2NO( errno, throw std::out_of_range("this is message") ); assert( errno == -1 ); } { int errno = 123; BSL_E2NO( errno, call_throw_int(456) ); assert( errno == -1 ); } { int errno = 123; BSL_E2NO( errno, errno = 789 ); assert( errno == 0 ); } } }; #endif //__BSL_TEST_EXCEPTION_H_