1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package bits
import (
"strconv"
"testing"
)
func TestHamming(t *testing.T) {
for i := 0; i < 256; i++ {
b, result := i, byte(0)
for b > 0 {
if (b & 1) > 0 {
result++
}
b = b >> 1
}
if result != Hamming(byte(i)) {
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package bits
import (
"strconv"
"testing"
)
func TestHamming(t *testing.T) {
for i := 0; i < 256; i++ {
b, result := i, 0
for b > 0 {
if (b & 1) > 0 {
result++
}
b = b >> 1
}
if result != Hamming(byte(i)) {
|