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

Function Test_majorityElement

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

Source from the content-addressed store, hash-verified

6)
7
8func Test_majorityElement(t *testing.T) {
9 type args struct {
10 nums []int
11 }
12 tests := []struct {
13 name string
14 args args
15 want int
16 }{
17 {
18 name: "majority element",
19 args: args{
20 []int{
21 3, 3,
22 },
23 },
24 want: 3,
25 },
26 {
27 name: "majority element",
28 args: args{
29 []int{
30 3, 2, 3,
31 },
32 },
33 want: 3,
34 },
35 {
36 name: "majority element",
37 args: args{
38 []int{
39 2, 2, 1, 1, 1, 2, 2,
40 },
41 },
42 want: 2,
43 },
44 {
45 name: "majority element",
46 args: args{
47 []int{
48 7, 7, 5, 7, 5, 1, 5, 7, 5, 5, 7, 7, 7, 7, 7, 7,
49 },
50 },
51 want: 7,
52 },
53 }
54 for _, tt := range tests {
55 t.Run(tt.name, func(t *testing.T) {
56 assert.Equal(t, tt.want, majorityElement(tt.args.nums))
57 })
58 }
59}

Callers

nothing calls this directly

Calls 1

majorityElementFunction · 0.70

Tested by

no test coverage detected