diff options
author | antoshkka <[email protected]> | 2022-02-10 16:50:14 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:14 +0300 |
commit | 90277959ac43a22ec25e7b78b1a2b4f610530d51 (patch) | |
tree | 83f00e4f33f9a449c5f5a871ad9330211c595f5c /util/generic/cast_ut.cpp | |
parent | 9a6b05f93140131e64aa069bad7092698970130d (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/generic/cast_ut.cpp')
-rw-r--r-- | util/generic/cast_ut.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/util/generic/cast_ut.cpp b/util/generic/cast_ut.cpp index 718a8de79de..9892029eb11 100644 --- a/util/generic/cast_ut.cpp +++ b/util/generic/cast_ut.cpp @@ -6,7 +6,7 @@ class TGenericCastsTest: public TTestBase { UNIT_TEST_SUITE(TGenericCastsTest); UNIT_TEST(TestVerifyDynamicCast) UNIT_TEST(TestIntegralCast) - UNIT_TEST(TestEnumCast) + UNIT_TEST(TestEnumCast) UNIT_TEST(TestToUnderlying) UNIT_TEST(TestBitCast) UNIT_TEST_SUITE_END(); @@ -29,32 +29,32 @@ private: UNIT_ASSERT_EXCEPTION(SafeIntegerCast<ui16>(static_cast<i32>(Max<ui16>() + 10)), TBadCastException); UNIT_ASSERT_EXCEPTION(SafeIntegerCast<ui16>(static_cast<ui32>(Max<ui16>() + 10)), TBadCastException); } - - inline void TestEnumCast() { - enum A { - AM1 = -1 - }; - + + inline void TestEnumCast() { + enum A { + AM1 = -1 + }; + enum B: int { - BM1 = -1 - }; - + BM1 = -1 + }; + enum class C: unsigned short { - CM1 = 1 - }; - - UNIT_ASSERT_EXCEPTION(SafeIntegerCast<unsigned int>(AM1), TBadCastException); - UNIT_ASSERT_EXCEPTION(SafeIntegerCast<unsigned int>(BM1), TBadCastException); - UNIT_ASSERT_EXCEPTION(SafeIntegerCast<C>(AM1), TBadCastException); - UNIT_ASSERT_EXCEPTION(static_cast<int>(SafeIntegerCast<C>(BM1)), TBadCastException); - UNIT_ASSERT(SafeIntegerCast<A>(BM1) == AM1); - UNIT_ASSERT(SafeIntegerCast<B>(AM1) == BM1); - UNIT_ASSERT(SafeIntegerCast<A>(C::CM1) == 1); - UNIT_ASSERT(SafeIntegerCast<B>(C::CM1) == 1); - UNIT_ASSERT(SafeIntegerCast<A>(-1) == AM1); - UNIT_ASSERT(SafeIntegerCast<B>(-1) == BM1); - UNIT_ASSERT(SafeIntegerCast<C>(1) == C::CM1); - } + CM1 = 1 + }; + + UNIT_ASSERT_EXCEPTION(SafeIntegerCast<unsigned int>(AM1), TBadCastException); + UNIT_ASSERT_EXCEPTION(SafeIntegerCast<unsigned int>(BM1), TBadCastException); + UNIT_ASSERT_EXCEPTION(SafeIntegerCast<C>(AM1), TBadCastException); + UNIT_ASSERT_EXCEPTION(static_cast<int>(SafeIntegerCast<C>(BM1)), TBadCastException); + UNIT_ASSERT(SafeIntegerCast<A>(BM1) == AM1); + UNIT_ASSERT(SafeIntegerCast<B>(AM1) == BM1); + UNIT_ASSERT(SafeIntegerCast<A>(C::CM1) == 1); + UNIT_ASSERT(SafeIntegerCast<B>(C::CM1) == 1); + UNIT_ASSERT(SafeIntegerCast<A>(-1) == AM1); + UNIT_ASSERT(SafeIntegerCast<B>(-1) == BM1); + UNIT_ASSERT(SafeIntegerCast<C>(1) == C::CM1); + } void TestToUnderlying() { enum A { |