diff options
| author | chegoryu <[email protected]> | 2022-02-10 16:49:47 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:47 +0300 | 
| commit | 767f05356832cfac686778897626e124d257dbc8 (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf | |
| parent | e4b93027b4c6dbd741ebd637f0b5db1d583ee93f (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf')
| -rw-r--r-- | library/cpp/protobuf/json/json2proto.cpp | 2 | ||||
| -rw-r--r-- | library/cpp/protobuf/json/json2proto.h | 16 | ||||
| -rw-r--r-- | library/cpp/protobuf/json/ut/json2proto_ut.cpp | 48 | 
3 files changed, 33 insertions, 33 deletions
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 9a13f0abd08..640c10f5a51 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -408,7 +408,7 @@ namespace NProtobufJson {      void MergeJson2Proto(const TStringBuf& json, google::protobuf::Message& proto, const TJson2ProtoConfig& config) {          NJson::TJsonReaderConfig jsonCfg;          jsonCfg.DontValidateUtf8 = true; -        jsonCfg.AllowComments = config.AllowComments;  +        jsonCfg.AllowComments = config.AllowComments;          NJson::TJsonValue jsonValue;          ReadJsonTree(json, &jsonCfg, &jsonValue, /* throwOnError = */ true); diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h index 84402245b07..4c33498dfa3 100644 --- a/library/cpp/protobuf/json/json2proto.h +++ b/library/cpp/protobuf/json/json2proto.h @@ -93,11 +93,11 @@ namespace NProtobufJson {              return *this;          } -        TSelf& SetAllowComments(bool value) {  -            AllowComments = value;  -            return *this;  -        }  -  +        TSelf& SetAllowComments(bool value) { +            AllowComments = value; +            return *this; +        } +          TSelf& SetAllowUnknownFields(bool value) {              AllowUnknownFields = value;              return *this; @@ -141,9 +141,9 @@ namespace NProtobufJson {          /// Custom spliter non array value to repeated fields.          TValueVectorizer ValueVectorizer; -  -        /// Allow js-style comments (both // and /**/)  -        bool AllowComments = false;  + +        /// Allow js-style comments (both // and /**/) +        bool AllowComments = false;      };      /// @throw yexception diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 24964ea652e..0dfe57bc7a2 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -1120,28 +1120,28 @@ Y_UNIT_TEST(TestEmptyStringForCastFromString) {      UNIT_ASSERT_EQUAL("", proto.GetOneString());  } // TestEmptyStringForCastFromString -Y_UNIT_TEST(TestAllowComments) {  -    constexpr TStringBuf json = R"(  -{  -    "I32": 4, // comment1  -/*  -    comment2  -    {}  -    qwer  -*/  -    "I64": 3423  -}  -  -)";  -  -    TJson2ProtoConfig config;  -    TFlatOptional proto;  -    UNIT_ASSERT_EXCEPTION_CONTAINS(Json2Proto(json, proto, config), yexception, "Error: Missing a name for object member");  -  -    config.SetAllowComments(true);  -    UNIT_ASSERT_NO_EXCEPTION(Json2Proto(json, proto, config));  -    UNIT_ASSERT_VALUES_EQUAL(proto.GetI32(), 4);  -    UNIT_ASSERT_VALUES_EQUAL(proto.GetI64(), 3423);  -} // TestAllowComments  -  +Y_UNIT_TEST(TestAllowComments) { +    constexpr TStringBuf json = R"( +{ +    "I32": 4, // comment1 +/* +    comment2 +    {} +    qwer +*/ +    "I64": 3423 +} + +)"; + +    TJson2ProtoConfig config; +    TFlatOptional proto; +    UNIT_ASSERT_EXCEPTION_CONTAINS(Json2Proto(json, proto, config), yexception, "Error: Missing a name for object member"); + +    config.SetAllowComments(true); +    UNIT_ASSERT_NO_EXCEPTION(Json2Proto(json, proto, config)); +    UNIT_ASSERT_VALUES_EQUAL(proto.GetI32(), 4); +    UNIT_ASSERT_VALUES_EQUAL(proto.GetI64(), 3423); +} // TestAllowComments +  } // TJson2ProtoTest  | 
