diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-11 14:15:03 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-11 14:15:03 +0000 |
| commit | ac4ea73cdbf6a25c169dbdce5e46defd56553600 (patch) | |
| tree | a591280ac6ed52a5491064710aa462618aee4d8f /util_test.go | |
| parent | 502fef431dc8999243935a2b345e658f86387e49 (diff) | |
Add MapKeys
Diffstat (limited to 'util_test.go')
| -rw-r--r-- | util_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/util_test.go b/util_test.go index a9b297e..f8731e5 100644 --- a/util_test.go +++ b/util_test.go @@ -5,6 +5,7 @@ package core_test import ( "errors" + "sort" "testing" "github.com/google/go-cmp/cmp" @@ -13,6 +14,16 @@ import ( "go.awhk.org/core" ) +func TestMapKeys(s *testing.T) { + t := core.T{T: s} + + 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) +} + func TestMust(s *testing.T) { t := core.T{T: s, Options: []cmp.Option{cmpopts.EquateErrors()}} |
