MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / Test_topKFrequent

Function Test_topKFrequent

top_k_frequent_elements_347/solution_test.go:8–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func Test_topKFrequent(t *testing.T) {
9 type args struct {
10 nums []int
11 k int
12 }
13 tests := []struct {
14 name string
15 args args
16 want []int
17 }{
18 {
19 name: "top k frequent elements",
20 args: args{
21 nums: []int{
22 1, 1, 1, 2, 2, 3,
23 },
24 k: 2,
25 },
26 want: []int{
27 1, 2,
28 },
29 },
30 {
31 name: "top k frequent elements",
32 args: args{
33 nums: []int{
34 1,
35 },
36 k: 1,
37 },
38 want: []int{
39 1,
40 },
41 },
42 }
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 assert.Equal(t, tt.want, topKFrequent(tt.args.nums, tt.args.k))
46 })
47 }
48}

Callers

nothing calls this directly

Calls 1

topKFrequentFunction · 0.85

Tested by

no test coverage detected