// TestReadBit tests that a single bit can be read.
TestReadBit tests that a single bit can be read.
// TestReadBit tests that a single bit can be read .
func TestReadBit(t *testing.T) {
	buff := bytes.NewBuffer([]byte{0xF0, 0xA5, 0x08})
	tests := []struct {
		want Bit
	}{
		{1}, {1}, {1}, {1}, 
		{0}, {0}, {0}, {0}, 
		{1}, {0}, {1}, {0}, 
		{0}, {1}, {0}, {1}, 
		{0}, {0}, {0}, {0}, 
		{1}, {0}, {0}, {0}, 
	}
	r := NewReader(buff, 2)
	for i, tt := range tests {
		t.Logf(`bit %d (index %d)`, i, r.index)
		bit, err := r.ReadBit()
		if bit != tt.want {
			t.Errorf(`bit = %d, want %d`, bit, tt.want)
		}
		if err != nil {
			t.Fatalf(`err = %v, want nil`, err)
		}
	}
	if _, err := r.ReadBit(); err != io.EOF {
		t.Fatalf(`err = %v, want io.EOF`, err)
	}
}
func TestReadBit ( t * testing . T ) { buff := bytes . NewBuffer ( [ ] byte { 0xF0 , 0xA5 , 0x08 } ) tests := [ ] struct { want Bit } { { 1 } , { 1 } , { 1 } , { 1 } , { 0 } , { 0 } , { 0 } , { 0 } , { 1 } , { 0 } , { 1 } , { 0 } , { 0 } , { 1 } , { 0 } , { 1 } , { 0 } , { 0 } , { 0 } , { 0 } , { 1 } , { 0 } , { 0 } , { 0 } , } r := NewReader ( buff , 2 ) for i , tt := range tests { t . Logf ( `bit %d (index %d)` , i , r . index ) bit , err := r . ReadBit ( ) if bit != tt . want { t . Errorf ( `bit = %d, want %d` , bit , tt . want ) } if err != nil { t . Fatalf ( `err = %v, want nil` , err ) } } if _ , err := r . ReadBit ( ) ; err != io . EOF { t . Fatalf ( `err = %v, want io.EOF` , err ) } }
TestReadBit tests that a single bit can be read.
TestReadBit tests that a single bit can be read .
// F // 0 // A // 5 // 0 // 8