diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2023-02-26 13:03:45 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2023-02-26 13:03:45 +0000 |
| commit | e7407fe22c8164a500aaa12ebcd1084cf53d42e1 (patch) | |
| tree | 49121aa1d9d65f44fba9666a28d9162f848545b9 | |
| parent | b74779ddd5c66419afd0b4a00108d30c7573390e (diff) | |
Simplify TestMapKeys a bit
| -rw-r--r-- | util_test.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/util_test.go b/util_test.go index f8731e5..4ed1dde 100644 --- a/util_test.go +++ b/util_test.go @@ -5,7 +5,6 @@ package core_test import ( "errors" - "sort" "testing" "github.com/google/go-cmp/cmp" @@ -15,13 +14,11 @@ import ( ) func TestMapKeys(s *testing.T) { - t := core.T{T: s} + t := core.T{T: s, Options: cmp.Options{sortStrings}} t.AssertEqual(([]string)(nil), core.MapKeys[map[string]int](nil)) t.AssertEqual(([]string)(nil), core.MapKeys(map[string]int{})) - keys := core.MapKeys(map[string]int{"foo": 1, "bar": 2}) - sort.Strings(keys) - t.AssertEqual([]string{"bar", "foo"}, keys) + t.AssertEqual([]string{"bar", "foo"}, core.MapKeys(map[string]int{"foo": 1, "bar": 2})) } func TestMust(s *testing.T) { @@ -40,3 +37,5 @@ func TestSliceMap(s *testing.T) { t.AssertEqual(([]int)(nil), core.SliceMap(func(int) int { return 0 }, []int{})) t.AssertEqual([]int{42, 84}, core.SliceMap(func(x int) int { return x * 2 }, []int{21, 42})) } + +var sortStrings = cmpopts.SortSlices(func(s, t string) bool { return s <= t }) |
