Alex Goodman 59b880f26a
order locations by container layer order (#3858)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
2025-05-13 00:02:07 -04:00

25 lines
445 B
Go

package cmptest
type slicer[T any] interface {
ToSlice(sorter ...func(a, b T) int) []T
}
func buildSetComparer[T any, S slicer[T]](l func(x, y T) bool, sorters ...func(a, b T) int) func(x, y S) bool {
return func(x, y S) bool {
xs := x.ToSlice(sorters...)
ys := y.ToSlice(sorters...)
if len(xs) != len(ys) {
return false
}
for i, xe := range xs {
ye := ys[i]
if !l(xe, ye) {
return false
}
}
return true
}
}