diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-08 18:25:47 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-08 18:25:47 +0300 |
commit | a3ac8a71f16e0db7d50d5b1235466ff754e0d228 (patch) | |
tree | 8433eb84ffae296ccb9ae094d08491c86c48bdb1 /library/cpp/testing/unittest/registar.h | |
parent | 60312eaed2e51caa7ed482270d3545a9d27cb284 (diff) | |
download | ydb-a3ac8a71f16e0db7d50d5b1235466ff754e0d228.tar.gz |
intermediate changes
ref:f398132a6a7101a031da4a85ff8dc9f360af7d8a
Diffstat (limited to 'library/cpp/testing/unittest/registar.h')
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 332485bdf3b..44517a00924 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -627,6 +627,23 @@ public: \ // Assert that a specific exception is thrown #define UNIT_ASSERT_EXCEPTION(A, E) UNIT_ASSERT_EXCEPTION_C(A, E, "") +#define UNIT_ASSERT_NO_EXCEPTION_RESULT_C(A, C) \ + [&] () mutable -> decltype(A) { \ + static_assert(!std::is_void_v<decltype(A)>); \ + try { return (A); } \ + catch (const ::NUnitTest::TAssertException&) { throw; } \ + catch (...) { \ + UNIT_FAIL_IMPL( \ + "exception-free assertion failed", \ + Sprintf("%s throws %s\nException message: %s", \ + #A, (::TStringBuilder() << C).data(), \ + CurrentExceptionMessage().data())); \ + return decltype(A){}; \ + } \ + }() + +#define UNIT_ASSERT_NO_EXCEPTION_RESULT(A) UNIT_ASSERT_NO_EXCEPTION_RESULT_C(A, "") + #define UNIT_ASSERT_NO_EXCEPTION_C(A, C) \ do { \ try { \ |