(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func 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 | } |
nothing calls this directly
no test coverage detected