Skip to content

Commit

Permalink
encoding/prototext: capture current reserved field behavior
Browse files Browse the repository at this point in the history
This change was originally done in Google-internal cl/512993970.

Change-Id: I66ea95cd975b160892ed9f931312f1767cbc9fc9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/608315
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Michael Stapelberg <[email protected]>
Reviewed-by: Christian Höppner <[email protected]>
  • Loading branch information
stapelberg authored and gopherbot committed Aug 27, 2024
1 parent 5c1f700 commit cf4f382
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 131 deletions.
10 changes: 10 additions & 0 deletions encoding/prototext/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ s_string: "谷歌"
inputMessage: &pb3.Scalars{},
inputText: "unknown_field: 456",
wantErr: "unknown field",
}, {
desc: "proto2 message contains reserved field name",
inputMessage: &pb2.ReservedFieldNames{},
inputText: "reserved_field: 123 reserved_field { nested: 123 } opt_int32: 456",
wantMessage: &pb2.ReservedFieldNames{OptInt32: proto.Int32(456)},
}, {
desc: "proto3 message contains reserved field name",
inputMessage: &pb3.ReservedFieldNames{},
inputText: "reserved_field: 123 reserved_field { nested: 123 } opt_int32: 456",
wantMessage: &pb3.ReservedFieldNames{OptInt32: 456},
}, {
desc: "proto2 message contains discarded unknown field",
umo: prototext.UnmarshalOptions{DiscardUnknown: true},
Expand Down
Loading

0 comments on commit cf4f382

Please sign in to comment.