-
Notifications
You must be signed in to change notification settings - Fork 1
/
keys_test.go
51 lines (46 loc) · 1.01 KB
/
keys_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package goulash
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestKeysMapString(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
input map[string]string
expect []string
}{
{
name: "Empty map",
input: map[string]string{},
expect: []string{},
},
{
name: "Map with 1 element",
input: map[string]string{"key": "value"},
expect: []string{"key"},
},
{
name: "Map with distinct keys/values",
input: map[string]string{
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
},
expect: []string{"key1", "key2", "key3", "key4"},
},
{
name: "Map with identical values",
input: map[string]string{"key1": "value", "key2": "value", "key3": "value"},
expect: []string{"key1", "key2", "key3"},
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
assert.ElementsMatch(t, testCase.expect, Keys(testCase.input))
})
}
}