@@ -17,10 +17,29 @@ if result != Hamming(byte(i)) { t.Error("Invalid hamming weight reported for ", i) } } } + +func TestReverse(t *testing.T) { + for i := 0; i < 256; i++ { + input, result := i, byte(0) + for j := 0; j < 7; j++ { + if (input & 1) > 0 { + result |= 1 + } + result <<= 1 + input >>= 1 + } + if (input & 1) > 0 { + result |= 1 + } + if result != Reverse(byte(i)) { + t.Error("Invalid reverse byte reported for ", i) + } + } +} var sizes []uint = []uint{0, 31, 32, 33, 61, 63, 64, 127, 128, 129} func TestBitSize(t *testing.T) { for _, size := range sizes {