aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/ut/writer_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/yson_pull/ut/writer_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson_pull/ut/writer_ut.cpp')
-rw-r--r--library/cpp/yson_pull/ut/writer_ut.cpp294
1 files changed, 147 insertions, 147 deletions
diff --git a/library/cpp/yson_pull/ut/writer_ut.cpp b/library/cpp/yson_pull/ut/writer_ut.cpp
index 5c304bad0f..4002574fd3 100644
--- a/library/cpp/yson_pull/ut/writer_ut.cpp
+++ b/library/cpp/yson_pull/ut/writer_ut.cpp
@@ -11,34 +11,34 @@
using namespace std::string_view_literals;
namespace {
- template <typename Writer, typename Function>
+ template <typename Writer, typename Function>
TString with_writer(Function&& function) {
TString result;
- auto writer = NYsonPull::NDetail::make_writer<Writer>(
+ auto writer = NYsonPull::NDetail::make_writer<Writer>(
NYsonPull::NOutput::FromString(&result),
- NYsonPull::EStreamType::Node);
+ NYsonPull::EStreamType::Node);
- function(writer);
+ function(writer);
return result;
- }
+ }
- template <typename Writer>
+ template <typename Writer>
TString to_yson_string(const NYsonPull::TScalar& value) {
- return with_writer<Writer>([&](NYsonPull::TWriter& writer) {
+ return with_writer<Writer>([&](NYsonPull::TWriter& writer) {
writer.BeginStream().Scalar(value).EndStream();
- });
- }
+ });
+ }
- template <typename T>
+ template <typename T>
TString to_yson_binary_string(T&& value) {
return to_yson_string<NYsonPull::NDetail::TBinaryWriterImpl>(std::forward<T>(value));
- }
+ }
- template <typename T>
+ template <typename T>
TString to_yson_text_string(T&& value) {
return to_yson_string<NYsonPull::NDetail::TTextWriterImpl>(std::forward<T>(value));
- }
+ }
} // anonymous namespace
@@ -46,80 +46,80 @@ namespace {
Y_UNIT_TEST_SUITE(Writer) {
Y_UNIT_TEST(TextEntity) {
- UNIT_ASSERT_VALUES_EQUAL(
- "#",
- to_yson_text_string(NYsonPull::TScalar{}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ "#",
+ to_yson_text_string(NYsonPull::TScalar{}));
+ }
Y_UNIT_TEST(TextBoolean) {
- UNIT_ASSERT_VALUES_EQUAL(
- "%false",
- to_yson_text_string(NYsonPull::TScalar{false}));
- UNIT_ASSERT_VALUES_EQUAL(
- "%true",
- to_yson_text_string(NYsonPull::TScalar{true}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ "%false",
+ to_yson_text_string(NYsonPull::TScalar{false}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "%true",
+ to_yson_text_string(NYsonPull::TScalar{true}));
+ }
Y_UNIT_TEST(TextInt64) {
- UNIT_ASSERT_VALUES_EQUAL(
- "0",
- to_yson_text_string(NYsonPull::TScalar{i64{0}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "200",
- to_yson_text_string(NYsonPull::TScalar{i64{200}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "20000",
- to_yson_text_string(NYsonPull::TScalar{i64{20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "200000000",
- to_yson_text_string(NYsonPull::TScalar{i64{200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "20000000000000000",
- to_yson_text_string(NYsonPull::TScalar{i64{20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "9223372036854775807",
- to_yson_text_string(NYsonPull::TScalar{i64{INT64_MAX}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "0",
+ to_yson_text_string(NYsonPull::TScalar{i64{0}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "200",
+ to_yson_text_string(NYsonPull::TScalar{i64{200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "20000",
+ to_yson_text_string(NYsonPull::TScalar{i64{20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "200000000",
+ to_yson_text_string(NYsonPull::TScalar{i64{200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "20000000000000000",
+ to_yson_text_string(NYsonPull::TScalar{i64{20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "9223372036854775807",
+ to_yson_text_string(NYsonPull::TScalar{i64{INT64_MAX}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "-200",
- to_yson_text_string(NYsonPull::TScalar{i64{-200}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "-20000",
- to_yson_text_string(NYsonPull::TScalar{i64{-20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "-200000000",
- to_yson_text_string(NYsonPull::TScalar{i64{-200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "-20000000000000000",
- to_yson_text_string(NYsonPull::TScalar{i64{-20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "-9223372036854775808",
- to_yson_text_string(NYsonPull::TScalar{i64{INT64_MIN}}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ "-200",
+ to_yson_text_string(NYsonPull::TScalar{i64{-200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "-20000",
+ to_yson_text_string(NYsonPull::TScalar{i64{-20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "-200000000",
+ to_yson_text_string(NYsonPull::TScalar{i64{-200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "-20000000000000000",
+ to_yson_text_string(NYsonPull::TScalar{i64{-20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "-9223372036854775808",
+ to_yson_text_string(NYsonPull::TScalar{i64{INT64_MIN}}));
+ }
Y_UNIT_TEST(TextUInt64) {
- UNIT_ASSERT_VALUES_EQUAL(
- "0u",
- to_yson_text_string(NYsonPull::TScalar{ui64{0}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "200u",
- to_yson_text_string(NYsonPull::TScalar{ui64{200}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "20000u",
- to_yson_text_string(NYsonPull::TScalar{ui64{20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "200000000u",
- to_yson_text_string(NYsonPull::TScalar{ui64{200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "20000000000000000u",
- to_yson_text_string(NYsonPull::TScalar{ui64{20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "9223372036854775807u",
- to_yson_text_string(NYsonPull::TScalar{ui64{INT64_MAX}}));
- UNIT_ASSERT_VALUES_EQUAL(
- "18446744073709551615u",
- to_yson_text_string(NYsonPull::TScalar{ui64{UINT64_MAX}}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ "0u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{0}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "200u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "20000u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "200000000u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "20000000000000000u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "9223372036854775807u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{INT64_MAX}}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "18446744073709551615u",
+ to_yson_text_string(NYsonPull::TScalar{ui64{UINT64_MAX}}));
+ }
Y_UNIT_TEST(TextFloat64) {
UNIT_ASSERT_VALUES_EQUAL(
@@ -131,97 +131,97 @@ Y_UNIT_TEST_SUITE(Writer) {
UNIT_ASSERT_VALUES_EQUAL(
"%nan",
to_yson_text_string(NYsonPull::TScalar{std::numeric_limits<double>::quiet_NaN()}));
- }
+ }
Y_UNIT_TEST(TextString) {
- UNIT_ASSERT_VALUES_EQUAL(
- R"("")",
- to_yson_text_string(NYsonPull::TScalar{""}));
- UNIT_ASSERT_VALUES_EQUAL(
- R"("hello")",
- to_yson_text_string(NYsonPull::TScalar{"hello"}));
- UNIT_ASSERT_VALUES_EQUAL(
- R"("hello\nworld")",
- to_yson_text_string(NYsonPull::TScalar{"hello\nworld"}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ R"("")",
+ to_yson_text_string(NYsonPull::TScalar{""}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ R"("hello")",
+ to_yson_text_string(NYsonPull::TScalar{"hello"}));
+ UNIT_ASSERT_VALUES_EQUAL(
+ R"("hello\nworld")",
+ to_yson_text_string(NYsonPull::TScalar{"hello\nworld"}));
+ }
- // =================== Binary format =====================
+ // =================== Binary format =====================
Y_UNIT_TEST(BinaryEntity) {
- UNIT_ASSERT_VALUES_EQUAL(
- "#",
- to_yson_binary_string(NYsonPull::TScalar{}));
- }
+ UNIT_ASSERT_VALUES_EQUAL(
+ "#",
+ to_yson_binary_string(NYsonPull::TScalar{}));
+ }
Y_UNIT_TEST(BinaryBoolean) {
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x4"),
- to_yson_binary_string(NYsonPull::TScalar{false}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{false}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x5"),
- to_yson_binary_string(NYsonPull::TScalar{true}));
- }
+ to_yson_binary_string(NYsonPull::TScalar{true}));
+ }
Y_UNIT_TEST(BinaryInt64) {
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\0"sv),
- to_yson_binary_string(NYsonPull::TScalar{i64{0}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{0}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\x90\x3"),
- to_yson_binary_string(NYsonPull::TScalar{i64{200}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xC0\xB8\x2"),
- to_yson_binary_string(NYsonPull::TScalar{i64{20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\x80\x88\xDE\xBE\x1"),
- to_yson_binary_string(NYsonPull::TScalar{i64{200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\x80\x80\x90\xF8\x9B\xF9\x86G"),
- to_yson_binary_string(NYsonPull::TScalar{i64{20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1"),
- to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MAX}}));
+ to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MAX}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\x8F\x3"),
- to_yson_binary_string(NYsonPull::TScalar{i64{-200}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{-200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xBF\xB8\x2"),
- to_yson_binary_string(NYsonPull::TScalar{i64{-20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{-20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xFF\x87\xDE\xBE\x1"),
- to_yson_binary_string(NYsonPull::TScalar{i64{-200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{-200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xFF\xFF\x8F\xF8\x9B\xF9\x86G"),
- to_yson_binary_string(NYsonPull::TScalar{i64{-20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{i64{-20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x2\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1"),
- to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MIN}}));
- }
+ to_yson_binary_string(NYsonPull::TScalar{i64{INT64_MIN}}));
+ }
Y_UNIT_TEST(BinaryUInt64) {
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\0"sv),
- to_yson_binary_string(NYsonPull::TScalar{ui64{0}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{0}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\xC8\x1"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{200}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{200}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\xA0\x9C\x1"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{20000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{20000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\x80\x84\xAF_"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{200000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{200000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\x80\x80\x88\xFC\xCD\xBC\xC3#"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{20000000000000000}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{20000000000000000}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{INT64_MAX}}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{ui64{INT64_MAX}}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x6\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1"),
- to_yson_binary_string(NYsonPull::TScalar{ui64{UINT64_MAX}}));
- }
+ to_yson_binary_string(NYsonPull::TScalar{ui64{UINT64_MAX}}));
+ }
Y_UNIT_TEST(BinaryFloat64) {
UNIT_ASSERT_VALUES_EQUAL(
@@ -239,18 +239,18 @@ Y_UNIT_TEST_SUITE(Writer) {
UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x03\x9a\x99\x99\x99\x99\x99\xf1\xbf"),
to_yson_binary_string(NYsonPull::TScalar{double{-1.1}}));
- }
+ }
Y_UNIT_TEST(BinaryString) {
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x1\0"sv),
- to_yson_binary_string(NYsonPull::TScalar{""}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{""}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x1\nhello"),
- to_yson_binary_string(NYsonPull::TScalar{"hello"}));
- UNIT_ASSERT_VALUES_EQUAL(
+ to_yson_binary_string(NYsonPull::TScalar{"hello"}));
+ UNIT_ASSERT_VALUES_EQUAL(
TStringBuf("\x1\x16hello\nworld"),
- to_yson_binary_string(NYsonPull::TScalar{"hello\nworld"}));
- }
+ to_yson_binary_string(NYsonPull::TScalar{"hello\nworld"}));
+ }
} // Y_UNIT_TEST_SUITE(Writer)