Test ToSlice() with custom comparison function
(t *testing.T)
| 145 | |
| 146 | // Test ToSlice() with custom comparison function |
| 147 | func 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() |
| 162 | func TestIntSetFuncMatch(t *testing.T) { |