diff options
Diffstat (limited to 'xdelta3/testing')
-rw-r--r-- | xdelta3/testing/checksum_test.cc | 82 |
1 files changed, 18 insertions, 64 deletions
diff --git a/xdelta3/testing/checksum_test.cc b/xdelta3/testing/checksum_test.cc index 353d705..53566b9 100644 --- a/xdelta3/testing/checksum_test.cc +++ b/xdelta3/testing/checksum_test.cc | |||
@@ -176,9 +176,9 @@ struct with_stream : public cksum_params<SELF> { | |||
176 | }; | 176 | }; |
177 | 177 | ||
178 | MEMBER | 178 | MEMBER |
179 | struct large64_cksum : public with_stream<SELF> { | 179 | struct large_cksum : public with_stream<SELF> { |
180 | Word step(const uint8_t *ptr) { | 180 | Word step(const uint8_t *ptr) { |
181 | return xd3_large64_cksum (&this->stream.large_hash, ptr, CksumSize); | 181 | return xd3_large_cksum (&this->stream.large_hash, ptr, CksumSize); |
182 | } | 182 | } |
183 | 183 | ||
184 | Word state0(const uint8_t *ptr) { | 184 | Word state0(const uint8_t *ptr) { |
@@ -187,36 +187,26 @@ struct large64_cksum : public with_stream<SELF> { | |||
187 | } | 187 | } |
188 | 188 | ||
189 | Word incr(const uint8_t *ptr) { | 189 | Word incr(const uint8_t *ptr) { |
190 | incr_state = xd3_large64_cksum_update (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | 190 | incr_state = xd3_large_cksum_update (&this->stream.large_hash, |
191 | incr_state, ptr - 1, CksumSize); | ||
191 | return incr_state; | 192 | return incr_state; |
192 | } | 193 | } |
193 | 194 | ||
194 | Word incr_state; | 195 | Word incr_state; |
195 | }; | 196 | }; |
196 | 197 | ||
197 | MEMBER | 198 | #if SIZEOF_USIZE_T == 4 |
198 | struct large64_cksum_old : public with_stream<SELF> { | 199 | #define xd3_large_cksum_old xd3_large32_cksum_old |
199 | Word step(const uint8_t *ptr) { | 200 | #define xd3_large_cksum_update_old xd3_large32_cksum_update_old |
200 | return xd3_large64_cksum_old (&this->stream.large_hash, ptr, CksumSize); | 201 | #elif SIZEOF_USIZE_T == 8 |
201 | } | 202 | #define xd3_large_cksum_old xd3_large64_cksum_old |
202 | 203 | #define xd3_large_cksum_update_old xd3_large64_cksum_update_old | |
203 | Word state0(const uint8_t *ptr) { | 204 | #endif |
204 | incr_state = step(ptr); | ||
205 | return incr_state; | ||
206 | } | ||
207 | |||
208 | Word incr(const uint8_t *ptr) { | ||
209 | incr_state = xd3_large64_cksum_update_old (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | ||
210 | return incr_state; | ||
211 | } | ||
212 | |||
213 | Word incr_state; | ||
214 | }; | ||
215 | 205 | ||
216 | MEMBER | 206 | MEMBER |
217 | struct large32_cksum : public with_stream<SELF> { | 207 | struct large_cksum_old : public with_stream<SELF> { |
218 | Word step(const uint8_t *ptr) { | 208 | Word step(const uint8_t *ptr) { |
219 | return xd3_large32_cksum (&this->stream.large_hash, ptr, CksumSize); | 209 | return xd3_large_cksum_old (&this->stream.large_hash, ptr, CksumSize); |
220 | } | 210 | } |
221 | 211 | ||
222 | Word state0(const uint8_t *ptr) { | 212 | Word state0(const uint8_t *ptr) { |
@@ -225,48 +215,14 @@ struct large32_cksum : public with_stream<SELF> { | |||
225 | } | 215 | } |
226 | 216 | ||
227 | Word incr(const uint8_t *ptr) { | 217 | Word incr(const uint8_t *ptr) { |
228 | incr_state = xd3_large32_cksum_update (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | 218 | incr_state = xd3_large_cksum_update_old (&this->stream.large_hash, |
219 | incr_state, ptr - 1, CksumSize); | ||
229 | return incr_state; | 220 | return incr_state; |
230 | } | 221 | } |
231 | 222 | ||
232 | Word incr_state; | 223 | Word incr_state; |
233 | }; | 224 | }; |
234 | 225 | ||
235 | MEMBER | ||
236 | struct large32_cksum_old : public with_stream<SELF> { | ||
237 | Word step(const uint8_t *ptr) { | ||
238 | return xd3_large32_cksum_old (&this->stream.large_hash, ptr, CksumSize); | ||
239 | } | ||
240 | |||
241 | Word state0(const uint8_t *ptr) { | ||
242 | incr_state = step(ptr); | ||
243 | return incr_state; | ||
244 | } | ||
245 | |||
246 | Word incr(const uint8_t *ptr) { | ||
247 | incr_state = xd3_large32_cksum_update_old (&this->stream.large_hash, incr_state, ptr - 1, CksumSize); | ||
248 | return incr_state; | ||
249 | } | ||
250 | |||
251 | Word incr_state; | ||
252 | }; | ||
253 | |||
254 | MEMBER | ||
255 | struct large_cksum | ||
256 | : std::conditional<std::is_same<Word, uint32_t>::value, | ||
257 | large32_cksum<SELF>, | ||
258 | large64_cksum<SELF>>::type | ||
259 | { | ||
260 | }; | ||
261 | |||
262 | MEMBER | ||
263 | struct large_cksum_old | ||
264 | : std::conditional<std::is_same<Word, uint32_t>::value, | ||
265 | large32_cksum_old<SELF>, | ||
266 | large64_cksum_old<SELF>>::type | ||
267 | { | ||
268 | }; | ||
269 | |||
270 | // TESTS | 226 | // TESTS |
271 | 227 | ||
272 | template <typename Word> | 228 | template <typename Word> |
@@ -717,11 +673,9 @@ int main(int argc, char** argv) { | |||
717 | _old_ ## T ## _ ## Z ## _ ## S ## _ ## C \ | 673 | _old_ ## T ## _ ## Z ## _ ## S ## _ ## C \ |
718 | ("old_" #T "_" #Z "_" #S "_" #C) | 674 | ("old_" #T "_" #Z "_" #S "_" #C) |
719 | 675 | ||
720 | #define TESTS(SIZE, SKIP) \ | 676 | #define TESTS(SIZE, SKIP) \ |
721 | TEST(uint32_t, SIZE, SKIP, 1); \ | 677 | TEST(usize_t, SIZE, SKIP, 1); \ |
722 | TEST(uint32_t, SIZE, SKIP, 2); \ | 678 | TEST(usize_t, SIZE, SKIP, 2) |
723 | TEST(uint64_t, SIZE, SKIP, 1); \ | ||
724 | TEST(uint64_t, SIZE, SKIP, 2) | ||
725 | 679 | ||
726 | TESTS(9, 1); | 680 | TESTS(9, 1); |
727 | TESTS(9, 9); | 681 | TESTS(9, 9); |