Skip to content

Adds crc32c codec #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 28, 2024
Prev Previous commit
Next Next commit
codecov
  • Loading branch information
normanrz committed Oct 21, 2024
commit a3579a0a00b66d67f473c4a01cfa7dbcd88049d7
14 changes: 14 additions & 0 deletions numcodecs/tests/test_crc32c.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ def test_checksum():
assert np.frombuffer(buf, dtype="<u4", offset=(len(buf) - 4))[0] == np.uint32(4218238699)


def test_err_checksum():
arr = np.arange(0, 64, dtype="uint8")
buf = bytearray(Crc32c().encode(arr))
buf[-1] = 0 # corrupt the checksum
with pytest.raises(ValueError):
Crc32c().decode(buf)


def test_repr():
check_repr("Crc32c()")

Expand Down Expand Up @@ -73,6 +81,12 @@ def test_err_encode_non_contiguous():
Crc32c().encode(arr)


def test_err_input_too_small():
buf = b'000' # 3 bytes are too little for a CRC32C checksum
with pytest.raises(ValueError):
Crc32c().decode(buf)


def test_err_out_too_small():
arr = np.arange(10, dtype='i4')
out = np.empty_like(arr)[:-1]
Expand Down
Loading