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

Function Test_hammingWeight

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

Source from the content-addressed store, hash-verified

6)
7
8func Test_hammingWeight(t *testing.T) {
9 type args struct {
10 num uint32
11 }
12 tests := []struct {
13 name string
14 args args
15 want int
16 }{
17 {
18 name: "hamming weight",
19 args: args{
20 num: 11,
21 },
22 want: 3,
23 },
24 {
25 name: "hamming weight",
26 args: args{
27 num: 128,
28 },
29 want: 1,
30 },
31 {
32 name: "hamming weight",
33 args: args{
34 num: 4294967293,
35 },
36 want: 31,
37 },
38 }
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 assert.Equal(t, tt.want, hammingWeight(tt.args.num))
42 })
43 }
44}

Callers

nothing calls this directly

Calls 1

hammingWeightFunction · 0.85

Tested by

no test coverage detected