]> gitweb.factorcode.org Git - factor.git/blob - extra/compression/bzip3/bzip3-tests.factor
bzip3: add unit tests, fix unit test problems
[factor.git] / extra / compression / bzip3 / bzip3-tests.factor
1 ! Copyright (C) 2022 Raghu Ranganathan.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: tools.test byte-arrays random locals sequences ;
4 IN: compression.bzip3.tests
5
6 ! Simple compression and decompression
7 { B{
8     0 0 0 0 0 0 0 12 66 90 51 118 49 0 4 1 0 1 0 0 0 20 0 0 0 12
9     0 0 0 177 144 125 228 255 255 255 255 72 101 108 108 111 32
10     87 111 114 108 100 33 0 0 0
11 } } [ B{ 72 101 108 108 111 32 87 111 114 108 100 33 } f compress ] unit-test
12 { B{
13   72 101 108 108 111 32 87 111 114 108 100 33 
14 } } [ B{
15   0 0 0 0 0 0 0 12 66 90 51 118 49 0 4 1 0 1 0 0 0 20 0 0 0 12 0 0 0 177 144
16   125 228 255 255 255 255 72 101 108 108 111 32 87 111 114 108
17   100 33 0 0 0
18 } decompress ] unit-test
19
20 ! Random byte sequences
21 40 [| |
22   36 [ 256 random ] B{ } replicate-as :> input
23   { input } [ input f compress decompress ] unit-test
24 ] times
25
26 ! Incorrect block sizes must error
27 [ B{ } 0 compress ] must-fail
28 [ B{ } 536870912 compress ] must-fail