flatmap: deterministic tests
This commit is contained in:
parent
4a3d51f40e
commit
485bc668bf
|
@ -2,6 +2,7 @@ package flatmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,14 +37,18 @@ func TestMapKeys(t *testing.T) {
|
||||||
"bar.0.baz": "bar",
|
"bar.0.baz": "bar",
|
||||||
},
|
},
|
||||||
Output: []string{
|
Output: []string{
|
||||||
"foo",
|
|
||||||
"bar",
|
"bar",
|
||||||
|
"foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
actual := Map(tc.Input).Keys()
|
actual := Map(tc.Input).Keys()
|
||||||
|
|
||||||
|
// Sort so we have a consistent view of the output
|
||||||
|
sort.Strings(actual)
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, tc.Output) {
|
if !reflect.DeepEqual(actual, tc.Output) {
|
||||||
t.Fatalf("input: %#v\n\nbad: %#v", tc.Input, actual)
|
t.Fatalf("input: %#v\n\nbad: %#v", tc.Input, actual)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue