diff options
| author | Ivan Komarov <[email protected]> | 2022-02-10 16:46:48 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:48 +0300 | 
| commit | 4de97ab2fe437cbe83e4c63234e809ddd5ac34f2 (patch) | |
| tree | ff8fb38b661955e6c99d1d000d6c72f739199590 /library/cpp/testing | |
| parent | 9abfb1a53b7f7b791444d1378e645d8fad9b06ed (diff) | |
Restoring authorship annotation for Ivan Komarov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing')
| -rw-r--r-- | library/cpp/testing/unittest/gtest.h | 2 | ||||
| -rw-r--r-- | library/cpp/testing/unittest/registar.h | 44 | ||||
| -rw-r--r-- | library/cpp/testing/unittest/registar_ut.cpp | 10 | 
3 files changed, 28 insertions, 28 deletions
diff --git a/library/cpp/testing/unittest/gtest.h b/library/cpp/testing/unittest/gtest.h index b6768b1bf0b..3818b2096df 100644 --- a/library/cpp/testing/unittest/gtest.h +++ b/library/cpp/testing/unittest/gtest.h @@ -80,7 +80,7 @@ namespace testing {  #define EXPECT_NE(A, B) UNIT_ASSERT_UNEQUAL(A, B)  #define EXPECT_LE(A, B) UNIT_ASSERT((A) <= (B))  #define EXPECT_LT(A, B) UNIT_ASSERT((A) < (B)) -#define EXPECT_GE(A, B) UNIT_ASSERT((A) >= (B)) +#define EXPECT_GE(A, B) UNIT_ASSERT((A) >= (B))   #define EXPECT_GT(A, B) UNIT_ASSERT((A) > (B))  #define EXPECT_NO_THROW(A) UNIT_ASSERT_NO_EXCEPTION(A)  #define EXPECT_THROW(A, B) UNIT_ASSERT_EXCEPTION(A, B) diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a00924..4965e0bbb7a 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -383,9 +383,9 @@ public:                       \      } 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)                                                     \ +// 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));                                                       \ @@ -396,32 +396,32 @@ public:                       \          }                                                                                                      \      } while (false) -#define UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED(E, A, D) UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED_C(E, A, D, "") - -#define UNIT_ASSERT_DOUBLES_EQUAL_C(E, A, D, C)                                                                                        \ -    do {                                                                                                                               \ -        const auto _ed = (E);                                                                                                          \ -        const auto _ad = (A);                                                                                                          \ -        const auto _dd = (D);                                                                                                          \ +#define UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED(E, A, D) UNIT_ASSERT_DOUBLES_EQUAL_DEPRECATED_C(E, A, D, "")  +  +#define UNIT_ASSERT_DOUBLES_EQUAL_C(E, A, D, C)                                                                                        \  +    do {                                                                                                                               \  +        const auto _ed = (E);                                                                                                          \  +        const auto _ad = (A);                                                                                                          \  +        const auto _dd = (D);                                                                                                          \           if (std::isnan((long double)_ed) && !std::isnan((long double)_ad)) {                                                           \              const auto _as = ToString((long double)_ad);                                                                               \              auto&& failMsg = Sprintf("expected NaN, got %s %s", _as.data(), (::TStringBuilder() << C).data());                           \ -            UNIT_FAIL_IMPL("assertion failure", failMsg);                                                                              \ -        }                                                                                                                              \ +            UNIT_FAIL_IMPL("assertion failure", failMsg);                                                                              \  +        }                                                                                                                              \           if (!std::isnan((long double)_ed) && std::isnan((long double)_ad)) {                                                           \              const auto _es = ToString((long double)_ed);                                                                               \              auto&& failMsg = Sprintf("expected %s, got NaN %s", _es.data(), (::TStringBuilder() << C).data());                           \ -            UNIT_FAIL_IMPL("assertion failure", failMsg);                                                                              \ -        }                                                                                                                              \ -        if (std::abs((_ed) - (_ad)) > (_dd)) {                                                                                         \ -            const auto _es = ToString((long double)_ed);                                                                               \ -            const auto _as = ToString((long double)_ad);                                                                               \ -            const auto _ds = ToString((long double)_dd);                                                                               \ +            UNIT_FAIL_IMPL("assertion failure", failMsg);                                                                              \  +        }                                                                                                                              \  +        if (std::abs((_ed) - (_ad)) > (_dd)) {                                                                                         \  +            const auto _es = ToString((long double)_ed);                                                                               \  +            const auto _as = ToString((long double)_ad);                                                                               \  +            const auto _ds = ToString((long double)_dd);                                                                               \               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(E, A, D) UNIT_ASSERT_DOUBLES_EQUAL_C(E, A, D, "")  //strings diff --git a/library/cpp/testing/unittest/registar_ut.cpp b/library/cpp/testing/unittest/registar_ut.cpp index 1f36d53abbe..5db231c49d7 100644 --- a/library/cpp/testing/unittest/registar_ut.cpp +++ b/library/cpp/testing/unittest/registar_ut.cpp @@ -28,11 +28,11 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {          UNIT_ASSERT_DOUBLES_EQUAL(0.0, 0.01, 0.1);          UNIT_ASSERT_DOUBLES_EQUAL(0.01, 0.0, 0.1); - -        constexpr auto nan = std::numeric_limits<double>::quiet_NaN(); -        UNIT_ASSERT_TEST_FAILS(doublesEqual(nan, 0.5, 0.1)); -        UNIT_ASSERT_TEST_FAILS(doublesEqual(0.5, nan, 0.1)); -        UNIT_ASSERT_DOUBLES_EQUAL(nan, nan, 0.1); +  +        constexpr auto nan = std::numeric_limits<double>::quiet_NaN();  +        UNIT_ASSERT_TEST_FAILS(doublesEqual(nan, 0.5, 0.1));  +        UNIT_ASSERT_TEST_FAILS(doublesEqual(0.5, nan, 0.1));  +        UNIT_ASSERT_DOUBLES_EQUAL(nan, nan, 0.1);       }      Y_UNIT_TEST(StringsEqual) {  | 
