aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/yson_string/unittests/convert_ut.cpp
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.ru>2022-02-10 16:49:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:19 +0300
commitf31097c96270919a1f49360bdaaa69ea4f3fefab (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/yson_string/unittests/convert_ut.cpp
parentcec37806d8847aa3db53bafc9e251d4aaf325c12 (diff)
downloadydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/yson_string/unittests/convert_ut.cpp')
-rw-r--r--library/cpp/yt/yson_string/unittests/convert_ut.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/library/cpp/yt/yson_string/unittests/convert_ut.cpp b/library/cpp/yt/yson_string/unittests/convert_ut.cpp
index 4050eb5889..3a64f63896 100644
--- a/library/cpp/yt/yson_string/unittests/convert_ut.cpp
+++ b/library/cpp/yt/yson_string/unittests/convert_ut.cpp
@@ -1,79 +1,79 @@
-#include <library/cpp/testing/gtest/gtest.h>
-
-#include <library/cpp/testing/gtest_extensions/assertions.h>
-
-#include <library/cpp/yt/yson_string/convert.h>
-
-#include <thread>
-
-namespace NYT::NYson {
-namespace {
-
-////////////////////////////////////////////////////////////////////////////////
-
-template <class T, class R = T, class U>
-void Check(const U& value)
-{
- auto str = ConvertToYsonString(static_cast<T>(value));
- auto anotherValue = ConvertFromYsonString<R>(str);
- EXPECT_EQ(static_cast<T>(value), anotherValue);
-}
-
-TEST(TConvertTest, Basic)
-{
- Check<i8>(13);
- Check<i32>(13);
- Check<i64>(13);
- Check<i8>(-13);
- Check<i32>(-13);
- Check<i64>(-13);
- Check<ui8>(13);
- Check<ui32>(13);
- Check<ui64>(13);
- Check<TString>("");
- Check<TString>("hello");
- Check<TStringBuf, TString>("hello");
- Check<const char*, TString>("hello");
- Check<float>(3.14);
- Check<double>(3.14);
- Check<bool>(true);
- Check<bool>(false);
- Check<TInstant>(TInstant::Now());
- Check<TDuration>(TDuration::Seconds(123));
- Check<TGuid>(TGuid::FromString("12345678-12345678-abcdabcd-fefefefe"));
-}
-
-TEST(TConvertTest, InRange)
-{
- EXPECT_EQ(ConvertFromYsonString<i16>(ConvertToYsonString(static_cast<i64>(-123))), -123);
- EXPECT_EQ(ConvertFromYsonString<ui16>(ConvertToYsonString(static_cast<ui64>(123))), 123U);
-}
-
-TEST(TConvertTest, OutOfRange)
-{
- EXPECT_THROW_MESSAGE_HAS_SUBSTR(
- ConvertFromYsonString<i8>(ConvertToYsonString(static_cast<i64>(128))),
- TYsonLiteralParseException,
- "is out of expected range");
- EXPECT_THROW_MESSAGE_HAS_SUBSTR(
- ConvertFromYsonString<ui8>(ConvertToYsonString(static_cast<ui64>(256))),
- TYsonLiteralParseException,
- "is out of expected range");
-}
-
-TEST(TConvertTest, MalformedValues)
-{
- EXPECT_THROW_MESSAGE_HAS_SUBSTR(
- ConvertFromYsonString<TInstant>(ConvertToYsonString(TStringBuf("sometime"))),
- TYsonLiteralParseException,
- "Error parsing \"instant\" value");
- EXPECT_THROW_MESSAGE_HAS_SUBSTR(
- ConvertFromYsonString<TGuid>(ConvertToYsonString(TStringBuf("1-2-3-g"))),
- TYsonLiteralParseException,
- "Error parsing \"guid\" value");
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // namespace
-} // namespace NYT::NYson
+#include <library/cpp/testing/gtest/gtest.h>
+
+#include <library/cpp/testing/gtest_extensions/assertions.h>
+
+#include <library/cpp/yt/yson_string/convert.h>
+
+#include <thread>
+
+namespace NYT::NYson {
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <class T, class R = T, class U>
+void Check(const U& value)
+{
+ auto str = ConvertToYsonString(static_cast<T>(value));
+ auto anotherValue = ConvertFromYsonString<R>(str);
+ EXPECT_EQ(static_cast<T>(value), anotherValue);
+}
+
+TEST(TConvertTest, Basic)
+{
+ Check<i8>(13);
+ Check<i32>(13);
+ Check<i64>(13);
+ Check<i8>(-13);
+ Check<i32>(-13);
+ Check<i64>(-13);
+ Check<ui8>(13);
+ Check<ui32>(13);
+ Check<ui64>(13);
+ Check<TString>("");
+ Check<TString>("hello");
+ Check<TStringBuf, TString>("hello");
+ Check<const char*, TString>("hello");
+ Check<float>(3.14);
+ Check<double>(3.14);
+ Check<bool>(true);
+ Check<bool>(false);
+ Check<TInstant>(TInstant::Now());
+ Check<TDuration>(TDuration::Seconds(123));
+ Check<TGuid>(TGuid::FromString("12345678-12345678-abcdabcd-fefefefe"));
+}
+
+TEST(TConvertTest, InRange)
+{
+ EXPECT_EQ(ConvertFromYsonString<i16>(ConvertToYsonString(static_cast<i64>(-123))), -123);
+ EXPECT_EQ(ConvertFromYsonString<ui16>(ConvertToYsonString(static_cast<ui64>(123))), 123U);
+}
+
+TEST(TConvertTest, OutOfRange)
+{
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR(
+ ConvertFromYsonString<i8>(ConvertToYsonString(static_cast<i64>(128))),
+ TYsonLiteralParseException,
+ "is out of expected range");
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR(
+ ConvertFromYsonString<ui8>(ConvertToYsonString(static_cast<ui64>(256))),
+ TYsonLiteralParseException,
+ "is out of expected range");
+}
+
+TEST(TConvertTest, MalformedValues)
+{
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR(
+ ConvertFromYsonString<TInstant>(ConvertToYsonString(TStringBuf("sometime"))),
+ TYsonLiteralParseException,
+ "Error parsing \"instant\" value");
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR(
+ ConvertFromYsonString<TGuid>(ConvertToYsonString(TStringBuf("1-2-3-g"))),
+ TYsonLiteralParseException,
+ "Error parsing \"guid\" value");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+} // namespace NYT::NYson