aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util_test.cc
diff options
context:
space:
mode:
authorGravatar Konstantin Podsvirov <konstantin@podsvirov.pro>2016-12-07 00:28:36 +0300
committerGravatar Konstantin Podsvirov <konstantin@podsvirov.pro>2017-02-11 03:39:53 +0300
commit46c022a0a9d7639d928adbc1b3ea16f9d5765cf3 (patch)
treec45c73620dafd74f8741c4fe12d1aeb9d837409b /src/google/protobuf/util/json_util_test.cc
parente844510f442119cc0c9b3d3ebbf06a542d7d18eb (diff)
JsonUtilTest: Add ParsePrimitiveMapIn subtest
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r--src/google/protobuf/util/json_util_test.cc15
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;