20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
-
+
-
-
+
+
+
+
+
|
}
}
func TestCoding(t *testing.T) {
n := New(32)
for i := uint64(0); i < 4096; i++ {
enc, _ := n.Code(i)
enc, encLen := n.Code(i)
//fmt.Printf("%d - %b, %d\n", i, enc, len)
dec, _ := n.Decode(enc)
dec, decLen := n.Decode(enc)
if i != dec {
t.Errorf("Unexpected value for %d - enc is %b, dec is %d\n", i, enc, dec)
}
if encLen != decLen {
t.Errorf("Unexpected difference between encoded and decoded lengths.", encLen, decLen)
}
}
}
func TestWriter(t *testing.T) {
var buf bytes.Buffer
var w io.Writer = Writer(&buf)
var input []byte = make([]byte, 256)
|