saveload_ut.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <library/cpp/testing/gtest/gtest.h>
  2. #include <library/cpp/testing/gtest_extensions/assertions.h>
  3. #include <library/cpp/yt/yson_string/string.h>
  4. namespace NYT::NYson {
  5. namespace {
  6. ////////////////////////////////////////////////////////////////////////////////
  7. TEST(TYsonStringTest, SaveLoadNull)
  8. {
  9. const TYsonString expected;
  10. TStringStream s;
  11. ::Save(&s, expected);
  12. TYsonString result;
  13. ::Load(&s, result);
  14. EXPECT_EQ(expected, result);
  15. }
  16. TEST(TYsonStringTest, SaveLoadString)
  17. {
  18. const TYsonString expected(TString("My tests data"));
  19. TStringStream s;
  20. ::Save(&s, expected);
  21. TYsonString result;
  22. ::Load(&s, result);
  23. EXPECT_EQ(expected, result);
  24. }
  25. TEST(TYsonStringTest, SaveLoadSharedRef)
  26. {
  27. TSharedRef ref = TSharedRef::FromString("My tests data");
  28. const TYsonString expected(ref);
  29. TStringStream s;
  30. ::Save(&s, expected);
  31. TYsonString result;
  32. ::Load(&s, result);
  33. EXPECT_EQ(expected, result);
  34. }
  35. ////////////////////////////////////////////////////////////////////////////////
  36. } // namespace
  37. } // namespace NYT::NYson