diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2017-02-13 10:46:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 10:46:40 -0800 |
commit | ed423c2c521862df9c9bb4a6b557ef0c503807cb (patch) | |
tree | 62bbae616befc4ea85455adc321decadc4120061 /src | |
parent | aa78aeba98f7a3b7648d849ddcf688407c4d6d34 (diff) | |
parent | 46c022a0a9d7639d928adbc1b3ea16f9d5765cf3 (diff) | |
download | protobuf-ed423c2c521862df9c9bb4a6b557ef0c503807cb.tar.gz protobuf-ed423c2c521862df9c9bb4a6b557ef0c503807cb.tar.bz2 protobuf-ed423c2c521862df9c9bb4a6b557ef0c503807cb.zip |
Merge pull request #2451 from podsvirov/json-primitive-map
JsonUtilTest: Add ParsePrimitiveMapIn subtest
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/util/json_util_test.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 3ce779c9..bf35ae3e 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -36,6 +36,7 @@ #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/descriptor_database.h> #include <google/protobuf/dynamic_message.h> +#include <google/protobuf/util/internal/testdata/maps.pb.h> #include <google/protobuf/util/json_format_proto3.pb.h> #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/util/type_resolver_util.h> @@ -50,6 +51,7 @@ using proto3::FOO; using proto3::BAR; using proto3::TestMessage; using proto3::TestMap; +using testing::MapIn; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -62,7 +64,7 @@ static string GetTypeUrl(const Descriptor* message) { // only cover some very basic cases to make sure the wrappers have forwarded // parameters to the underlying implementation correctly. More detailed // tests are contained in the //net/proto2/util/converter directory. -class JsonUtilTest : public testing::Test { +class JsonUtilTest : public ::testing::Test { protected: JsonUtilTest() { } @@ -196,6 +198,17 @@ TEST_F(JsonUtilTest, ParseMap) { EXPECT_EQ(message.DebugString(), other.DebugString()); } +TEST_F(JsonUtilTest, ParsePrimitiveMapIn) { + MapIn message; + JsonPrintOptions print_options; + print_options.always_print_primitive_fields = true; + JsonParseOptions parse_options; + EXPECT_EQ("{\"other\":\"\",\"things\":[],\"mapInput\":{}}", ToJson(message, print_options)); + MapIn other; + ASSERT_TRUE(FromJson(ToJson(message, print_options), &other, parse_options)); + EXPECT_EQ(message.DebugString(), other.DebugString()); +} + TEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) { TestMessage m; JsonParseOptions options; |