File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ def test_checksum():
4040 assert np .frombuffer (buf , dtype = "<u4" , offset = (len (buf ) - 4 ))[0 ] == np .uint32 (4218238699 )
4141
4242
43+ def test_err_checksum ():
44+ arr = np .arange (0 , 64 , dtype = "uint8" )
45+ buf = bytearray (Crc32c ().encode (arr ))
46+ buf [- 1 ] = 0 # corrupt the checksum
47+ with pytest .raises (ValueError ):
48+ Crc32c ().decode (buf )
49+
50+
4351def test_repr ():
4452 check_repr ("Crc32c()" )
4553
@@ -73,6 +81,12 @@ def test_err_encode_non_contiguous():
7381 Crc32c ().encode (arr )
7482
7583
84+ def test_err_input_too_small ():
85+ buf = b'000' # 3 bytes are too little for a CRC32C checksum
86+ with pytest .raises (ValueError ):
87+ Crc32c ().decode (buf )
88+
89+
7690def test_err_out_too_small ():
7791 arr = np .arange (10 , dtype = 'i4' )
7892 out = np .empty_like (arr )[:- 1 ]
You can’t perform that action at this time.
0 commit comments