Mercurial > public > mercurial-scm > hg
comparison contrib/python-zstandard/tests/test_data_structures.py @ 42070:675775c33ab6
zstandard: vendor python-zstandard 0.11
The upstream source distribution from PyPI was extracted. Unwanted
files were removed.
The clang-format ignore list was updated to reflect the new source
of files.
The project contains a vendored copy of zstandard 1.3.8. The old
version was 1.3.6. This should result in some minor performance wins.
test-check-py3-compat.t was updated to reflect now-passing tests on
Python 3.8.
Some HTTP tests were updated to reflect new zstd compression output.
# no-check-commit because 3rd party code has different style guidelines
Differential Revision: https://phab.mercurial-scm.org/D6199
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 04 Apr 2019 17:34:43 -0700 |
parents | 73fef626dae3 |
children | 69de49c4e39c |
comparison
equal
deleted
inserted
replaced
42069:668eff08387f | 42070:675775c33ab6 |
---|---|
13 def test_bounds(self): | 13 def test_bounds(self): |
14 zstd.ZstdCompressionParameters(window_log=zstd.WINDOWLOG_MIN, | 14 zstd.ZstdCompressionParameters(window_log=zstd.WINDOWLOG_MIN, |
15 chain_log=zstd.CHAINLOG_MIN, | 15 chain_log=zstd.CHAINLOG_MIN, |
16 hash_log=zstd.HASHLOG_MIN, | 16 hash_log=zstd.HASHLOG_MIN, |
17 search_log=zstd.SEARCHLOG_MIN, | 17 search_log=zstd.SEARCHLOG_MIN, |
18 min_match=zstd.SEARCHLENGTH_MIN + 1, | 18 min_match=zstd.MINMATCH_MIN + 1, |
19 target_length=zstd.TARGETLENGTH_MIN, | 19 target_length=zstd.TARGETLENGTH_MIN, |
20 compression_strategy=zstd.STRATEGY_FAST) | 20 strategy=zstd.STRATEGY_FAST) |
21 | 21 |
22 zstd.ZstdCompressionParameters(window_log=zstd.WINDOWLOG_MAX, | 22 zstd.ZstdCompressionParameters(window_log=zstd.WINDOWLOG_MAX, |
23 chain_log=zstd.CHAINLOG_MAX, | 23 chain_log=zstd.CHAINLOG_MAX, |
24 hash_log=zstd.HASHLOG_MAX, | 24 hash_log=zstd.HASHLOG_MAX, |
25 search_log=zstd.SEARCHLOG_MAX, | 25 search_log=zstd.SEARCHLOG_MAX, |
26 min_match=zstd.SEARCHLENGTH_MAX - 1, | 26 min_match=zstd.MINMATCH_MAX - 1, |
27 target_length=zstd.TARGETLENGTH_MAX, | 27 target_length=zstd.TARGETLENGTH_MAX, |
28 compression_strategy=zstd.STRATEGY_BTULTRA) | 28 strategy=zstd.STRATEGY_BTULTRA2) |
29 | 29 |
30 def test_from_level(self): | 30 def test_from_level(self): |
31 p = zstd.ZstdCompressionParameters.from_level(1) | 31 p = zstd.ZstdCompressionParameters.from_level(1) |
32 self.assertIsInstance(p, zstd.CompressionParameters) | 32 self.assertIsInstance(p, zstd.CompressionParameters) |
33 | 33 |
41 chain_log=6, | 41 chain_log=6, |
42 hash_log=7, | 42 hash_log=7, |
43 search_log=4, | 43 search_log=4, |
44 min_match=5, | 44 min_match=5, |
45 target_length=8, | 45 target_length=8, |
46 compression_strategy=1) | 46 strategy=1) |
47 self.assertEqual(p.window_log, 10) | 47 self.assertEqual(p.window_log, 10) |
48 self.assertEqual(p.chain_log, 6) | 48 self.assertEqual(p.chain_log, 6) |
49 self.assertEqual(p.hash_log, 7) | 49 self.assertEqual(p.hash_log, 7) |
50 self.assertEqual(p.search_log, 4) | 50 self.assertEqual(p.search_log, 4) |
51 self.assertEqual(p.min_match, 5) | 51 self.assertEqual(p.min_match, 5) |
57 | 57 |
58 p = zstd.ZstdCompressionParameters(threads=4) | 58 p = zstd.ZstdCompressionParameters(threads=4) |
59 self.assertEqual(p.threads, 4) | 59 self.assertEqual(p.threads, 4) |
60 | 60 |
61 p = zstd.ZstdCompressionParameters(threads=2, job_size=1048576, | 61 p = zstd.ZstdCompressionParameters(threads=2, job_size=1048576, |
62 overlap_size_log=6) | 62 overlap_log=6) |
63 self.assertEqual(p.threads, 2) | 63 self.assertEqual(p.threads, 2) |
64 self.assertEqual(p.job_size, 1048576) | 64 self.assertEqual(p.job_size, 1048576) |
65 self.assertEqual(p.overlap_log, 6) | |
65 self.assertEqual(p.overlap_size_log, 6) | 66 self.assertEqual(p.overlap_size_log, 6) |
66 | 67 |
67 p = zstd.ZstdCompressionParameters(compression_level=-1) | 68 p = zstd.ZstdCompressionParameters(compression_level=-1) |
68 self.assertEqual(p.compression_level, -1) | 69 self.assertEqual(p.compression_level, -1) |
69 | 70 |
83 self.assertEqual(p.ldm_min_match, 6) | 84 self.assertEqual(p.ldm_min_match, 6) |
84 | 85 |
85 p = zstd.ZstdCompressionParameters(ldm_bucket_size_log=7) | 86 p = zstd.ZstdCompressionParameters(ldm_bucket_size_log=7) |
86 self.assertEqual(p.ldm_bucket_size_log, 7) | 87 self.assertEqual(p.ldm_bucket_size_log, 7) |
87 | 88 |
88 p = zstd.ZstdCompressionParameters(ldm_hash_every_log=8) | 89 p = zstd.ZstdCompressionParameters(ldm_hash_rate_log=8) |
89 self.assertEqual(p.ldm_hash_every_log, 8) | 90 self.assertEqual(p.ldm_hash_every_log, 8) |
91 self.assertEqual(p.ldm_hash_rate_log, 8) | |
90 | 92 |
91 def test_estimated_compression_context_size(self): | 93 def test_estimated_compression_context_size(self): |
92 p = zstd.ZstdCompressionParameters(window_log=20, | 94 p = zstd.ZstdCompressionParameters(window_log=20, |
93 chain_log=16, | 95 chain_log=16, |
94 hash_log=17, | 96 hash_log=17, |
95 search_log=1, | 97 search_log=1, |
96 min_match=5, | 98 min_match=5, |
97 target_length=16, | 99 target_length=16, |
98 compression_strategy=zstd.STRATEGY_DFAST) | 100 strategy=zstd.STRATEGY_DFAST) |
99 | 101 |
100 # 32-bit has slightly different values from 64-bit. | 102 # 32-bit has slightly different values from 64-bit. |
101 self.assertAlmostEqual(p.estimated_compression_context_size(), 1294072, | 103 self.assertAlmostEqual(p.estimated_compression_context_size(), 1294072, |
102 delta=250) | 104 delta=250) |
105 | |
106 def test_strategy(self): | |
107 with self.assertRaisesRegexp(ValueError, 'cannot specify both compression_strategy'): | |
108 zstd.ZstdCompressionParameters(strategy=0, compression_strategy=0) | |
109 | |
110 p = zstd.ZstdCompressionParameters(strategy=2) | |
111 self.assertEqual(p.compression_strategy, 2) | |
112 | |
113 p = zstd.ZstdCompressionParameters(strategy=3) | |
114 self.assertEqual(p.compression_strategy, 3) | |
115 | |
116 def test_ldm_hash_rate_log(self): | |
117 with self.assertRaisesRegexp(ValueError, 'cannot specify both ldm_hash_rate_log'): | |
118 zstd.ZstdCompressionParameters(ldm_hash_rate_log=8, ldm_hash_every_log=4) | |
119 | |
120 p = zstd.ZstdCompressionParameters(ldm_hash_rate_log=8) | |
121 self.assertEqual(p.ldm_hash_every_log, 8) | |
122 | |
123 p = zstd.ZstdCompressionParameters(ldm_hash_every_log=16) | |
124 self.assertEqual(p.ldm_hash_every_log, 16) | |
125 | |
126 def test_overlap_log(self): | |
127 with self.assertRaisesRegexp(ValueError, 'cannot specify both overlap_log'): | |
128 zstd.ZstdCompressionParameters(overlap_log=1, overlap_size_log=9) | |
129 | |
130 p = zstd.ZstdCompressionParameters(overlap_log=2) | |
131 self.assertEqual(p.overlap_log, 2) | |
132 self.assertEqual(p.overlap_size_log, 2) | |
133 | |
134 p = zstd.ZstdCompressionParameters(overlap_size_log=4) | |
135 self.assertEqual(p.overlap_log, 4) | |
136 self.assertEqual(p.overlap_size_log, 4) | |
103 | 137 |
104 | 138 |
105 @make_cffi | 139 @make_cffi |
106 class TestFrameParameters(unittest.TestCase): | 140 class TestFrameParameters(unittest.TestCase): |
107 def test_invalid_type(self): | 141 def test_invalid_type(self): |