Commit d83a9f66 authored by Brandon Cole's avatar Brandon Cole

Add unit test for loading unknown fields in Any messages

Use ./tests.sh cpp to run it
parent 45d03a97
......@@ -56,6 +56,7 @@ using proto3::TestEnumValue;
using proto3::TestMap;
using proto3::TestMessage;
using proto3::TestOneof;
using proto3::TestAny;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
......@@ -357,6 +358,23 @@ TEST_F(JsonUtilTest, TestDynamicMessage) {
EXPECT_EQ(ToJson(generated, options), ToJson(*message, options));
}
TEST_F(JsonUtilTest, TestParsingUnknownAnyFields) {
string input =
"{\n"
" \"value\": {\n"
" \"@type\": \"type.googleapis.com/proto3.TestMessage\",\n"
" \"unknown_field\": \"UNKOWN_VALUE\"\n"
" }\n"
"}";
TestAny m;
JsonParseOptions options;
EXPECT_FALSE(FromJson(input, &m, options));
options.ignore_unknown_fields = true;
EXPECT_TRUE(FromJson(input, &m, options));
}
TEST_F(JsonUtilTest, TestParsingUnknownEnumsProto2) {
string input =
"{\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment