File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616#include < string>
1717#include < type_traits>
1818#include < utility>
19- #include < vector>
2019
2120#include " absl/log/absl_check.h"
2221#include " absl/log/absl_log.h"
@@ -3685,6 +3684,22 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::RunJsonTestsForAny() {
36853684 })" ,
36863685 R"(
36873686 )" );
3687+
3688+ // google.protobuf.Empty packed into an Any, implementations must accept it
3689+ // without the "value" field set. This also confirms that what they round trip
3690+ // does not have `"value":{}` set on it, since the test harness uses the C++
3691+ // JSON parser which will reject it.
3692+ RunValidJsonTest (" AnyEmpty" , REQUIRED,
3693+ R"( {
3694+ "optionalAny": {
3695+ "@type": "type.googleapis.com/google.protobuf.Empty"
3696+ }
3697+ })" ,
3698+ R"(
3699+ optional_any: {
3700+ [type.googleapis.com/google.protobuf.Empty] {}
3701+ }
3702+ )" );
36883703}
36893704
36903705template <typename MessageType>
Original file line number Diff line number Diff line change @@ -40,4 +40,4 @@ Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
4040Required.*.ProtobufInput.BadTag_FieldNumberTooHigh # Should have failed to parse, but didn't.
4141Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
4242Required.*.ProtobufInput.BadTag_OverlongVarint # Should have failed to parse, but didn't.
43-
43+ Required.*.JsonInput.AnyEmpty.*
Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ proto_library(
258258 deps = [
259259 "//:any_proto" ,
260260 "//:duration_proto" ,
261+ "//:empty_proto" ,
261262 "//:field_mask_proto" ,
262263 "//:struct_proto" ,
263264 "//:timestamp_proto" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package protobuf_test_messages.proto3;
1818
1919import "google/protobuf/any.proto" ;
2020import "google/protobuf/duration.proto" ;
21+ import "google/protobuf/empty.proto" ;
2122import "google/protobuf/field_mask.proto" ;
2223import "google/protobuf/struct.proto" ;
2324import "google/protobuf/timestamp.proto" ;
@@ -255,13 +256,15 @@ message TestAllTypesProto3 {
255256 google.protobuf.Any optional_any = 305 ;
256257 google.protobuf.Value optional_value = 306 ;
257258 google.protobuf.NullValue optional_null_value = 307 ;
259+ google.protobuf.Empty optional_empty = 308 ;
258260 repeated google.protobuf.Duration repeated_duration = 311 ;
259261 repeated google.protobuf.Timestamp repeated_timestamp = 312 ;
260262 repeated google.protobuf.FieldMask repeated_fieldmask = 313 ;
261263 repeated google.protobuf.Struct repeated_struct = 324 ;
262264 repeated google.protobuf.Any repeated_any = 315 ;
263265 repeated google.protobuf.Value repeated_value = 316 ;
264266 repeated google.protobuf.ListValue repeated_list_value = 317 ;
267+ repeated google.protobuf.Empty repeated_empty = 318 ;
265268
266269 // Test field-name-to-JSON-name convention.
267270 // (protobuf says names can be any valid C/C++ identifier.)
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package protobuf_test_messages.proto3;
1919
2020import "google/protobuf/any.proto" ;
2121import "google/protobuf/duration.proto" ;
22+ import "google/protobuf/empty.proto" ;
2223import "google/protobuf/field_mask.proto" ;
2324import "google/protobuf/struct.proto" ;
2425import "google/protobuf/timestamp.proto" ;
@@ -268,13 +269,15 @@ message TestAllTypesProto3 {
268269 google.protobuf.Any optional_any = 305 ;
269270 google.protobuf.Value optional_value = 306 ;
270271 google.protobuf.NullValue optional_null_value = 307 ;
272+ google.protobuf.Empty optional_empty = 308 ;
271273 repeated google.protobuf.Duration repeated_duration = 311 ;
272274 repeated google.protobuf.Timestamp repeated_timestamp = 312 ;
273275 repeated google.protobuf.FieldMask repeated_fieldmask = 313 ;
274276 repeated google.protobuf.Struct repeated_struct = 324 ;
275277 repeated google.protobuf.Any repeated_any = 315 ;
276278 repeated google.protobuf.Value repeated_value = 316 ;
277279 repeated google.protobuf.ListValue repeated_list_value = 317 ;
280+ repeated google.protobuf.Empty repeated_empty = 318 ;
278281
279282 // Test field-name-to-JSON-name convention.
280283 // (protobuf says names can be any valid C/C++ identifier.)
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package protobuf_test_messages.editions.proto3;
1818
1919import "google/protobuf/any.proto" ;
2020import "google/protobuf/duration.proto" ;
21+ import "google/protobuf/empty.proto" ;
2122import "google/protobuf/field_mask.proto" ;
2223import "google/protobuf/struct.proto" ;
2324import "google/protobuf/timestamp.proto" ;
@@ -255,13 +256,15 @@ message TestAllTypesProto3 {
255256 google.protobuf.Any optional_any = 305 ;
256257 google.protobuf.Value optional_value = 306 ;
257258 google.protobuf.NullValue optional_null_value = 307 ;
259+ google.protobuf.Empty optional_empty = 308 ;
258260 repeated google.protobuf.Duration repeated_duration = 311 ;
259261 repeated google.protobuf.Timestamp repeated_timestamp = 312 ;
260262 repeated google.protobuf.FieldMask repeated_fieldmask = 313 ;
261263 repeated google.protobuf.Struct repeated_struct = 324 ;
262264 repeated google.protobuf.Any repeated_any = 315 ;
263265 repeated google.protobuf.Value repeated_value = 316 ;
264266 repeated google.protobuf.ListValue repeated_list_value = 317 ;
267+ repeated google.protobuf.Empty repeated_empty = 318 ;
265268
266269 // Test field-name-to-JSON-name convention.
267270 // (protobuf says names can be any valid C/C++ identifier.)
Original file line number Diff line number Diff line change @@ -1374,6 +1374,7 @@ proto_library(
13741374 deps = [
13751375 ":any_proto" ,
13761376 ":duration_proto" ,
1377+ ":empty_proto" ,
13771378 ":field_mask_proto" ,
13781379 ":struct_proto" ,
13791380 ":timestamp_proto" ,
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ option optimize_for = SPEED;
2424
2525import "google/protobuf/any.proto" ;
2626import "google/protobuf/duration.proto" ;
27+ import "google/protobuf/empty.proto" ;
2728import "google/protobuf/field_mask.proto" ;
2829import "google/protobuf/struct.proto" ;
2930import "google/protobuf/timestamp.proto" ;
@@ -212,6 +213,7 @@ message TestAllTypesProto3 {
212213 google.protobuf.Any optional_any = 305 ;
213214 google.protobuf.Value optional_value = 306 ;
214215 google.protobuf.NullValue optional_null_value = 307 ;
216+ google.protobuf.Empty optional_empty = 308 ;
215217
216218 repeated google.protobuf.Duration repeated_duration = 311 ;
217219 repeated google.protobuf.Timestamp repeated_timestamp = 312 ;
@@ -220,6 +222,7 @@ message TestAllTypesProto3 {
220222 repeated google.protobuf.Any repeated_any = 315 ;
221223 repeated google.protobuf.Value repeated_value = 316 ;
222224 repeated google.protobuf.ListValue repeated_list_value = 317 ;
225+ repeated google.protobuf.Empty repeated_empty = 318 ;
223226
224227 // Test field-name-to-JSON-name convention.
225228 // (protobuf says names can be any valid C/C++ identifier.)
You can’t perform that action at this time.
0 commit comments