diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/json/ut/json_saveload_ut.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/json/ut/json_saveload_ut.cpp')
-rw-r--r-- | library/cpp/json/ut/json_saveload_ut.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/library/cpp/json/ut/json_saveload_ut.cpp b/library/cpp/json/ut/json_saveload_ut.cpp new file mode 100644 index 0000000000..b480a80fe4 --- /dev/null +++ b/library/cpp/json/ut/json_saveload_ut.cpp @@ -0,0 +1,36 @@ +#include <library/cpp/json/json_value.h> + +#include <library/cpp/testing/unittest/registar.h> +#include <util/stream/buffer.h> +#include <util/generic/buffer.h> +#include <util/ysaveload.h> + +Y_UNIT_TEST_SUITE(JsonSaveLoad) { + Y_UNIT_TEST(Serialize) { + + NJson::TJsonValue expected; + + expected["ui64"] = ui64(1); + expected["i64"] = i64(2); + expected["double"] = 2.0; + expected["string"] = "text"; + expected["map"] = expected; + expected["array"].SetType(NJson::JSON_ARRAY).GetArraySafe().emplace_back(expected); + expected["null"].SetType(NJson::JSON_NULL); + expected["undefined"].SetType(NJson::JSON_UNDEFINED); + + TBuffer buffer; + { + TBufferOutput output(buffer); + ::Save(&output, expected); + } + + NJson::TJsonValue load; + { + TBufferInput input(buffer); + ::Load(&input, load); + } + + UNIT_ASSERT_EQUAL_C(expected, load, "expected: " << expected << ", got: " << load); + } +} |