MCPcopy Create free account
hub / github.com/egonelbre/exp / TestWriteReadRandomBit

Function TestWriteReadRandomBit

bit/bit_test.go:9–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestWriteReadRandomBit(t *testing.T) {
10 var buf bytes.Buffer
11 w := NewWriter(&buf)
12
13 values := make([]int, 1251)
14 for i := range values {
15 values[i] = rand.Intn(1)
16 w.WriteBit(values[i])
17 }
18 w.Close()
19
20 r := NewReader(&buf)
21 for i, exp := range values {
22 got, err := r.ReadBit(), r.Error()
23 if err != nil {
24 t.Errorf("r.ReadBits: %v", err)
25 return
26 }
27 if got != exp {
28 t.Errorf("%v: %d got %v expected %v", values, i, got, exp)
29 return
30 }
31 }
32}
33
34func TestWriteReadBits(t *testing.T) {
35 testReadWrite(t, []pair{

Callers

nothing calls this directly

Calls 6

WriteBitMethod · 0.95
CloseMethod · 0.95
ReadBitMethod · 0.95
ErrorMethod · 0.95
NewWriterFunction · 0.70
NewReaderFunction · 0.70

Tested by

no test coverage detected