Cosmo/BinaryKit

Mixed reading error

aserdobintsev opened this issue · 0 comments

I'm getting wrong data while reading with using readBit() and readByte() methods, though readBitCursor increments correctly.

Test case:

  1. The data is 0b1010_1101_1010_1111.
  2. Do try bin.readBit() result 1
  3. Do try bin.readByte()
    Actual result: 173
    Expected result: 91

The expected behaviour is that Binary reads sequentially:

//                                     readBitCursor              // 9
//                                          | 
var binary = Binary(bytes: [0b1_1011100, 0b1_0101111])
//                            | |___________| 
//                            |       | 
//                            | try binary.readBit()              // 91
//                            try binary.readBit()                // 1