Add optional fields also to the testing

PiperOrigin-RevId: 592030444
pull/15133/head
Thomas Van Lenten 11 months ago committed by Copybara-Service
parent 542ca772fa
commit ba57a4e715
  1. 8
      src/google/protobuf/json/json_test.cc
  2. 12
      src/google/protobuf/util/json_format_proto3.proto

@ -204,6 +204,9 @@ TEST_P(JsonTest, TestDefaultValues) {
m.set_string_value("i am a test string value");
m.set_bytes_value("i am a test bytes value");
m.set_optional_bool_value(false);
m.set_optional_string_value("");
m.set_optional_bytes_value("");
EXPECT_THAT(
ToJson(m, options),
IsOkAndHolds("{\"boolValue\":false,"
@ -226,7 +229,10 @@ TEST_P(JsonTest, TestDefaultValues) {
"\"repeatedStringValue\":[],"
"\"repeatedBytesValue\":[],"
"\"repeatedEnumValue\":[],"
"\"repeatedMessageValue\":[]"
"\"repeatedMessageValue\":[],"
"\"optionalBoolValue\":false,"
"\"optionalStringValue\":\"\","
"\"optionalBytesValue\":\"\""
"}"));
EXPECT_THAT(

@ -54,6 +54,18 @@ message TestMessage {
repeated bytes repeated_bytes_value = 29;
repeated EnumType repeated_enum_value = 30;
repeated MessageType repeated_message_value = 31;
optional bool optional_bool_value = 41;
optional int32 optional_int32_value = 42;
optional int64 optional_int64_value = 43;
optional uint32 optional_uint32_value = 44;
optional uint64 optional_uint64_value = 45;
optional float optional_float_value = 46;
optional double optional_double_value = 47;
optional string optional_string_value = 48;
optional bytes optional_bytes_value = 49;
optional EnumType optional_enum_value = 50;
optional MessageType optional_message_value = 51;
}
message TestOneof {

Loading…
Cancel
Save