From 657337012a264721d58c470b4e9e796611f3c492 Mon Sep 17 00:00:00 2001 From: svshevtsov <svshevtsov@yandex-team.ru> Date: Thu, 10 Feb 2022 16:49:37 +0300 Subject: Restoring authorship annotation for <svshevtsov@yandex-team.ru>. Commit 1 of 2. --- library/cpp/json/ut/json_writer_ut.cpp | 74 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'library/cpp/json/ut/json_writer_ut.cpp') diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index ca11d34dad..af38ccf662 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -187,42 +187,42 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, ""), "\"A\""); UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, "Foo"), "Foo(\"A\")"); } - + Y_UNIT_TEST(FloatPrecision) { - const double value = 1517933989.4242; - const NJson::TJsonValue json(value); - NJson::TJsonWriterConfig config; - { - TString expected = "1517933989"; - TString actual = NJson::WriteJson(json); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - TString expected = "1517933989"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - config.DoubleNDigits = 13; - TString expected = "1517933989.424"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - config.DoubleNDigits = 6; - config.FloatToStringMode = PREC_POINT_DIGITS; - TString expected = "1517933989.424200"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - } + const double value = 1517933989.4242; + const NJson::TJsonValue json(value); + NJson::TJsonWriterConfig config; + { + TString expected = "1517933989"; + TString actual = NJson::WriteJson(json); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + TString expected = "1517933989"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + config.DoubleNDigits = 13; + TString expected = "1517933989.424"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + config.DoubleNDigits = 6; + config.FloatToStringMode = PREC_POINT_DIGITS; + TString expected = "1517933989.424200"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + } } -- cgit v1.2.3