mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +01:00
Implement the gzip checksum
Also fix a bug in ast.Raw.SetPackage, discovered because type checking failed to show that "[] u8" and "[] u8" are equivalent types.
This commit is contained in:
1 parent
153d1276a1
commit
a8e40fedc9
7 files changed
+184
-28
No files matched your search
+8
-8
@@ -231,17 +231,17 @@ bool do_test_wuffs_zlib_checksum(bool ignore_checksum, bool bad_checksum) {
|
||||
if (!read_file(&src, zlib_midsummer_gt.src_filename)) {
|
||||
return false;
|
||||
}
|
||||
if (src.wi == 0) {
|
||||
FAIL("source file was empty");
|
||||
// Flip a bit in the zlib checksum, which is in the last 4 bytes of the file.
|
||||
if (src.wi < 4) {
|
||||
FAIL("source file was too short");
|
||||
return false;
|
||||
}
|
||||
// Flip a bit in the zlib checksum, which comes at the end of the file.
|
||||
if (bad_checksum) {
|
||||
src.ptr[src.wi - 1] ^= 1;
|
||||
src.ptr[src.wi - 1 - (bad_checksum & 3)] ^= 1;
|
||||
}
|
||||
|
||||
int end_limit;
|
||||
for (end_limit = 0; end_limit < 8; end_limit++) {
|
||||
for (end_limit = 0; end_limit < 10; end_limit++) {
|
||||
wuffs_zlib__decoder dec;
|
||||
wuffs_zlib__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
wuffs_zlib__decoder__set_ignore_checksum(&dec, ignore_checksum);
|
||||
@@ -288,17 +288,17 @@ bool do_test_wuffs_zlib_checksum(bool ignore_checksum, bool bad_checksum) {
|
||||
|
||||
void test_wuffs_zlib_checksum_ignore() {
|
||||
CHECK_FOCUS(__func__);
|
||||
do_test_wuffs_zlib_checksum(true, true);
|
||||
do_test_wuffs_zlib_checksum(true, 1);
|
||||
}
|
||||
|
||||
void test_wuffs_zlib_checksum_verify_bad() {
|
||||
CHECK_FOCUS(__func__);
|
||||
do_test_wuffs_zlib_checksum(false, true);
|
||||
do_test_wuffs_zlib_checksum(false, 1);
|
||||
}
|
||||
|
||||
void test_wuffs_zlib_checksum_verify_good() {
|
||||
CHECK_FOCUS(__func__);
|
||||
do_test_wuffs_zlib_checksum(false, false);
|
||||
do_test_wuffs_zlib_checksum(false, 0);
|
||||
}
|
||||
|
||||
void test_wuffs_zlib_decode_midsummer() {
|
||||
|
||||
Reference in new issue
Block a user