diff options
author | trenin17 <trenin17@yandex-team.ru> | 2022-02-10 16:51:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:09 +0300 |
commit | 7d9e9dd650ccaad923d6b1ce79baaa3a15b740ae (patch) | |
tree | 9c42d6cb3c90f951425e1d63ce484ad67e0936e7 /util/generic/yexception_ut.cpp | |
parent | 9a82582baef5f5fc12d0448b66bdb6576fbb1dd2 (diff) | |
download | ydb-7d9e9dd650ccaad923d6b1ce79baaa3a15b740ae.tar.gz |
Restoring authorship annotation for <trenin17@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/yexception_ut.cpp')
-rw-r--r-- | util/generic/yexception_ut.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp index cb3e29fed84..77b26b9c25e 100644 --- a/util/generic/yexception_ut.cpp +++ b/util/generic/yexception_ut.cpp @@ -52,7 +52,7 @@ class TExceptionTest: public TTestBase { UNIT_TEST(TestMacroOverload) UNIT_TEST(TestMessageCrop) UNIT_TEST(TestTIoSystemErrorSpecialMethods) - UNIT_TEST(TestCurrentExceptionTypeNameMethod) + UNIT_TEST(TestCurrentExceptionTypeNameMethod) UNIT_TEST_SUITE_END(); private: @@ -319,74 +319,74 @@ private: errMoveAssign = std::move(errMove); UNIT_ASSERT(errMoveAssign.AsStrBuf().Contains(testStr)); } - inline void TestCurrentExceptionTypeNameMethod() { - //Basic test of getting the correct exception type name. - try { - throw std::runtime_error("Test Runtime Error Exception"); - } catch (...) { - UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::runtime_error"); - } - //Test when exception has an unusual type. Under Linux it should return "int" and under other OSs "unknown type". - try { - throw int(1); - } catch (...) { + inline void TestCurrentExceptionTypeNameMethod() { + //Basic test of getting the correct exception type name. + try { + throw std::runtime_error("Test Runtime Error Exception"); + } catch (...) { + UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::runtime_error"); + } + //Test when exception has an unusual type. Under Linux it should return "int" and under other OSs "unknown type". + try { + throw int(1); + } catch (...) { #if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBGCC) - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); -#else - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); -#endif - } - //Test when the caught exception is rethrown with std::rethrow_exception. - try { - throw std::logic_error("Test Logic Error Exception"); - } catch (...) { - try { - std::rethrow_exception(std::current_exception()); - } catch (...) { - UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::logic_error"); - } - } - //Test when the caught exception is rethrown with throw; . + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); +#else + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); +#endif + } + //Test when the caught exception is rethrown with std::rethrow_exception. + try { + throw std::logic_error("Test Logic Error Exception"); + } catch (...) { + try { + std::rethrow_exception(std::current_exception()); + } catch (...) { + UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::logic_error"); + } + } + //Test when the caught exception is rethrown with throw; . //This test is different from the previous one because of the interaction with cxxabi specifics. - try { - throw std::bad_alloc(); - } catch (...) { - try { - throw; - } catch (...) { - UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::bad_alloc"); - } - } + try { + throw std::bad_alloc(); + } catch (...) { + try { + throw; + } catch (...) { + UNIT_ASSERT_STRING_CONTAINS(CurrentExceptionTypeName(), "std::bad_alloc"); + } + } // For exceptions thrown by std::rethrow_exception() a nullptr will be returned by libcxxrt's __cxa_current_exception_type(). - // Adding an explicit test for the case. - try { - throw int(1); - } catch (...) { - try { - std::rethrow_exception(std::current_exception()); - } catch (...) { + // Adding an explicit test for the case. + try { + throw int(1); + } catch (...) { + try { + std::rethrow_exception(std::current_exception()); + } catch (...) { #if defined(LIBCXX_BUILDING_LIBGCC) - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); -#else - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); -#endif - } - } - //Test when int is rethrown with throw; . - try { - throw int(1); - } catch (...) { - try { - throw; - } catch (...) { + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); +#else + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); +#endif + } + } + //Test when int is rethrown with throw; . + try { + throw int(1); + } catch (...) { + try { + throw; + } catch (...) { #if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBGCC) - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); -#else - UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); -#endif - } - } - } + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "int"); +#else + UNIT_ASSERT_VALUES_EQUAL(CurrentExceptionTypeName(), "unknown type"); +#endif + } + } + } }; UNIT_TEST_SUITE_REGISTRATION(TExceptionTest); |