...
1 package funk
2
3 import (
4 "sort"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestKeys(t *testing.T) {
11 is := assert.New(t)
12
13 results := Keys(map[string]int{"one": 1, "two": 2}).([]string)
14 sort.Strings(results)
15
16 is.Equal(results, []string{"one", "two"})
17
18 fields := Keys(foo).([]string)
19
20 sort.Strings(fields)
21
22 is.Equal(fields, []string{"Age", "Bar", "BarInterface", "BarPointer", "Bars", "EmptyValue", "FirstName", "GeneralInterface", "ID", "LastName", "ZeroBoolValue", "ZeroIntPtrValue", "ZeroIntValue"})
23 }
24
25 func TestValues(t *testing.T) {
26 is := assert.New(t)
27
28 results := Values(map[string]int{"one": 1, "two": 2}).([]int)
29 sort.Ints(results)
30
31 is.Equal(results, []int{1, 2})
32
33 values := Values(foo).([]interface{})
34
35 is.Len(values, 13)
36 }
37
View as plain text