aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/yexception_ut.cpp
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-02-10 16:46:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:31 +0300
commit11a24635da4c4f39428b182c49a7bc35e47c9534 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/generic/yexception_ut.cpp
parent317da38588b7898a99fd9168571408123350012b (diff)
downloadydb-11a24635da4c4f39428b182c49a7bc35e47c9534.tar.gz
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/yexception_ut.cpp')
-rw-r--r--util/generic/yexception_ut.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index 732aa12656..cb3e29fed8 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -10,7 +10,7 @@ static inline void Throw2DontMove() {
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/algorithm.h>
+#include <util/generic/algorithm.h>
#include <util/memory/tempbuf.h>
#include <util/random/mersenne.h>
#include <util/stream/output.h>
@@ -32,9 +32,9 @@ static IOutputStream* OUTS = nullptr;
namespace NOuter::NInner {
void Compare10And20() {
Y_ENSURE(10 > 20);
- }
-}
-
+ }
+}
+
class TExceptionTest: public TTestBase {
UNIT_TEST_SUITE(TExceptionTest);
UNIT_TEST_EXCEPTION(TestException, yexception)
@@ -46,8 +46,8 @@ class TExceptionTest: public TTestBase {
UNIT_TEST(TestVirtualInheritance)
UNIT_TEST(TestMixedCode)
UNIT_TEST(TestBackTrace)
- UNIT_TEST(TestEnsureWithBackTrace1)
- UNIT_TEST(TestEnsureWithBackTrace2)
+ UNIT_TEST(TestEnsureWithBackTrace1)
+ UNIT_TEST(TestEnsureWithBackTrace2)
UNIT_TEST(TestRethrowAppend)
UNIT_TEST(TestMacroOverload)
UNIT_TEST(TestMessageCrop)
@@ -86,48 +86,48 @@ private:
UNIT_ASSERT(false);
}
- template <typename TException>
- static void EnsureCurrentExceptionHasBackTrace() {
- auto exceptionPtr = std::current_exception();
- UNIT_ASSERT_C(exceptionPtr != nullptr, "No exception");
- try {
- std::rethrow_exception(exceptionPtr);
- } catch (const TException& e) {
- const TBackTrace* bt = e.BackTrace();
- UNIT_ASSERT(bt != nullptr);
- } catch (...) {
- UNIT_ASSERT_C(false, "Unexpected exception type");
- }
- };
-
- inline void TestEnsureWithBackTrace1() {
- try {
- Y_ENSURE_BT(4 > 6);
- } catch (...) {
- const TString msg = CurrentExceptionMessage();
- UNIT_ASSERT(msg.Contains("4 > 6"));
- UNIT_ASSERT(msg.Contains("\n"));
- EnsureCurrentExceptionHasBackTrace<yexception>();
- return;
- }
- UNIT_ASSERT(false);
- }
-
- inline void TestEnsureWithBackTrace2() {
- try {
+ template <typename TException>
+ static void EnsureCurrentExceptionHasBackTrace() {
+ auto exceptionPtr = std::current_exception();
+ UNIT_ASSERT_C(exceptionPtr != nullptr, "No exception");
+ try {
+ std::rethrow_exception(exceptionPtr);
+ } catch (const TException& e) {
+ const TBackTrace* bt = e.BackTrace();
+ UNIT_ASSERT(bt != nullptr);
+ } catch (...) {
+ UNIT_ASSERT_C(false, "Unexpected exception type");
+ }
+ };
+
+ inline void TestEnsureWithBackTrace1() {
+ try {
+ Y_ENSURE_BT(4 > 6);
+ } catch (...) {
+ const TString msg = CurrentExceptionMessage();
+ UNIT_ASSERT(msg.Contains("4 > 6"));
+ UNIT_ASSERT(msg.Contains("\n"));
+ EnsureCurrentExceptionHasBackTrace<yexception>();
+ return;
+ }
+ UNIT_ASSERT(false);
+ }
+
+ inline void TestEnsureWithBackTrace2() {
+ try {
Y_ENSURE_BT(4 > 6, "custom "
<< "message");
- } catch (...) {
- const TString msg = CurrentExceptionMessage();
- UNIT_ASSERT(!msg.Contains("4 > 6"));
- UNIT_ASSERT(msg.Contains("custom message"));
- UNIT_ASSERT(msg.Contains("\n"));
- EnsureCurrentExceptionHasBackTrace<yexception>();
- return;
- }
- UNIT_ASSERT(false);
- }
-
+ } catch (...) {
+ const TString msg = CurrentExceptionMessage();
+ UNIT_ASSERT(!msg.Contains("4 > 6"));
+ UNIT_ASSERT(msg.Contains("custom message"));
+ UNIT_ASSERT(msg.Contains("\n"));
+ EnsureCurrentExceptionHasBackTrace<yexception>();
+ return;
+ }
+ UNIT_ASSERT(false);
+ }
+
inline void TestVirtualInheritance() {
TStringStream ss;
@@ -273,12 +273,12 @@ private:
} catch (const yexception& e) {
UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for"));
}
-
- try {
- NOuter::NInner::Compare10And20();
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
- }
+
+ try {
+ NOuter::NInner::Compare10And20();
+ } catch (const yexception& e) {
+ UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
+ }
}
void TestMessageCrop() {