aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util_test.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-08-11 15:07:12 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-08-11 17:19:54 -0700
commitbd11198f694a2cb1544992bb7868198b1e9dfe6c (patch)
tree3335f17b58d66091025f6407e16ea1708170f26f /src/google/protobuf/util/json_util_test.cc
parentedaefac5d2221ab26b9988fb76c79760c6495fb8 (diff)
Fix map fields parsing.
Change-Id: If61e16cea84492474a71bbfe985131ec980b0b0a
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r--src/google/protobuf/util/json_util_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index 8399b408..6686416c 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -47,6 +47,7 @@ namespace {
using proto3::FOO;
using proto3::BAR;
using proto3::TestMessage;
+using proto3::TestMap;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
@@ -146,6 +147,16 @@ TEST_F(JsonUtilTest, ParseMessage) {
EXPECT_EQ(96, m.repeated_message_value(1).value());
}
+TEST_F(JsonUtilTest, ParseMap) {
+ TestMap message;
+ (*message.mutable_string_map())["hello"] = 1234;
+ JsonOptions options;
+ EXPECT_EQ("{\"stringMap\":{\"hello\":1234}}", ToJson(message, options));
+ TestMap other;
+ ASSERT_TRUE(FromJson(ToJson(message, options), &other));
+ EXPECT_EQ(message.DebugString(), other.DebugString());
+}
+
typedef pair<char*, int> Segment;
// A ZeroCopyOutputStream that writes to multiple buffers.
class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream {