Mercurial > hg
annotate contrib/python-zstandard/tests/test_data_structures.py @ 51699:bd1483fd7088
Latest image and pytype fix
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 22 Jul 2024 16:49:38 +0200 |
parents | 5e84a96d865b |
children |
rev | line source |
---|---|
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
1 import sys |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
2 import unittest |
30435
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
4 import zstandard as zstd |
30435
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
6 from .common import ( |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
7 make_cffi, |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
8 TestCase, |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
9 ) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
10 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
11 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
12 @make_cffi |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
13 class TestCompressionParameters(TestCase): |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
14 def test_bounds(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
15 zstd.ZstdCompressionParameters( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
16 window_log=zstd.WINDOWLOG_MIN, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
17 chain_log=zstd.CHAINLOG_MIN, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
18 hash_log=zstd.HASHLOG_MIN, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
19 search_log=zstd.SEARCHLOG_MIN, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
20 min_match=zstd.MINMATCH_MIN + 1, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
21 target_length=zstd.TARGETLENGTH_MIN, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
22 strategy=zstd.STRATEGY_FAST, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
23 ) |
30435
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
25 zstd.ZstdCompressionParameters( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
26 window_log=zstd.WINDOWLOG_MAX, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
27 chain_log=zstd.CHAINLOG_MAX, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
28 hash_log=zstd.HASHLOG_MAX, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
29 search_log=zstd.SEARCHLOG_MAX, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
30 min_match=zstd.MINMATCH_MAX - 1, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
31 target_length=zstd.TARGETLENGTH_MAX, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
32 strategy=zstd.STRATEGY_BTULTRA2, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
33 ) |
30435
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
35 def test_from_level(self): |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
36 p = zstd.ZstdCompressionParameters.from_level(1) |
30435
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 self.assertIsInstance(p, zstd.CompressionParameters) |
b86a448a2965
zstd: vendor python-zstandard 0.5.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
39 self.assertEqual(p.window_log, 19) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
40 |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
41 p = zstd.ZstdCompressionParameters.from_level(-4) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
42 self.assertEqual(p.window_log, 19) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
43 |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
44 def test_members(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
45 p = zstd.ZstdCompressionParameters( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
46 window_log=10, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
47 chain_log=6, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
48 hash_log=7, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
49 search_log=4, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
50 min_match=5, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
51 target_length=8, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
52 strategy=1, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
53 ) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
54 self.assertEqual(p.window_log, 10) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
55 self.assertEqual(p.chain_log, 6) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
56 self.assertEqual(p.hash_log, 7) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
57 self.assertEqual(p.search_log, 4) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
58 self.assertEqual(p.min_match, 5) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
59 self.assertEqual(p.target_length, 8) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
60 self.assertEqual(p.compression_strategy, 1) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
61 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
62 p = zstd.ZstdCompressionParameters(compression_level=2) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
63 self.assertEqual(p.compression_level, 2) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
64 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
65 p = zstd.ZstdCompressionParameters(threads=4) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
66 self.assertEqual(p.threads, 4) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
67 |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
68 p = zstd.ZstdCompressionParameters( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
69 threads=2, job_size=1048576, overlap_log=6 |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
70 ) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
71 self.assertEqual(p.threads, 2) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
72 self.assertEqual(p.job_size, 1048576) |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
73 self.assertEqual(p.overlap_log, 6) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
74 self.assertEqual(p.overlap_size_log, 6) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
75 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
76 p = zstd.ZstdCompressionParameters(compression_level=-1) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
77 self.assertEqual(p.compression_level, -1) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
78 |
40121
73fef626dae3
zstandard: vendor python-zstandard 0.10.1
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37495
diff
changeset
|
79 p = zstd.ZstdCompressionParameters(compression_level=-2) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
80 self.assertEqual(p.compression_level, -2) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
81 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
82 p = zstd.ZstdCompressionParameters(force_max_window=True) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
83 self.assertEqual(p.force_max_window, 1) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
84 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
85 p = zstd.ZstdCompressionParameters(enable_ldm=True) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
86 self.assertEqual(p.enable_ldm, 1) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
87 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
88 p = zstd.ZstdCompressionParameters(ldm_hash_log=7) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
89 self.assertEqual(p.ldm_hash_log, 7) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
90 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
91 p = zstd.ZstdCompressionParameters(ldm_min_match=6) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
92 self.assertEqual(p.ldm_min_match, 6) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
93 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
94 p = zstd.ZstdCompressionParameters(ldm_bucket_size_log=7) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
95 self.assertEqual(p.ldm_bucket_size_log, 7) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
96 |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
97 p = zstd.ZstdCompressionParameters(ldm_hash_rate_log=8) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
98 self.assertEqual(p.ldm_hash_every_log, 8) |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
99 self.assertEqual(p.ldm_hash_rate_log, 8) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
100 |
31796
e0dc40530c5a
zstd: vendor python-zstandard 0.8.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30895
diff
changeset
|
101 def test_estimated_compression_context_size(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
102 p = zstd.ZstdCompressionParameters( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
103 window_log=20, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
104 chain_log=16, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
105 hash_log=17, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
106 search_log=1, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
107 min_match=5, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
108 target_length=16, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
109 strategy=zstd.STRATEGY_DFAST, |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
110 ) |
31796
e0dc40530c5a
zstd: vendor python-zstandard 0.8.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30895
diff
changeset
|
111 |
e0dc40530c5a
zstd: vendor python-zstandard 0.8.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30895
diff
changeset
|
112 # 32-bit has slightly different values from 64-bit. |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
113 self.assertAlmostEqual( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
114 p.estimated_compression_context_size(), 1294464, delta=400 |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
115 ) |
31796
e0dc40530c5a
zstd: vendor python-zstandard 0.8.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30895
diff
changeset
|
116 |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
117 def test_strategy(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
118 with self.assertRaisesRegex( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
119 ValueError, "cannot specify both compression_strategy" |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
120 ): |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
121 zstd.ZstdCompressionParameters(strategy=0, compression_strategy=0) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
122 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
123 p = zstd.ZstdCompressionParameters(strategy=2) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
124 self.assertEqual(p.compression_strategy, 2) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
125 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
126 p = zstd.ZstdCompressionParameters(strategy=3) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
127 self.assertEqual(p.compression_strategy, 3) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
128 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
129 def test_ldm_hash_rate_log(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
130 with self.assertRaisesRegex( |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
131 ValueError, "cannot specify both ldm_hash_rate_log" |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
132 ): |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
133 zstd.ZstdCompressionParameters( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
134 ldm_hash_rate_log=8, ldm_hash_every_log=4 |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
135 ) |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
136 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
137 p = zstd.ZstdCompressionParameters(ldm_hash_rate_log=8) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
138 self.assertEqual(p.ldm_hash_every_log, 8) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
139 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
140 p = zstd.ZstdCompressionParameters(ldm_hash_every_log=16) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
141 self.assertEqual(p.ldm_hash_every_log, 16) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
142 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
143 def test_overlap_log(self): |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
144 with self.assertRaisesRegex( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
145 ValueError, "cannot specify both overlap_log" |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
146 ): |
42070
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
147 zstd.ZstdCompressionParameters(overlap_log=1, overlap_size_log=9) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
148 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
149 p = zstd.ZstdCompressionParameters(overlap_log=2) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
150 self.assertEqual(p.overlap_log, 2) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
151 self.assertEqual(p.overlap_size_log, 2) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
152 |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
153 p = zstd.ZstdCompressionParameters(overlap_size_log=4) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
154 self.assertEqual(p.overlap_log, 4) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
155 self.assertEqual(p.overlap_size_log, 4) |
675775c33ab6
zstandard: vendor python-zstandard 0.11
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40121
diff
changeset
|
156 |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
157 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
158 @make_cffi |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
159 class TestFrameParameters(TestCase): |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
160 def test_invalid_type(self): |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
161 with self.assertRaises(TypeError): |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
162 zstd.get_frame_parameters(None) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
163 |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
164 # Python 3 doesn't appear to convert unicode to Py_buffer. |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
165 if sys.version_info[0] >= 3: |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
166 with self.assertRaises(TypeError): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
167 zstd.get_frame_parameters(u"foobarbaz") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
168 else: |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
169 # CPython will convert unicode to Py_buffer. But CFFI won't. |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
170 if zstd.backend == "cffi": |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
171 with self.assertRaises(TypeError): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
172 zstd.get_frame_parameters(u"foobarbaz") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
173 else: |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
174 with self.assertRaises(zstd.ZstdError): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
175 zstd.get_frame_parameters(u"foobarbaz") |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
176 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
177 def test_invalid_input_sizes(self): |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
178 with self.assertRaisesRegex( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
179 zstd.ZstdError, "not enough data for frame" |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
180 ): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
181 zstd.get_frame_parameters(b"") |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
182 |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
183 with self.assertRaisesRegex( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
184 zstd.ZstdError, "not enough data for frame" |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
185 ): |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
186 zstd.get_frame_parameters(zstd.FRAME_HEADER) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
187 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
188 def test_invalid_frame(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
189 with self.assertRaisesRegex(zstd.ZstdError, "Unknown frame descriptor"): |
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
190 zstd.get_frame_parameters(b"foobarbaz") |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
191 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
192 def test_attributes(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
193 params = zstd.get_frame_parameters(zstd.FRAME_HEADER + b"\x00\x00") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
194 self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
195 self.assertEqual(params.window_size, 1024) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
196 self.assertEqual(params.dict_id, 0) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
197 self.assertFalse(params.has_checksum) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
198 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
199 # Lowest 2 bits indicate a dictionary and length. Here, the dict id is 1 byte. |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
200 params = zstd.get_frame_parameters(zstd.FRAME_HEADER + b"\x01\x00\xff") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
201 self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
202 self.assertEqual(params.window_size, 1024) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
203 self.assertEqual(params.dict_id, 255) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
204 self.assertFalse(params.has_checksum) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
205 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
206 # Lowest 3rd bit indicates if checksum is present. |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
207 params = zstd.get_frame_parameters(zstd.FRAME_HEADER + b"\x04\x00") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
208 self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
209 self.assertEqual(params.window_size, 1024) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
210 self.assertEqual(params.dict_id, 0) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
211 self.assertTrue(params.has_checksum) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
212 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
213 # Upper 2 bits indicate content size. |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
214 params = zstd.get_frame_parameters( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
215 zstd.FRAME_HEADER + b"\x40\x00\xff\x00" |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
216 ) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
217 self.assertEqual(params.content_size, 511) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
218 self.assertEqual(params.window_size, 1024) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
219 self.assertEqual(params.dict_id, 0) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
220 self.assertFalse(params.has_checksum) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
221 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
222 # Window descriptor is 2nd byte after frame header. |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
223 params = zstd.get_frame_parameters(zstd.FRAME_HEADER + b"\x00\x40") |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
224 self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
225 self.assertEqual(params.window_size, 262144) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
226 self.assertEqual(params.dict_id, 0) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
227 self.assertFalse(params.has_checksum) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
228 |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
229 # Set multiple things. |
44147
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
230 params = zstd.get_frame_parameters( |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
231 zstd.FRAME_HEADER + b"\x45\x40\x0f\x10\x00" |
5e84a96d865b
python-zstandard: blacken at 80 characters
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43994
diff
changeset
|
232 ) |
30895
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
233 self.assertEqual(params.content_size, 272) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
234 self.assertEqual(params.window_size, 262144) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
235 self.assertEqual(params.dict_id, 15) |
c32454d69b85
zstd: vendor python-zstandard 0.7.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
236 self.assertTrue(params.has_checksum) |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
237 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
238 def test_input_types(self): |
43994
de7838053207
zstandard: vendor python-zstandard 0.13.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42937
diff
changeset
|
239 v = zstd.FRAME_HEADER + b"\x00\x00" |
37495
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
240 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
241 mutable_array = bytearray(len(v)) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
242 mutable_array[:] = v |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
243 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
244 sources = [ |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
245 memoryview(v), |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
246 bytearray(v), |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
247 mutable_array, |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
248 ] |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
249 |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
250 for source in sources: |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
251 params = zstd.get_frame_parameters(source) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
252 self.assertEqual(params.content_size, zstd.CONTENTSIZE_UNKNOWN) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
253 self.assertEqual(params.window_size, 1024) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
254 self.assertEqual(params.dict_id, 0) |
b1fb341d8a61
zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31796
diff
changeset
|
255 self.assertFalse(params.has_checksum) |