MCPcopy
hub / github.com/minio/minio-go / TestToSliceWithCustomCompare

Function TestToSliceWithCustomCompare

pkg/set/set_test.go:147–159  ·  view source on GitHub ↗

Test ToSlice() with custom comparison function

(t *testing.T)

Source from the content-addressed store, hash-verified

145
146// Test ToSlice() with custom comparison function
147func TestToSliceWithCustomCompare(t *testing.T) {
148 s := Create(3, 1, 4, 1, 5, 9, 2, 6)
149
150 // Reverse sort
151 slice := s.ToSlice(func(a, b int) int {
152 return cmp.Compare(b, a)
153 })
154
155 expected := []int{9, 6, 5, 4, 3, 2, 1}
156 if !reflect.DeepEqual(slice, expected) {
157 t.Fatalf("expected reverse sorted slice %v, got: %v", expected, slice)
158 }
159}
160
161// Test FuncMatch()
162func TestIntSetFuncMatch(t *testing.T) {

Callers

nothing calls this directly

Calls 2

CreateFunction · 0.85
ToSliceMethod · 0.45

Tested by

no test coverage detected