forked from dgryski/go-tsz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bstream_test.go
72 lines (63 loc) · 1.26 KB
/
bstream_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package tsz
import (
"io"
"testing"
)
func TestNewBWriter(t *testing.T) {
b := newBWriter(1)
if b.count != 0 {
t.Errorf("Unexpected value: %v\n", b.count)
}
}
func TestReadBitEOF1(t *testing.T) {
b := newBWriter(1)
_, err := b.readBit()
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestReadBitEOF2(t *testing.T) {
b := newBReader([]byte{1})
b.count = 0
_, err := b.readBit()
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestReadByteEOF1(t *testing.T) {
b := newBWriter(1)
_, err := b.readByte()
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestReadByteEOF2(t *testing.T) {
b := newBReader([]byte{1})
b.count = 0
_, err := b.readByte()
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestReadByteEOF3(t *testing.T) {
b := newBReader([]byte{1})
b.count = 16
_, err := b.readByte()
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestReadBitsEOF(t *testing.T) {
b := newBReader([]byte{1})
_, err := b.readBits(9)
if err != io.EOF {
t.Errorf("Unexpected value: %v\n", err)
}
}
func TestUnmarshalBinaryErr(t *testing.T) {
b := &bstream{}
err := b.UnmarshalBinary([]byte{})
if err == nil {
t.Errorf("An error was expected\n")
}
}