Skip to content

Commit

Permalink
testing/protocmp: document behavior when combining Ignore and Sort
Browse files Browse the repository at this point in the history
fixes golang/protobuf#1652

Change-Id: I19af3714ec9fd9e54446bb0c3bd6815d90f11e10
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/622575
Reviewed-by: Christian Höppner <hoeppi@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
  • Loading branch information
stapelberg authored and gopherbot committed Oct 28, 2024
1 parent d14ebce commit 0517e5a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions testing/protocmp/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ func IgnoreUnknown() cmp.Option {
// handled by this option. To sort Go slices that are not repeated fields,
// consider using [github.com/google/go-cmp/cmp/cmpopts.SortSlices] instead.
//
// The sorting of messages does not take into account ignored fields or oneofs
// as a result of [IgnoreFields] or [IgnoreOneofs].
//
// This must be used in conjunction with [Transform].
func SortRepeated(lessFunc any) cmp.Option {
t, ok := checkTTBFunc(lessFunc)
Expand Down Expand Up @@ -624,6 +627,9 @@ func checkTTBFunc(lessFunc any) (reflect.Type, bool) {
// ... // user-provided definition for less
// }))
//
// The sorting of messages does not take into account ignored fields or oneofs
// as a result of [IgnoreFields] or [IgnoreOneofs].
//
// This must be used in conjunction with [Transform].
func SortRepeatedFields(message proto.Message, names ...protoreflect.Name) cmp.Option {
var opts cmp.Options
Expand Down

0 comments on commit 0517e5a

Please sign in to comment.