Skip to content

Commit f403390

Browse files
committed
Add tests for options with G, GB and GiB suffixes
1 parent f1e77ab commit f403390

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

tests/cli-tests/basic/memlimit.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ rm file.zst
3535
println "+ zstd --memory=1MiB file"
3636
zstd -q --memory=1MiB file && die "Should allow numeric parameter with expected suffix"
3737
rm file.zst
38+
println "+ zstd --memory=1G file"
39+
zstd -q --memory=1G file && die "Should allow numeric parameter with expected suffix"
40+
rm file.zst
41+
println "+ zstd --memory=1GB file"
42+
zstd -q --memory=1GB file && die "Should allow numeric parameter with expected suffix"
43+
rm file.zst
44+
println "+ zstd --memory=1GiB file"
45+
zstd -q --memory=1GiB file && die "Should allow numeric parameter with expected suffix"
46+
rm file.zst
47+
println "+ zstd --memory=3G file"
48+
zstd -q --memory=3G file && die "Should allow numeric parameter with expected suffix"
49+
rm file.zst
50+
println "+ zstd --memory=3GB file"
51+
zstd -q --memory=3GB file && die "Should allow numeric parameter with expected suffix"
52+
rm file.zst
53+
println "+ zstd --memory=3GiB file"
54+
zstd -q --memory=3GiB file && die "Should allow numeric parameter with expected suffix"
55+
rm file.zst
56+
println "+ zstd --memory=4G file"
57+
zstd --memory=4G file && die "Should not allow out-of-bound numeric parameter"
58+
println "+ zstd --memory=4GB file"
59+
zstd --memory=4GB file && die "Should not allow out-of-bound numeric parameter"
60+
println "+ zstd --memory=4GiB file"
61+
zstd --memory=4GiB file && die "Should not allow out-of-bound numeric parameter"
3862

3963
rm file
4064
exit 0
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
2-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
3-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
4-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
5-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
6-
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed
1+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
2+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
3+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
4+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
5+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
6+
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB, G, GB, GiB are allowed
77
Should allow numeric parameter without suffix
88
Should allow numeric parameter with expected suffix
99
Should allow numeric parameter with expected suffix
1010
Should allow numeric parameter with expected suffix
1111
Should allow numeric parameter with expected suffix
1212
Should allow numeric parameter with expected suffix
1313
Should allow numeric parameter with expected suffix
14+
Should allow numeric parameter with expected suffix
15+
Should allow numeric parameter with expected suffix
16+
Should allow numeric parameter with expected suffix
17+
Should allow numeric parameter with expected suffix
18+
Should allow numeric parameter with expected suffix
19+
Should allow numeric parameter with expected suffix
20+
error: numeric value overflows 32-bit unsigned int
21+
error: numeric value overflows 32-bit unsigned int
22+
error: numeric value overflows 32-bit unsigned int

tests/cli-tests/basic/memlimit.sh.stdout.exact

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@
1111
+ zstd --memory=1M file
1212
+ zstd --memory=1MB file
1313
+ zstd --memory=1MiB file
14+
+ zstd --memory=1G file
15+
+ zstd --memory=1GB file
16+
+ zstd --memory=1GiB file
17+
+ zstd --memory=3G file
18+
+ zstd --memory=3GB file
19+
+ zstd --memory=3GiB file
20+
+ zstd --memory=4G file
21+
+ zstd --memory=4GB file
22+
+ zstd --memory=4GiB file

tests/playTests.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,13 +1075,19 @@ cat tmp | zstd -14 -f --size-hint=11050 | zstd -t # slightly too high
10751075
cat tmp | zstd -14 -f --size-hint=10950 | zstd -t # slightly too low
10761076
cat tmp | zstd -14 -f --size-hint=22000 | zstd -t # considerably too high
10771077
cat tmp | zstd -14 -f --size-hint=5500 | zstd -t # considerably too low
1078-
println "test : allows and interprets K,KB,KiB,M,MB and MiB suffix"
1078+
println "test : allows and interprets K,KB,KiB,M,MB,MiB,G,GB and GiB suffix"
10791079
cat tmp | zstd -14 -f --size-hint=11K | zstd -t
10801080
cat tmp | zstd -14 -f --size-hint=11KB | zstd -t
10811081
cat tmp | zstd -14 -f --size-hint=11KiB | zstd -t
10821082
cat tmp | zstd -14 -f --size-hint=1M | zstd -t
10831083
cat tmp | zstd -14 -f --size-hint=1MB | zstd -t
10841084
cat tmp | zstd -14 -f --size-hint=1MiB | zstd -t
1085+
cat tmp | zstd -14 -f --size-hint=1G | zstd -t
1086+
cat tmp | zstd -14 -f --size-hint=1GB | zstd -t
1087+
cat tmp | zstd -14 -f --size-hint=1GiB | zstd -t
1088+
cat tmp | zstd -14 -f --size-hint=3G | zstd -t
1089+
cat tmp | zstd -14 -f --size-hint=3GB | zstd -t
1090+
cat tmp | zstd -14 -f --size-hint=3GiB | zstd -t
10851091

10861092

10871093
println "\n===> dictionary tests "
@@ -1684,6 +1690,8 @@ roundTripTest -g1M -P50 "1 --single-thread --long=29" " --memory=512MB"
16841690
roundTripTest -g1M -P50 "1 --single-thread --long=29 --zstd=wlog=28" " --memory=256MB"
16851691
roundTripTest -g1M -P50 "1 --single-thread --long=29" " --long=28 --memory=512MB"
16861692
roundTripTest -g1M -P50 "1 --single-thread --long=29" " --zstd=wlog=28 --memory=512MB"
1693+
roundTripTest -g1M -P50 "1 --single-thread --long=30" " --memory=1GB"
1694+
roundTripTest -g1M -P50 "1 --single-thread --long=30" " --zstd=wlog=29 --memory=1GB"
16871695

16881696

16891697
if [ "$ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP" -ne "1" ]; then

0 commit comments

Comments
 (0)