MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

library/cpp/json/ut/json_writer_ut.cpp:9–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8Y_UNIT_TEST_SUITE(TJsonWriterTest) {
9 Y_UNIT_TEST(SimpleWriteTest) {
10 TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3";
11 TString expected2 = expected1 + ",\"array\":[\"stroka\",false]";
12 TString expected3 = expected2 + "}";
13
14 TStringStream out;
15
16 TJsonWriter json(&out, false);
17 json.OpenMap();
18 json.Write("key1", (ui16)1);
19 json.WriteKey("key2");
20 json.Write((i32)2);
21 json.Write("key3", (ui64)3);
22
23 UNIT_ASSERT(out.Empty());
24 json.Flush();
25 UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected1);
26
27 json.Write("array");
28 json.OpenArray();
29 json.Write("stroka");
30 json.Write(false);
31 json.CloseArray();
32
33 UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected1);
34 json.Flush();
35 UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected2);
36
37 json.CloseMap();
38
39 UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected2);
40 json.Flush();
41 UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected3);
42 }
43
44 Y_UNIT_TEST(SimpleWriteValueTest) {
45 TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}";

Callers

nothing calls this directly

Calls 15

NothingFunction · 0.85
AppendValueMethod · 0.80
WriteJsonFunction · 0.50
TJsonValueClass · 0.50
WrapJsonToCallbackFunction · 0.50
OpenMapMethod · 0.45
WriteMethod · 0.45
WriteKeyMethod · 0.45
EmptyMethod · 0.45
FlushMethod · 0.45
StrMethod · 0.45
OpenArrayMethod · 0.45

Tested by

no test coverage detected