From ba7e8f1051913982d809f4904f829d512702225d Mon Sep 17 00:00:00 2001 From: 15596858998 Date: Sun, 5 Dec 2021 19:12:52 +0800 Subject: [PATCH] add test case --- tests/playTests.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/playTests.sh b/tests/playTests.sh index 4face06dd..f3c45fa24 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -184,10 +184,16 @@ fi println "\n===> simple tests " - +datagen datagen > tmp +zstd -h +zstd -H +zstd -V println "test : basic compression " zstd -f tmp # trivial compression case, creates tmp.zst +zstd -f -z tmp +zstd -f -k tmp +zstd -f -C tmp println "test : basic decompression" zstd -df tmp.zst # trivial decompression case (overwrites tmp) println "test : too large compression level => auto-fix" @@ -747,6 +753,7 @@ rm -rf tmp* println "test : show-default-cparams regular" datagen > tmp zstd --show-default-cparams -f tmp +zstd --show-default-cparams -d tmp.zst && die "error: can't use --show-default-cparams in decompression mode" rm -rf tmp* println "test : show-default-cparams recursive" @@ -785,6 +792,7 @@ println "world!" > world.tmp cat hello.tmp world.tmp > helloworld.tmp zstd -c hello.tmp > hello.zst zstd -c world.tmp > world.zst +zstd -c hello.tmp world.tmp > helloworld.zst cat hello.zst world.zst > helloworld.zst zstd -dc helloworld.zst > result.tmp cat result.tmp @@ -937,6 +945,13 @@ cat tmp | zstd -14 -f --size-hint=11050 | zstd -t # slightly too high cat tmp | zstd -14 -f --size-hint=10950 | zstd -t # slightly too low cat tmp | zstd -14 -f --size-hint=22000 | zstd -t # considerably too high cat tmp | zstd -14 -f --size-hint=5500 | zstd -t # considerably too low +println "test : allows and interprets K,KB,KiB,M,MB and MiB suffix" +cat tmp | zstd -14 -f --size-hint=11K | zstd -t +cat tmp | zstd -14 -f --size-hint=11KB | zstd -t +cat tmp | zstd -14 -f --size-hint=11KiB | zstd -t +cat tmp | zstd -14 -f --size-hint=1M | zstd -t +cat tmp | zstd -14 -f --size-hint=1MB | zstd -t +cat tmp | zstd -14 -f --size-hint=1MiB | zstd -t println "\n===> dictionary tests " @@ -1047,6 +1062,7 @@ println "- Create dictionaries with shrink-dict flag enabled" zstd --train-fastcover=steps=1,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict zstd --train-fastcover=steps=1,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict1 zstd --train-fastcover=steps=1,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict2 +zstd --train-fastcover=shrink=5,steps=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict3 println "- Create dictionary with size limit" zstd --train-fastcover=steps=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K println "- Create dictionary using all samples for both training and testing" @@ -1549,6 +1565,7 @@ if [ -n "$hasMT" ] then println "\n===> adaptive mode " roundTripTest -g270000000 " --adapt" + roundTripTest -g270000000 " --adapt=" && die "invalid compression parameter" roundTripTest -g27000000 " --adapt=min=1,max=4" roundTripTest -g27000000 " --adapt=min=-2,max=-1" println "===> test: --adapt must fail on incoherent bounds " @@ -1671,6 +1688,7 @@ println "- Create first dictionary" zstd --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict cp "$TESTFILE" tmp zstd -f tmp -D tmpDict +zstd -f tmp -D tmpDict --patch-from=tmpDict && die "error: can't use -D and --patch-from=#at the same time" zstd -d tmp.zst -D tmpDict -fo result $DIFF "$TESTFILE" result zstd --train-cover=k=56,d=8 && die "Create dictionary without input file (should error)" @@ -1681,6 +1699,7 @@ println "- Create dictionary using shrink-dict flag" zstd --train-cover=steps=256,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict zstd --train-cover=steps=256,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict1 zstd --train-cover=steps=256,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict2 +zstd --train-cover=shrink=5,steps=256 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict3 println "- Create dictionary with short dictID" zstd --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1 cmp tmpDict tmpDict1 && die "dictionaries should have different ID !" -- 2.47.2