diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/json/writer | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/json/writer')
-rw-r--r-- | library/cpp/json/writer/json.h | 6 | ||||
-rw-r--r-- | library/cpp/json/writer/json_ut.cpp | 46 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value.cpp | 10 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 40 |
4 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 0aae2531b9..94a1953630 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -41,7 +41,7 @@ namespace NJsonWriter { class TBuf : TNonCopyable { public: - TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); + TBuf(EHtmlEscapeMode mode = HEM_DONT_ESCAPE_HTML, IOutputStream* stream = nullptr); TValueContext WriteString(const TStringBuf& s, EHtmlEscapeMode hem); TValueContext WriteString(const TStringBuf& s); @@ -93,7 +93,7 @@ namespace NJsonWriter { /*** Dump and forget the string constructed so far. * You may only call it if the `stream' parameter was NULL * at construction time. */ - void FlushTo(IOutputStream* stream); + void FlushTo(IOutputStream* stream); /*** Write a literal string that represents a JSON value * (string, number, object, array, bool, or null). @@ -145,7 +145,7 @@ namespace NJsonWriter { TValueContext WriteFloatImpl(TFloat f, EFloatToStringMode mode, int ndigits); private: - IOutputStream* Stream; + IOutputStream* Stream; THolder<TStringStream> StringStream; typedef TVector<const TString*> TKeys; TKeys Keys; diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp index 9980555683..c2b2ccb95c 100644 --- a/library/cpp/json/writer/json_ut.cpp +++ b/library/cpp/json/writer/json_ut.cpp @@ -6,8 +6,8 @@ #include <limits> -Y_UNIT_TEST_SUITE(JsonWriter) { - Y_UNIT_TEST(Struct) { +Y_UNIT_TEST_SUITE(JsonWriter) { + Y_UNIT_TEST(Struct) { NJsonWriter::TBuf w; w.BeginList(); w.BeginObject() @@ -29,21 +29,21 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "[{\"key\":\"value\",\"xk\":13,\"key2\":[{},{}]},43,\"x\",\"...\"]"; UNIT_ASSERT_EQUAL(w.Str(), exp); } - Y_UNIT_TEST(EscapedString) { + Y_UNIT_TEST(EscapedString) { NJsonWriter::TBuf w(NJsonWriter::HEM_ESCAPE_HTML); w.WriteString(" \n \r \t \007 \b \f ' <tag> &ent; \"txt\" "); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\u0007 \\b \\f ' <tag> &ent; "txt" \""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedString) { + Y_UNIT_TEST(UnescapedString) { NJsonWriter::TBuf w; w.WriteString(" \n \r \t \b \f '; -- <tag> &ent; \"txt\"", NJsonWriter::HEM_DONT_ESCAPE_HTML); TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\b \\f \\u0027; -- \\u003Ctag\\u003E &ent; \\\"txt\\\"\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedChaining) { + Y_UNIT_TEST(UnescapedChaining) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.UnsafeWriteRawBytes("(", 1); w.BeginList().WriteString("<>&'\\").BeginList(); @@ -52,27 +52,27 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "([\"\\u003C\\u003E&\\u0027\\\\\",[]]"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(Utf8) { + Y_UNIT_TEST(Utf8) { TString ws = NJsonWriter::TBuf().WriteString("яЯ σΣ ש א").Str(); const char* exp = "\"яЯ σΣ ש א\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(WrongObject) { + Y_UNIT_TEST(WrongObject) { NJsonWriter::TBuf w; w.BeginObject(); UNIT_ASSERT_EXCEPTION(w.WriteString("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(WrongList) { + Y_UNIT_TEST(WrongList) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.WriteKey("hehe"), NJsonWriter::TError); } - Y_UNIT_TEST(Incomplete) { + Y_UNIT_TEST(Incomplete) { NJsonWriter::TBuf w; w.BeginList(); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(BareKey) { + Y_UNIT_TEST(BareKey) { NJsonWriter::TBuf w; w.BeginObject() .CompatWriteKeyWithoutQuotes("p") @@ -84,24 +84,24 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char* exp = "{p:1,n:0}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(UnescapedStringInObject) { + Y_UNIT_TEST(UnescapedStringInObject) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.BeginObject().WriteKey("key").WriteString("</&>'").EndObject(); TString ws = w.Str(); const char* exp = "{\"key\":\"\\u003C\\/&\\u003E\\u0027\"}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } - Y_UNIT_TEST(ForeignStreamStr) { + Y_UNIT_TEST(ForeignStreamStr) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &Cerr); UNIT_ASSERT_EXCEPTION(w.Str(), NJsonWriter::TError); } - Y_UNIT_TEST(ForeignStreamValue) { + Y_UNIT_TEST(ForeignStreamValue) { TStringStream ss; NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML, &ss); w.WriteInt(1543); UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), "1543"); } - Y_UNIT_TEST(Indentation) { + Y_UNIT_TEST(Indentation) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.SetIndentSpaces(2); w.BeginList() @@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { "]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValue) { + Y_UNIT_TEST(WriteJsonValue) { using namespace NJson; TJsonValue val; val.AppendValue(1); @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "[1,\"2\",3.5,{\"key\":\"value\"},null]"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(WriteJsonValueSorted) { + Y_UNIT_TEST(WriteJsonValueSorted) { using namespace NJson; TJsonValue val; val.InsertValue("1", TJsonValue(1)); @@ -159,35 +159,35 @@ Y_UNIT_TEST_SUITE(JsonWriter) { const char exp[] = "{\"0\":{\"succ\":1,\"zero\":0},\"1\":1,\"2\":2}"; UNIT_ASSERT_STRINGS_EQUAL(exp, w.Str()); } - Y_UNIT_TEST(Unescaped) { + Y_UNIT_TEST(Unescaped) { NJsonWriter::TBuf buf(NJsonWriter::HEM_UNSAFE); buf.WriteString("</security>'"); UNIT_ASSERT_STRINGS_EQUAL("\"</security>'\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyJsonp) { + Y_UNIT_TEST(LittleBobbyJsonp) { NJsonWriter::TBuf buf; buf.WriteString("hello\xe2\x80\xa8\xe2\x80\xa9stranger"); UNIT_ASSERT_STRINGS_EQUAL("\"hello\\u2028\\u2029stranger\"", buf.Str()); } - Y_UNIT_TEST(LittleBobbyInvalid) { + Y_UNIT_TEST(LittleBobbyInvalid) { NJsonWriter::TBuf buf; TStringBuf incomplete("\xe2\x80\xa8", 2); buf.WriteString(incomplete); // garbage in - garbage out UNIT_ASSERT_STRINGS_EQUAL("\"\xe2\x80\"", buf.Str()); } - Y_UNIT_TEST(OverlyZealous) { + Y_UNIT_TEST(OverlyZealous) { NJsonWriter::TBuf buf; buf.WriteString("—"); UNIT_ASSERT_STRINGS_EQUAL("\"—\"", buf.Str()); } - Y_UNIT_TEST(RelaxedEscaping) { + Y_UNIT_TEST(RelaxedEscaping) { NJsonWriter::TBuf buf(NJsonWriter::HEM_RELAXED); buf.WriteString("</>"); UNIT_ASSERT_STRINGS_EQUAL("\"\\u003C/\\u003E\"", buf.Str()); } - Y_UNIT_TEST(FloatFormatting) { + Y_UNIT_TEST(FloatFormatting) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML); buf.BeginList() .WriteFloat(0.12345678987654321f) @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(JsonWriter) { UNIT_ASSERT_STRINGS_EQUAL(exp, buf.Str()); } - Y_UNIT_TEST(NanFormatting) { + Y_UNIT_TEST(NanFormatting) { { NJsonWriter::TBuf buf; buf.BeginObject(); diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index c61e8d1dc4..27da313fd4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -18,7 +18,7 @@ static bool AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); + Y_VERIFY(lhs.GetType() == JSON_MAP, "lhs has not a JSON_MAP type."); if (rhs.GetType() != JSON_MAP) return false; @@ -30,12 +30,12 @@ AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { if (lhsMap.size() != rhsMap.size()) return false; - for (const auto& lhsIt : lhsMap) { + for (const auto& lhsIt : lhsMap) { TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); if (rhsIt == rhsMap.end()) return false; - if (lhsIt.second != rhsIt->second) + if (lhsIt.second != rhsIt->second) return false; } @@ -46,7 +46,7 @@ static bool AreJsonArraysEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { using namespace NJson; - Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); + Y_VERIFY(lhs.GetType() == JSON_ARRAY, "lhs has not a JSON_ARRAY type."); if (rhs.GetType() != JSON_ARRAY) return false; @@ -1099,7 +1099,7 @@ namespace NJson { } template <> -void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { +void Out<NJson::TJsonValue>(IOutputStream& out, const NJson::TJsonValue& v) { NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML, &out); buf.WriteJsonValue(&v); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index dc7f6affdf..ea33ef0888 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -6,8 +6,8 @@ using namespace NJson; -Y_UNIT_TEST_SUITE(TJsonValueTest) { - Y_UNIT_TEST(UndefTest) { +Y_UNIT_TEST_SUITE(TJsonValueTest) { + Y_UNIT_TEST(UndefTest) { TJsonValue undef; TJsonValue null(JSON_NULL); TJsonValue _false(false); @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(undef != emptyMap); } - Y_UNIT_TEST(DefaultCompareTest) { + Y_UNIT_TEST(DefaultCompareTest) { { TJsonValue lhs; TJsonValue rhs; @@ -52,14 +52,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NullCompareTest) { + Y_UNIT_TEST(NullCompareTest) { TJsonValue lhs(JSON_NULL); TJsonValue rhs(JSON_NULL); UNIT_ASSERT(lhs == rhs); UNIT_ASSERT(rhs == lhs); } - Y_UNIT_TEST(StringCompareTest) { + Y_UNIT_TEST(StringCompareTest) { { TJsonValue lhs(JSON_STRING); TJsonValue rhs(JSON_STRING); @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(ArrayCompareTest) { + Y_UNIT_TEST(ArrayCompareTest) { { TJsonValue lhs(JSON_ARRAY); TJsonValue rhs(JSON_ARRAY); @@ -139,7 +139,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(CompareTest) { + Y_UNIT_TEST(CompareTest) { { TJsonValue lhs; lhs.InsertValue("null value", TJsonValue(JSON_NULL)); @@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(SwapTest) { + Y_UNIT_TEST(SwapTest) { { TJsonValue lhs; lhs.InsertValue("a", "b"); @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathTest) { + Y_UNIT_TEST(GetValueByPathTest) { { TJsonValue lhs; TJsonValue first; @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetValueByPathConstTest) { + Y_UNIT_TEST(GetValueByPathConstTest) { TJsonValue lhs; TJsonValue first; TJsonValue second; @@ -339,7 +339,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", '.')->GetStringRobust() == "f"); } - Y_UNIT_TEST(EraseValueFromArray) { + Y_UNIT_TEST(EraseValueFromArray) { { TJsonValue vec; vec.AppendValue(TJsonValue(0)); @@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonConstMethodsTest) { + Y_UNIT_TEST(NonConstMethodsTest) { { TJsonValue src; TJsonValue value1; @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(NonexistentFieldAccessTest) { + Y_UNIT_TEST(NonexistentFieldAccessTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -518,7 +518,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(DefaultValuesTest) { + Y_UNIT_TEST(DefaultValuesTest) { { TJsonValue json; json.InsertValue("some", "key"); @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } } - Y_UNIT_TEST(GetArrayPointerInArrayTest) { + Y_UNIT_TEST(GetArrayPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetArrayPointerInMapTest) { + Y_UNIT_TEST(GetArrayPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -570,7 +570,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*array)[1], 2); } - Y_UNIT_TEST(GetMapPointerInArrayTest) { + Y_UNIT_TEST(GetMapPointerInArrayTest) { TJsonValue outer; { TJsonValue json; @@ -585,7 +585,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetMapPointerInMapTest) { + Y_UNIT_TEST(GetMapPointerInMapTest) { TJsonValue outer; { TJsonValue json; @@ -600,14 +600,14 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_VALUES_EQUAL((*map).at("b"), 2); } - Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { + Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { TString value = "1626862681464633683"; TJsonValue json(value); UNIT_ASSERT_VALUES_EQUAL(json.GetUIntegerRobust(), FromString<ui64>(value)); UNIT_ASSERT_VALUES_EQUAL(json.GetIntegerRobust(), FromString<i64>(value)); } - Y_UNIT_TEST(MoveSubpartToSelf) { + Y_UNIT_TEST(MoveSubpartToSelf) { TJsonValue json; json[0] = "testing 0"; json[1] = "testing 1"; |