You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
665 B
38 lines
665 B
11 months ago
|
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)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|