File: map_test.go

package info (click to toggle)
golang-github-thoas-go-funk 0.9.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 504 kB
  • sloc: makefile: 10
file content (36 lines) | stat: -rw-r--r-- 757 bytes parent folder | download
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
package funk

import (
	"sort"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestKeys(t *testing.T) {
	is := assert.New(t)

	results := Keys(map[string]int{"one": 1, "two": 2}).([]string)
	sort.Strings(results)

	is.Equal(results, []string{"one", "two"})

	fields := Keys(foo).([]string)

	sort.Strings(fields)

	is.Equal(fields, []string{"Age", "Bar", "BarInterface", "BarPointer", "Bars", "EmptyValue", "FirstName", "GeneralInterface", "ID", "LastName", "ZeroBoolValue", "ZeroIntPtrValue", "ZeroIntValue"})
}

func TestValues(t *testing.T) {
	is := assert.New(t)

	results := Values(map[string]int{"one": 1, "two": 2}).([]int)
	sort.Ints(results)

	is.Equal(results, []int{1, 2})

	values := Values(foo).([]interface{})

	is.Len(values, 13)
}