aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util_test.cc
diff options
context:
space:
mode:
authorGravatar Jie Luo <jieluo@google.com>2017-03-10 16:55:35 -0800
committerGravatar Jie Luo <jieluo@google.com>2017-03-10 16:58:20 -0800
commitd59592af61852023f549e91683ade4f062c2df83 (patch)
treef6b02e28502e1abe67c0bad2a899a77fbd3a8537 /src/google/protobuf/util/json_util_test.cc
parentae220cda61fe9efb69b3977d6813164e4d5e9a34 (diff)
DefaultValueObjectWriter should populate oneof message field
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r--src/google/protobuf/util/json_util_test.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index b0c2f494..53c8a0f8 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -51,6 +51,7 @@ using proto3::FOO;
using proto3::BAR;
using proto3::TestMessage;
using proto3::TestMap;
+using proto3::TestOneof;
using testing::MapIn;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
@@ -232,6 +233,21 @@ TEST_F(JsonUtilTest, ParsePrimitiveMapIn) {
EXPECT_EQ(message.DebugString(), other.DebugString());
}
+TEST_F(JsonUtilTest, PrintPrimitiveOneof) {
+ TestOneof message;
+ JsonPrintOptions options;
+ options.always_print_primitive_fields = true;
+ message.mutable_oneof_message_value();
+ EXPECT_EQ(
+ "{\"oneofMessageValue\":{\"value\":0}}",
+ ToJson(message, options));
+
+ message.set_oneof_int32_value(1);
+ EXPECT_EQ(
+ "{\"oneofInt32Value\":1}",
+ ToJson(message, options));
+}
+
TEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) {
TestMessage m;
JsonParseOptions options;