aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util_test.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2017-03-17 15:05:58 -0700
committerGravatar GitHub <noreply@github.com>2017-03-17 15:05:58 -0700
commit15b60bccf8992f7ff0897705e43aa8ab8889cd02 (patch)
tree811272aec7bfe0b81f6f2daaedfdc87eeb5b98c2 /src/google/protobuf/util/json_util_test.cc
parentc12cc3490bb5dc4bb686a597e10e8025b1617dac (diff)
parent89eb4e51b24f7417224b47faf32503d11b6b1bc0 (diff)
Merge pull request #2867 from mojoBrendan/master
Add preserve_proto_field_names option to JsonPrintOptions
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r--src/google/protobuf/util/json_util_test.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index 53c8a0f8..7c03d674 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -159,6 +159,43 @@ TEST_F(JsonUtilTest, TestDefaultValues) {
"\"repeatedMessageValue\":[]"
"}",
ToJson(m, options));
+
+ options.preserve_proto_field_names = true;
+ m.set_string_value("i am a test string value");
+ m.set_bytes_value("i am a test bytes value");
+ EXPECT_EQ(
+ "{\"bool_value\":false,"
+ "\"int32_value\":0,"
+ "\"int64_value\":\"0\","
+ "\"uint32_value\":0,"
+ "\"uint64_value\":\"0\","
+ "\"float_value\":0,"
+ "\"double_value\":0,"
+ "\"string_value\":\"i am a test string value\","
+ "\"bytes_value\":\"aSBhbSBhIHRlc3QgYnl0ZXMgdmFsdWU=\","
+ "\"enum_value\":\"FOO\","
+ "\"repeated_bool_value\":[],"
+ "\"repeated_int32_value\":[],"
+ "\"repeated_int64_value\":[],"
+ "\"repeated_uint32_value\":[],"
+ "\"repeated_uint64_value\":[],"
+ "\"repeated_float_value\":[],"
+ "\"repeated_double_value\":[],"
+ "\"repeated_string_value\":[],"
+ "\"repeated_bytes_value\":[],"
+ "\"repeated_enum_value\":[],"
+ "\"repeated_message_value\":[]"
+ "}",
+ ToJson(m, options));
+}
+
+TEST_F(JsonUtilTest, TestPreserveProtoFieldNames) {
+ TestMessage m;
+ m.mutable_message_value();
+
+ JsonPrintOptions options;
+ options.preserve_proto_field_names = true;
+ EXPECT_EQ("{\"message_value\":{}}", ToJson(m, options));
}
TEST_F(JsonUtilTest, TestAlwaysPrintEnumsAsInts) {