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