diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 3ce779c922..bf35ae3ea0 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -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;