@@ -6,7 +6,7 @@ import Data.Primitive (ByteArray,sizeofByteArray)
6
6
import Data.Word (Word8 )
7
7
import Lz4.Block (compress , compressHighly , decompress )
8
8
import Test.Tasty (TestTree , defaultMain , testGroup )
9
- import Test.Tasty.HUnit (testCase )
9
+ import Test.Tasty.HUnit (testCase , (@=?) )
10
10
import Test.Tasty.QuickCheck (Gen , choose , forAll , testProperty , vectorOf , (===) )
11
11
12
12
import qualified Data.Bytes as Bytes
@@ -39,6 +39,9 @@ tests = testGroup "lz4"
39
39
, testCase " example-a" $ case Frame. decompressU 20 (Bytes. fromByteArray exampleA) of
40
40
Nothing -> fail " decompression failed"
41
41
Just _ -> pure ()
42
+ , testCase " example-b" $ case Frame. decompressU 10 (Bytes. fromByteArray exampleB) of
43
+ Nothing -> fail " decompression failed"
44
+ Just x -> x @=? Exts. fromList [0xbb :: Word8 , 0x01 , 0xbb , 0x01 , 0xbb , 0x01 , 0xbb , 0x01 , 0xbb , 0x01 ]
42
45
]
43
46
]
44
47
@@ -62,3 +65,17 @@ exampleA = Exts.fromList
62
65
, 0x47 , 0x15 , 0x08 , 0x01 , 0x0a , 0x04 , 0x00 , 0x50 , 0x0a , 0x15 , 0x08 , 0x01 , 0x0a
63
66
, 0x00 , 0x00 , 0x00 , 0x00
64
67
]
68
+
69
+ -- Example that tests a frame that does not use compression
70
+ exampleB :: ByteArray
71
+ exampleB = Exts. fromList
72
+ [ 0x04 , 0x22 , 0x4d , (0x18 :: Word8 )
73
+ , 0x60 , 0x40 , 0x82
74
+ , 0x0a , 0x00 , 0x00 , 0x80 -- little-endian encoding of 10 but with the high bit set to disable compression
75
+ , 0xbb , 0x01
76
+ , 0xbb , 0x01
77
+ , 0xbb , 0x01
78
+ , 0xbb , 0x01
79
+ , 0xbb , 0x01
80
+ , 0x00 , 0x00 , 0x00 , 0x00
81
+ ]
0 commit comments