parent
62a894e89e
commit
2b79866b14
@ -0,0 +1,37 @@ |
||||
package set |
||||
|
||||
import ( |
||||
"reflect" |
||||
"testing" |
||||
) |
||||
|
||||
func TestSet_ToCustomSortSlice(t *testing.T) { |
||||
type args struct { |
||||
f func(i, j int) bool |
||||
} |
||||
type testCase[T Comparable] struct { |
||||
name string |
||||
s Set[T] |
||||
args args |
||||
want []T |
||||
} |
||||
tests := []testCase[int]{ |
||||
{ |
||||
name: "test1", |
||||
s: NewSetWithItems(1, 2, 3, 4, 5), |
||||
args: args{ |
||||
f: func(i, j int) bool { |
||||
return i > j |
||||
}, |
||||
}, |
||||
want: []int{5, 4, 3, 2, 1}, |
||||
}, |
||||
} |
||||
for _, tt := range tests { |
||||
t.Run(tt.name, func(t *testing.T) { |
||||
if got := tt.s.ToCustomSortSlice(tt.args.f); !reflect.DeepEqual(got, tt.want) { |
||||
t.Errorf("ToCustomSortSlice() = %v, want %v", got, tt.want) |
||||
} |
||||
}) |
||||
} |
||||
} |
Loading…
Reference in new issue