def test_parse_header(self, nr_segments, offsets):
        """Test parsing header data."""
        # Encode the header
        header = bytearray()
        header.extend(pack('<L', nr_segments))
        header.extend(pack('<{}L'.format(len(offsets)), *offsets))
        # Add padding
        header.extend(b'\x00' * (64 - len(header)))

        assert len(header) == 64
        assert offsets == _parse_rle_header(header)
 def test_invalid_nr_segments_raises(self):
     """Test that more than 15 segments raises exception."""
     with pytest.raises(ValueError, match="invalid number of segments"):
         _parse_rle_header(b'\x10' + b'\x00' * 63)
 def test_invalid_header_length(self):
     """Test exception raised if header is not 64 bytes long."""
     for length in [0, 1, 63, 65]:
         with pytest.raises(ValueError,
                            match='RLE header can only be 64 bytes long'):
             _parse_rle_header(b'\x00' * length)