mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-26 16:36:26 -06:00
30 lines
466 B
Go
30 lines
466 B
Go
package schema
|
|
|
|
import (
|
|
"reflect"
|
|
"sort"
|
|
"testing"
|
|
)
|
|
|
|
func TestListSort_impl(t *testing.T) {
|
|
var _ sort.Interface = new(listSort)
|
|
}
|
|
|
|
func TestListSort(t *testing.T) {
|
|
s := &listSort{
|
|
List: []interface{}{5, 2, 1, 3, 4},
|
|
Schema: &Schema{
|
|
Order: func(a, b interface{}) bool {
|
|
return a.(int) < b.(int)
|
|
},
|
|
},
|
|
}
|
|
|
|
sort.Sort(s)
|
|
|
|
expected := []interface{}{1, 2, 3, 4, 5}
|
|
if !reflect.DeepEqual(s.List, expected) {
|
|
t.Fatalf("bad: %#v", s.List)
|
|
}
|
|
}
|