(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestBitArraySerialization(t *testing.T) { |
| 50 | numItems := uint64(1280) |
| 51 | input := newBitArray(numItems) |
| 52 | |
| 53 | for i := uint64(0); i < numItems; i++ { |
| 54 | if i%3 == 0 { |
| 55 | input.SetBit(i) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | outBytes, err := input.Serialize() |
| 60 | assert.Equal(t, err, nil) |
| 61 | |
| 62 | // 1280 bits = 20 blocks = 160 bytes, plus lowest and highest at |
| 63 | // 128 bits = 16 bytes plus 1 byte for the anyset param and the identifer |
| 64 | assert.Equal(t, len(outBytes), 178) |
| 65 | |
| 66 | expected := []byte{66, 0, 0, 0, 0, 0, 0, 0, 0, 254} |
| 67 | assert.Equal(t, expected, outBytes[:10]) |
| 68 | |
| 69 | output := newBitArray(0) |
| 70 | err = output.Deserialize(outBytes) |
| 71 | assert.Equal(t, err, nil) |
| 72 | assert.True(t, input.Equals(output)) |
| 73 | } |
| 74 | |
| 75 | func TestBitArrayMarshalUnmarshal(t *testing.T) { |
| 76 | numItems := uint64(1280) |
nothing calls this directly
no test coverage detected
searching dependent graphs…