diff options
author | swarmer <swarmer@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
commit | 11a24635da4c4f39428b182c49a7bc35e47c9534 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/ysaveload_ut.cpp | |
parent | 317da38588b7898a99fd9168571408123350012b (diff) | |
download | ydb-11a24635da4c4f39428b182c49a7bc35e47c9534.tar.gz |
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/ysaveload_ut.cpp')
-rw-r--r-- | util/ysaveload_ut.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp index 49bfbc3d7f..723c68f391 100644 --- a/util/ysaveload_ut.cpp +++ b/util/ysaveload_ut.cpp @@ -29,8 +29,8 @@ class TSaveLoadTest: public TTestBase { UNIT_TEST(TestList) UNIT_TEST(TestTuple) UNIT_TEST(TestVariant) - UNIT_TEST(TestInheritNonVirtualClass) - UNIT_TEST(TestInheritVirtualClass) + UNIT_TEST(TestInheritNonVirtualClass) + UNIT_TEST(TestInheritVirtualClass) UNIT_TEST_SUITE_END(); struct TSaveHelper { @@ -430,58 +430,58 @@ private: std::variant<char, bool> v2 = false; UNIT_ASSERT_EXCEPTION(::Load(&s, v2), TLoadEOF); } - - // tests serialization of class with three public string members - template <class TDerived, class TInterface = TDerived> - void TestInheritClassImpl() { - TBufferStream s; - { - TDerived v1; - v1.Str1 = "One"; - v1.Str2 = "Two"; - v1.Str3 = "Three"; - ::Save(&s, static_cast<const TInterface&>(v1)); - } - { - TDerived v2; - ::Load(&s, static_cast<TInterface&>(v2)); - UNIT_ASSERT_VALUES_EQUAL_C(v2.Str1, "One", TypeName<TDerived>() << " via " << TypeName<TInterface>()); - UNIT_ASSERT_VALUES_EQUAL_C(v2.Str2, "Two", TypeName<TDerived>() << " via " << TypeName<TInterface>()); - UNIT_ASSERT_VALUES_EQUAL_C(v2.Str3, "Three", TypeName<TDerived>() << " via " << TypeName<TInterface>()); - } - } - - void TestInheritNonVirtualClass() { - struct TBaseNonVirtual { - TString Str1; - Y_SAVELOAD_DEFINE(Str1); - }; - struct TDerivedNonVirtual: TBaseNonVirtual { - TString Str2; - TString Str3; - Y_SAVELOAD_DEFINE(TNonVirtualSaver<TBaseNonVirtual>{this}, Str2, Str3); - }; - TestInheritClassImpl<TDerivedNonVirtual>(); - } - - void TestInheritVirtualClass() { - struct IInterface { - virtual void Save(IOutputStream* out) const = 0; - virtual void Load(IInputStream* in) = 0; - }; - struct TBaseVirtual: IInterface { - TString Str1; - Y_SAVELOAD_DEFINE_OVERRIDE(Str1); - }; - struct TDerivedVirtual: TBaseVirtual { - TString Str2; - TString Str3; - Y_SAVELOAD_DEFINE_OVERRIDE(TNonVirtualSaver<TBaseVirtual>{this}, Str2, Str3); - }; - TestInheritClassImpl<TDerivedVirtual>(); - TestInheritClassImpl<TDerivedVirtual, TBaseVirtual>(); - TestInheritClassImpl<TDerivedVirtual, IInterface>(); - } + + // tests serialization of class with three public string members + template <class TDerived, class TInterface = TDerived> + void TestInheritClassImpl() { + TBufferStream s; + { + TDerived v1; + v1.Str1 = "One"; + v1.Str2 = "Two"; + v1.Str3 = "Three"; + ::Save(&s, static_cast<const TInterface&>(v1)); + } + { + TDerived v2; + ::Load(&s, static_cast<TInterface&>(v2)); + UNIT_ASSERT_VALUES_EQUAL_C(v2.Str1, "One", TypeName<TDerived>() << " via " << TypeName<TInterface>()); + UNIT_ASSERT_VALUES_EQUAL_C(v2.Str2, "Two", TypeName<TDerived>() << " via " << TypeName<TInterface>()); + UNIT_ASSERT_VALUES_EQUAL_C(v2.Str3, "Three", TypeName<TDerived>() << " via " << TypeName<TInterface>()); + } + } + + void TestInheritNonVirtualClass() { + struct TBaseNonVirtual { + TString Str1; + Y_SAVELOAD_DEFINE(Str1); + }; + struct TDerivedNonVirtual: TBaseNonVirtual { + TString Str2; + TString Str3; + Y_SAVELOAD_DEFINE(TNonVirtualSaver<TBaseNonVirtual>{this}, Str2, Str3); + }; + TestInheritClassImpl<TDerivedNonVirtual>(); + } + + void TestInheritVirtualClass() { + struct IInterface { + virtual void Save(IOutputStream* out) const = 0; + virtual void Load(IInputStream* in) = 0; + }; + struct TBaseVirtual: IInterface { + TString Str1; + Y_SAVELOAD_DEFINE_OVERRIDE(Str1); + }; + struct TDerivedVirtual: TBaseVirtual { + TString Str2; + TString Str3; + Y_SAVELOAD_DEFINE_OVERRIDE(TNonVirtualSaver<TBaseVirtual>{this}, Str2, Str3); + }; + TestInheritClassImpl<TDerivedVirtual>(); + TestInheritClassImpl<TDerivedVirtual, TBaseVirtual>(); + TestInheritClassImpl<TDerivedVirtual, IInterface>(); + } }; UNIT_TEST_SUITE_REGISTRATION(TSaveLoadTest); |