diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:02 +0300 |
commit | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch) | |
tree | c2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/testing/unittest/registar.h | |
parent | ab3783171cc30e262243a0227c86118f7080c896 (diff) | |
download | ydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing/unittest/registar.h')
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a0092..ec74ef88dc 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -375,26 +375,26 @@ public: \ #define UNIT_FAIL_NONFATAL(M) UNIT_FAIL_NONFATAL_IMPL("forced failure", M) //types -#define UNIT_ASSERT_TYPES_EQUAL(A, B) \ - do { \ - if (!std::is_same<A, B>::value) { \ +#define UNIT_ASSERT_TYPES_EQUAL(A, B) \ + do { \ + if (!std::is_same<A, B>::value) { \ UNIT_FAIL_IMPL("types equal assertion failed", (::TStringBuilder() << #A << " (" << TypeName<A>() << ") != " << #B << " (" << TypeName<B>() << ")").data()); \ - } \ - } while (false) + } \ + } while (false) //doubles // UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED* macros do not handle NaNs correctly (see IGNIETFERRO-1419) and are for backward compatibility // only. Consider switching to regular UNIT_ASSERT_DOUBLES_EQUAL* macros if you're still using the deprecated version. #define UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED_C(E, A, D, C) \ - do { \ - if (std::abs((E) - (A)) > (D)) { \ - const auto _es = ToString((long double)(E)); \ - const auto _as = ToString((long double)(A)); \ - const auto _ds = ToString((long double)(D)); \ + do { \ + if (std::abs((E) - (A)) > (D)) { \ + const auto _es = ToString((long double)(E)); \ + const auto _as = ToString((long double)(A)); \ + const auto _ds = ToString((long double)(D)); \ auto&& failMsg = Sprintf("std::abs(%s - %s) > %s %s", _es.data(), _as.data(), _ds.data(), (::TStringBuilder() << C).data()); \ - UNIT_FAIL_IMPL("assertion failure", failMsg); \ - } \ - } while (false) + UNIT_FAIL_IMPL("assertion failure", failMsg); \ + } \ + } while (false) #define UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED(E, A, D) UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED_C(E, A, D, "") @@ -472,72 +472,72 @@ public: \ #define UNIT_ASSERT_STRINGS_UNEQUAL(A, B) UNIT_ASSERT_STRINGS_UNEQUAL_C(A, B, "") //bool -#define UNIT_ASSERT_C(A, C) \ - do { \ - if (!(A)) { \ +#define UNIT_ASSERT_C(A, C) \ + do { \ + if (!(A)) { \ UNIT_FAIL_IMPL("assertion failed", Sprintf("(%s) %s", #A, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT(A) UNIT_ASSERT_C(A, "") //general -#define UNIT_ASSERT_EQUAL_C(A, B, C) \ - do { \ - if (!((A) == (B))) { \ +#define UNIT_ASSERT_EQUAL_C(A, B, C) \ + do { \ + if (!((A) == (B))) { \ UNIT_FAIL_IMPL("equal assertion failed", Sprintf("%s == %s %s", #A, #B, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_EQUAL(A, B) UNIT_ASSERT_EQUAL_C(A, B, "") -#define UNIT_ASSERT_UNEQUAL_C(A, B, C) \ - do { \ - if ((A) == (B)) { \ +#define UNIT_ASSERT_UNEQUAL_C(A, B, C) \ + do { \ + if ((A) == (B)) { \ UNIT_FAIL_IMPL("unequal assertion failed", Sprintf("%s != %s %s", #A, #B, (::TStringBuilder() << C).data()));\ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_UNEQUAL(A, B) UNIT_ASSERT_UNEQUAL_C(A, B, "") -#define UNIT_ASSERT_LT_C(A, B, C) \ - do { \ - if (!((A) < (B))) { \ +#define UNIT_ASSERT_LT_C(A, B, C) \ + do { \ + if (!((A) < (B))) { \ UNIT_FAIL_IMPL("less-than assertion failed", Sprintf("%s < %s %s", #A, #B, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_LT(A, B) UNIT_ASSERT_LT_C(A, B, "") -#define UNIT_ASSERT_LE_C(A, B, C) \ - do { \ - if (!((A) <= (B))) { \ +#define UNIT_ASSERT_LE_C(A, B, C) \ + do { \ + if (!((A) <= (B))) { \ UNIT_FAIL_IMPL("less-or-equal assertion failed", Sprintf("%s <= %s %s", #A, #B, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_LE(A, B) UNIT_ASSERT_LE_C(A, B, "") -#define UNIT_ASSERT_GT_C(A, B, C) \ - do { \ - if (!((A) > (B))) { \ +#define UNIT_ASSERT_GT_C(A, B, C) \ + do { \ + if (!((A) > (B))) { \ UNIT_FAIL_IMPL("greater-than assertion failed", Sprintf("%s > %s %s", #A, #B, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_GT(A, B) UNIT_ASSERT_GT_C(A, B, "") #define UNIT_ASSERT_GE_C(A, B, C) \ - do { \ - if (!((A) >= (B))) { \ + do { \ + if (!((A) >= (B))) { \ UNIT_FAIL_IMPL("greater-or-equal assertion failed", Sprintf("%s >= %s %s", #A, #B, (::TStringBuilder() << C).data())); \ - } \ - } while (false) + } \ + } while (false) #define UNIT_ASSERT_GE(A, B) UNIT_ASSERT_GE_C(A, B, "") #define UNIT_CHECK_GENERATED_EXCEPTION_C(A, E, C) \ - do { \ + do { \ try { \ (void)(A); \ } catch (const ::NUnitTest::TAssertException&) { \ @@ -546,20 +546,20 @@ public: \ break; \ } \ UNIT_ASSERT_C(0, "Exception hasn't been thrown, but it should have happened " << C); \ - } while (false) + } while (false) #define UNIT_CHECK_GENERATED_EXCEPTION(A, E) UNIT_CHECK_GENERATED_EXCEPTION_C(A, E, "") -#define UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, C) \ - do { \ - try { \ - (void)(A); \ - } catch (const ::NUnitTest::TAssertException&) { \ - throw; \ - } catch (const E&) { \ - UNIT_ASSERT_C(0, "Exception has been thrown, but it shouldn't have happened " << C); \ - } \ - } while (false) +#define UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, C) \ + do { \ + try { \ + (void)(A); \ + } catch (const ::NUnitTest::TAssertException&) { \ + throw; \ + } catch (const E&) { \ + UNIT_ASSERT_C(0, "Exception has been thrown, but it shouldn't have happened " << C); \ + } \ + } while (false) #define UNIT_CHECK_GENERATED_NO_EXCEPTION(A, E) UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, "and exception message is:\n" << CurrentExceptionMessage()) |