From 0517e5afc7c7fcc9bc0d5f9973fb921358755830 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 25 Oct 2024 15:25:18 +0200 Subject: [PATCH] testing/protocmp: document behavior when combining Ignore and Sort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes golang/protobuf#1652 Change-Id: I19af3714ec9fd9e54446bb0c3bd6815d90f11e10 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/622575 Reviewed-by: Christian Höppner Reviewed-by: Joseph Tsai LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Stapelberg --- testing/protocmp/util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/protocmp/util.go b/testing/protocmp/util.go index 838e70fbc..2282811b6 100644 --- a/testing/protocmp/util.go +++ b/testing/protocmp/util.go @@ -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) @@ -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