|
@@ -27,6 +27,7 @@ class TSaveLoadTest: public TTestBase {
|
|
|
UNIT_TEST(TestList)
|
|
|
UNIT_TEST(TestTuple)
|
|
|
UNIT_TEST(TestVariant)
|
|
|
+ UNIT_TEST(TestOptional)
|
|
|
UNIT_TEST(TestInheritNonVirtualClass)
|
|
|
UNIT_TEST(TestInheritVirtualClass)
|
|
|
UNIT_TEST_SUITE_END();
|
|
@@ -429,6 +430,26 @@ private:
|
|
|
UNIT_ASSERT_EXCEPTION(::Load(&s, v2), TLoadEOF);
|
|
|
}
|
|
|
|
|
|
+ template <class T>
|
|
|
+ void TestOptionalImpl(const std::optional<T>& v) {
|
|
|
+ std::optional<T> loaded;
|
|
|
+ TBufferStream s;
|
|
|
+ ::Save(&s, v);
|
|
|
+ ::Load(&s, loaded);
|
|
|
+
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL(v.has_value(), loaded.has_value());
|
|
|
+ if (v.has_value()) {
|
|
|
+ UNIT_ASSERT_VALUES_EQUAL(*v, *loaded);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void TestOptional() {
|
|
|
+ TestOptionalImpl(std::optional<ui64>(42ull));
|
|
|
+ TestOptionalImpl(std::optional<bool>(true));
|
|
|
+ TestOptionalImpl(std::optional<TString>("abacaba"));
|
|
|
+ TestOptionalImpl(std::optional<ui64>(std::nullopt));
|
|
|
+ }
|
|
|
+
|
|
|
// tests serialization of class with three public string members
|
|
|
template <class TDerived, class TInterface = TDerived>
|
|
|
void TestInheritClassImpl() {
|