mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +01:00
Rename s/got/have/ in test/c
This commit is contained in:
1 parent
ce50a39f85
commit
7b199116b0
12 files changed
+422
-414
No files matched your search
@@ -88,7 +88,7 @@ const char* mimic_zlib_decode(wuffs_base__io_buffer* dst,
|
||||
rlimit, false);
|
||||
}
|
||||
|
||||
const char* mimic_zlib_decode_with_dictionary(wuffs_base__io_buffer* got,
|
||||
const char* mimic_zlib_decode_with_dictionary(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
wuffs_base__slice_u8 dictionary) {
|
||||
return "miniz does not implement zlib dictionaries";
|
||||
|
||||
@@ -144,7 +144,7 @@ const char* test_wuffs_adler32_golden() {
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
uint32_t got = 0;
|
||||
uint32_t have = 0;
|
||||
size_t num_fragments = 0;
|
||||
size_t num_bytes = 0;
|
||||
do {
|
||||
@@ -156,15 +156,15 @@ const char* test_wuffs_adler32_golden() {
|
||||
if ((j > 0) && (data.len > limit)) {
|
||||
data.len = limit;
|
||||
}
|
||||
got = wuffs_adler32__hasher__update_u32(&checksum, data);
|
||||
have = wuffs_adler32__hasher__update_u32(&checksum, data);
|
||||
num_fragments++;
|
||||
num_bytes += data.len;
|
||||
} while (num_bytes < src.meta.wi);
|
||||
|
||||
if (got != test_cases[i].want) {
|
||||
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": got 0x%08" PRIX32
|
||||
if (have != test_cases[i].want) {
|
||||
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": have 0x%08" PRIX32
|
||||
", want 0x%08" PRIX32 "\n",
|
||||
i, j, test_cases[i].filename, got, test_cases[i].want);
|
||||
i, j, test_cases[i].filename, have, test_cases[i].want);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ const char* test_wuffs_adler32_pi() {
|
||||
"141592653589793238462643383279502884197169399375105820974944592307816406"
|
||||
"2862089986280348253421170";
|
||||
if (strlen(digits) != 99) {
|
||||
RETURN_FAIL("strlen(digits): got %d, want 99", (int)(strlen(digits)));
|
||||
RETURN_FAIL("strlen(digits): have %d, want 99", (int)(strlen(digits)));
|
||||
}
|
||||
|
||||
// The want values are determined by script/checksum.go.
|
||||
@@ -212,13 +212,13 @@ const char* test_wuffs_adler32_pi() {
|
||||
wuffs_adler32__hasher__initialize(
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
uint32_t got = wuffs_adler32__hasher__update_u32(
|
||||
uint32_t have = wuffs_adler32__hasher__update_u32(
|
||||
&checksum, ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(digits),
|
||||
.len = i,
|
||||
}));
|
||||
if (got != wants[i]) {
|
||||
RETURN_FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32, i, got,
|
||||
if (have != wants[i]) {
|
||||
RETURN_FAIL("i=%d: have 0x%08" PRIX32 ", want 0x%08" PRIX32, i, have,
|
||||
wants[i]);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ const char* test_wuffs_bmp_decode_frame_config() {
|
||||
wuffs_base__status status =
|
||||
wuffs_bmp__decoder__decode_frame_config(&dec, &fc, &src);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config #1: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
if (src.meta.ri != src.meta.wi) {
|
||||
|
||||
+15
-15
@@ -144,7 +144,7 @@ const char* test_wuffs_crc32_ieee_golden() {
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
uint32_t got = 0;
|
||||
uint32_t have = 0;
|
||||
size_t num_fragments = 0;
|
||||
size_t num_bytes = 0;
|
||||
do {
|
||||
@@ -156,15 +156,15 @@ const char* test_wuffs_crc32_ieee_golden() {
|
||||
if ((j > 0) && (data.len > limit)) {
|
||||
data.len = limit;
|
||||
}
|
||||
got = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
|
||||
have = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
|
||||
num_fragments++;
|
||||
num_bytes += data.len;
|
||||
} while (num_bytes < src.meta.wi);
|
||||
|
||||
if (got != test_cases[i].want) {
|
||||
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": got 0x%08" PRIX32
|
||||
if (have != test_cases[i].want) {
|
||||
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": have 0x%08" PRIX32
|
||||
", want 0x%08" PRIX32,
|
||||
i, j, test_cases[i].filename, got, test_cases[i].want);
|
||||
i, j, test_cases[i].filename, have, test_cases[i].want);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
|
||||
"141592653589793238462643383279502884197169399375105820974944592307816406"
|
||||
"2862089986280348253421170";
|
||||
if (strlen(digits) != 99) {
|
||||
RETURN_FAIL("strlen(digits): got %d, want 99", (int)(strlen(digits)));
|
||||
RETURN_FAIL("strlen(digits): have %d, want 99", (int)(strlen(digits)));
|
||||
}
|
||||
|
||||
// The want values are determined by script/checksum.go.
|
||||
@@ -205,7 +205,7 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
uint32_t got;
|
||||
uint32_t have;
|
||||
wuffs_base__slice_u8 data = ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(digits),
|
||||
.len = i,
|
||||
@@ -213,19 +213,19 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
|
||||
|
||||
if (mimic) {
|
||||
// A simple, slow CRC-32 IEEE implementation, 1 bit at a time.
|
||||
got = 0xFFFFFFFF;
|
||||
have = 0xFFFFFFFF;
|
||||
while (data.len--) {
|
||||
uint8_t byte = *data.ptr++;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if ((got ^ byte) & 1) {
|
||||
got = (got >> 1) ^ 0xEDB88320;
|
||||
if ((have ^ byte) & 1) {
|
||||
have = (have >> 1) ^ 0xEDB88320;
|
||||
} else {
|
||||
got = (got >> 1);
|
||||
have = (have >> 1);
|
||||
}
|
||||
byte >>= 1;
|
||||
}
|
||||
}
|
||||
got ^= 0xFFFFFFFF;
|
||||
have ^= 0xFFFFFFFF;
|
||||
|
||||
} else {
|
||||
wuffs_crc32__ieee_hasher checksum;
|
||||
@@ -233,11 +233,11 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
|
||||
wuffs_crc32__ieee_hasher__initialize(
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
got = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
|
||||
have = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
|
||||
}
|
||||
|
||||
if (got != wants[i]) {
|
||||
RETURN_FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32, i, got,
|
||||
if (have != wants[i]) {
|
||||
RETURN_FAIL("i=%d: have 0x%08" PRIX32 ", want 0x%08" PRIX32, i, have,
|
||||
wants[i]);
|
||||
}
|
||||
}
|
||||
|
||||
+78
-76
@@ -226,11 +226,11 @@ const char* test_wuffs_deflate_decode_deflate_distance_32768() {
|
||||
|
||||
const char* test_wuffs_deflate_decode_deflate_distance_code_31() {
|
||||
CHECK_FOCUS(__func__);
|
||||
const char* got = do_test_io_buffers(wuffs_deflate_decode,
|
||||
&deflate_deflate_distance_code_31_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
if (got != wuffs_deflate__error__bad_huffman_code) {
|
||||
RETURN_FAIL("got \"%s\", want \"%s\"", got,
|
||||
const char* have = do_test_io_buffers(wuffs_deflate_decode,
|
||||
&deflate_deflate_distance_code_31_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
if (have != wuffs_deflate__error__bad_huffman_code) {
|
||||
RETURN_FAIL("have \"%s\", want \"%s\"", have,
|
||||
wuffs_deflate__error__bad_huffman_code);
|
||||
}
|
||||
return NULL;
|
||||
@@ -249,8 +249,8 @@ const char* test_wuffs_deflate_decode_deflate_huffman_primlen_9() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
|
||||
golden_test* gt = &deflate_deflate_huffman_primlen_9_gt;
|
||||
@@ -261,21 +261,21 @@ const char* test_wuffs_deflate_decode_deflate_huffman_primlen_9() {
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__DEFAULT_OPTIONS));
|
||||
CHECK_STATUS("transform_io", wuffs_deflate__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice));
|
||||
&dec, &have, &src, global_work_slice));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 2; i++) {
|
||||
// Find the first unused (i.e. zero) entry in the i'th huffs table.
|
||||
int got = WUFFS_DEFLATE__HUFFS_TABLE_SIZE;
|
||||
while ((got > 0) && (dec.private_data.f_huffs[i][got - 1] == 0)) {
|
||||
got--;
|
||||
int have = WUFFS_DEFLATE__HUFFS_TABLE_SIZE;
|
||||
while ((have > 0) && (dec.private_data.f_huffs[i][have - 1] == 0)) {
|
||||
have--;
|
||||
}
|
||||
|
||||
// See script/print-deflate-huff-table-size.go with primLen = 9 for how
|
||||
// these expected values are derived.
|
||||
int want = (i == 0) ? 852 : 592;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("i=%d: got %d, want %d", i, got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("i=%d: have %d, want %d", i, have, want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +329,8 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
@@ -346,7 +346,7 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
if (split >= gt->src_offset1) {
|
||||
RETURN_FAIL("i=%d: split was not an interior split", i);
|
||||
}
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
|
||||
wuffs_deflate__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
@@ -358,26 +358,26 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
src.meta.ri = gt->src_offset0;
|
||||
src.meta.wi = split;
|
||||
wuffs_base__status z0 = wuffs_deflate__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice);
|
||||
&dec, &have, &src, global_work_slice);
|
||||
|
||||
src.meta.closed = true;
|
||||
src.meta.ri = split;
|
||||
src.meta.wi = gt->src_offset1;
|
||||
wuffs_base__status z1 = wuffs_deflate__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice);
|
||||
&dec, &have, &src, global_work_slice);
|
||||
|
||||
if (z0.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("i=%d: z0: got \"%s\", want \"%s\"", i, z0.repr,
|
||||
RETURN_FAIL("i=%d: z0: have \"%s\", want \"%s\"", i, z0.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
if (z1.repr) {
|
||||
RETURN_FAIL("i=%d: z1: got \"%s\"", i, z1.repr);
|
||||
RETURN_FAIL("i=%d: z1: have \"%s\"", i, z1.repr);
|
||||
}
|
||||
|
||||
char prefix[64];
|
||||
snprintf(prefix, 64, "i=%d: ", i);
|
||||
CHECK_STRING(check_io_buffers_equal(prefix, &got, &want));
|
||||
CHECK_STRING(check_io_buffers_equal(prefix, &have, &want));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -385,27 +385,27 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
const char* do_test_wuffs_deflate_history(int i,
|
||||
golden_test* gt,
|
||||
wuffs_base__io_buffer* src,
|
||||
wuffs_base__io_buffer* got,
|
||||
wuffs_base__io_buffer* have,
|
||||
wuffs_deflate__decoder* dec,
|
||||
uint32_t starting_history_index,
|
||||
uint64_t wlimit,
|
||||
const char* want_z) {
|
||||
src->meta.ri = gt->src_offset0;
|
||||
src->meta.wi = gt->src_offset1;
|
||||
got->meta.ri = 0;
|
||||
got->meta.wi = 0;
|
||||
have->meta.ri = 0;
|
||||
have->meta.wi = 0;
|
||||
|
||||
wuffs_base__io_buffer limited_got = make_limited_writer(*got, wlimit);
|
||||
wuffs_base__io_buffer limited_have = make_limited_writer(*have, wlimit);
|
||||
|
||||
dec->private_impl.f_history_index = starting_history_index;
|
||||
|
||||
wuffs_base__status got_z = wuffs_deflate__decoder__transform_io(
|
||||
dec, &limited_got, src, global_work_slice);
|
||||
got->meta.wi += limited_got.meta.wi;
|
||||
if (got_z.repr != want_z) {
|
||||
wuffs_base__status have_z = wuffs_deflate__decoder__transform_io(
|
||||
dec, &limited_have, src, global_work_slice);
|
||||
have->meta.wi += limited_have.meta.wi;
|
||||
if (have_z.repr != want_z) {
|
||||
RETURN_FAIL("i=%d: starting_history_index=0x%04" PRIX32
|
||||
": decode: got \"%s\", want \"%s\"",
|
||||
i, starting_history_index, got_z.repr, want_z);
|
||||
": decode: have \"%s\", want \"%s\"",
|
||||
i, starting_history_index, have_z.repr, want_z);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -416,8 +416,8 @@ const char* test_wuffs_deflate_history_full() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
@@ -437,25 +437,25 @@ const char* test_wuffs_deflate_history_full() {
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
CHECK_STRING(do_test_wuffs_deflate_history(
|
||||
i, gt, &src, &got, &dec, 0, want.meta.wi + i,
|
||||
i, gt, &src, &have, &dec, 0, want.meta.wi + i,
|
||||
i >= 0 ? NULL : wuffs_base__suspension__short_write));
|
||||
|
||||
uint32_t want_history_index = i >= 0 ? 0 : full_history_size;
|
||||
if (dec.private_impl.f_history_index != want_history_index) {
|
||||
RETURN_FAIL("i=%d: history_index: got %" PRIu32 ", want %" PRIu32, i,
|
||||
RETURN_FAIL("i=%d: history_index: have %" PRIu32 ", want %" PRIu32, i,
|
||||
dec.private_impl.f_history_index, want_history_index);
|
||||
}
|
||||
if (i >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer history_got = ((wuffs_base__io_buffer){
|
||||
wuffs_base__io_buffer history_have = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dec.private_data.f_history,
|
||||
.len = full_history_size,
|
||||
}),
|
||||
});
|
||||
history_got.meta.wi = full_history_size;
|
||||
history_have.meta.wi = full_history_size;
|
||||
if (want.meta.wi < full_history_size - i) {
|
||||
RETURN_FAIL("i=%d: want file is too short", i);
|
||||
}
|
||||
@@ -467,7 +467,7 @@ const char* test_wuffs_deflate_history_full() {
|
||||
});
|
||||
history_want.meta.wi = full_history_size;
|
||||
|
||||
CHECK_STRING(check_io_buffers_equal("", &history_got, &history_want));
|
||||
CHECK_STRING(check_io_buffers_equal("", &history_have, &history_want));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -478,8 +478,8 @@ const char* test_wuffs_deflate_history_partial() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
|
||||
golden_test* gt = &deflate_pi_gt;
|
||||
@@ -507,30 +507,31 @@ const char* test_wuffs_deflate_history_partial() {
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
CHECK_STRING(do_test_wuffs_deflate_history(
|
||||
i, gt, &src, &got, &dec, starting_history_index, fragment_length,
|
||||
i, gt, &src, &have, &dec, starting_history_index, fragment_length,
|
||||
wuffs_base__suspension__short_write));
|
||||
|
||||
bool got_full = dec.private_impl.f_history_index >= 0x8000;
|
||||
uint32_t got_history_index = dec.private_impl.f_history_index & 0x7FFF;
|
||||
bool have_full = dec.private_impl.f_history_index >= 0x8000;
|
||||
uint32_t have_history_index = dec.private_impl.f_history_index & 0x7FFF;
|
||||
bool want_full = (starting_history_index + fragment_length) >= 0x8000;
|
||||
uint32_t want_history_index =
|
||||
(starting_history_index + fragment_length) & 0x7FFF;
|
||||
if ((got_full != want_full) || (got_history_index != want_history_index)) {
|
||||
if ((have_full != want_full) ||
|
||||
(have_history_index != want_history_index)) {
|
||||
RETURN_FAIL("i=%d: starting_history_index=0x%04" PRIX32
|
||||
": history_index: got %d;%04" PRIX32 ", want %d;%04" PRIX32,
|
||||
i, starting_history_index, (int)(got_full), got_history_index,
|
||||
(int)(want_full), want_history_index);
|
||||
": history_index: have %d;%04" PRIX32 ", want %d;%04" PRIX32,
|
||||
i, starting_history_index, (int)(have_full),
|
||||
have_history_index, (int)(want_full), want_history_index);
|
||||
}
|
||||
|
||||
int j;
|
||||
for (j = -2; j < (int)(fragment_length) + 2; j++) {
|
||||
uint32_t index = (starting_history_index + j) & 0x7FFF;
|
||||
uint8_t got = dec.private_data.f_history[index];
|
||||
uint8_t have = dec.private_data.f_history[index];
|
||||
uint8_t want = (0 <= j && j < fragment_length) ? fragment[j] : 0;
|
||||
if (got != want) {
|
||||
if (have != want) {
|
||||
RETURN_FAIL("i=%d: starting_history_index=0x%04" PRIX32
|
||||
": j=%d: got 0x%02" PRIX8 ", want 0x%02" PRIX8,
|
||||
i, starting_history_index, j, got, want);
|
||||
": j=%d: have 0x%02" PRIX8 ", want 0x%02" PRIX8,
|
||||
i, starting_history_index, j, have, want);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -616,10 +617,10 @@ const char* test_wuffs_deflate_table_redirect() {
|
||||
const int n_f_huffs = sizeof(dec.private_data.f_huffs[0]) /
|
||||
sizeof(dec.private_data.f_huffs[0][0]);
|
||||
for (i = 0; i < n_f_huffs; i++) {
|
||||
bool got = dec.private_data.f_huffs[0][i] == 0;
|
||||
bool have = dec.private_data.f_huffs[0][i] == 0;
|
||||
bool want = i >= (1 << 9) + (1 << 3) + (1 << 3) + (1 << 4);
|
||||
if (got != want) {
|
||||
RETURN_FAIL("huffs[0][%d] == 0: got %d, want %d", i, got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("huffs[0][%d] == 0: have %d, want %d", i, have, want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,25 +628,25 @@ const char* test_wuffs_deflate_table_redirect() {
|
||||
// - 0b101111111 (0x017F) to the table offset 512 (0x0200), a 3-bit table.
|
||||
// - 0b011111111 (0x00FF) to the table offset 520 (0x0208), a 3-bit table.
|
||||
// - 0b111111111 (0x01FF) to the table offset 528 (0x0210), a 4-bit table.
|
||||
uint32_t got;
|
||||
uint32_t have;
|
||||
uint32_t want;
|
||||
got = dec.private_data.f_huffs[0][0x017F];
|
||||
have = dec.private_data.f_huffs[0][0x017F];
|
||||
want = 0x10020039;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("huffs[0][0x017F]: got 0x%08" PRIX32 ", want 0x%08" PRIX32, got,
|
||||
want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("huffs[0][0x017F]: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
have, want);
|
||||
}
|
||||
got = dec.private_data.f_huffs[0][0x00FF];
|
||||
have = dec.private_data.f_huffs[0][0x00FF];
|
||||
want = 0x10020839;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("huffs[0][0x00FF]: got 0x%08" PRIX32 ", want 0x%08" PRIX32, got,
|
||||
want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("huffs[0][0x00FF]: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
have, want);
|
||||
}
|
||||
got = dec.private_data.f_huffs[0][0x01FF];
|
||||
have = dec.private_data.f_huffs[0][0x01FF];
|
||||
want = 0x10021049;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("huffs[0][0x01FF]: got 0x%08" PRIX32 ", want 0x%08" PRIX32, got,
|
||||
want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("huffs[0][0x01FF]: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
have, want);
|
||||
}
|
||||
|
||||
// The first 2nd-level table should look like wants.
|
||||
@@ -654,12 +655,12 @@ const char* test_wuffs_deflate_table_redirect() {
|
||||
0x80000801, 0x80000A03, 0x80000801, 0x80000C03,
|
||||
};
|
||||
for (i = 0; i < 8; i++) {
|
||||
got = dec.private_data.f_huffs[0][0x0200 + i];
|
||||
have = dec.private_data.f_huffs[0][0x0200 + i];
|
||||
want = wants[i];
|
||||
if (got != want) {
|
||||
RETURN_FAIL("huffs[0][0x%04" PRIX32 "]: got 0x%08" PRIX32
|
||||
if (have != want) {
|
||||
RETURN_FAIL("huffs[0][0x%04" PRIX32 "]: have 0x%08" PRIX32
|
||||
", want 0x%08" PRIX32,
|
||||
(uint32_t)(0x0200 + i), got, want);
|
||||
(uint32_t)(0x0200 + i), have, want);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -698,12 +699,13 @@ const char* test_mimic_deflate_decode_deflate_distance_32768() {
|
||||
|
||||
const char* test_mimic_deflate_decode_deflate_distance_code_31() {
|
||||
CHECK_FOCUS(__func__);
|
||||
const char* got = do_test_io_buffers(mimic_deflate_decode,
|
||||
&deflate_deflate_distance_code_31_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
const char* have = do_test_io_buffers(mimic_deflate_decode,
|
||||
&deflate_deflate_distance_code_31_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
const char* want = "inflate failed (data error)";
|
||||
if ((got != want) && ((got == NULL) || (want == NULL) || strcmp(got, want))) {
|
||||
RETURN_FAIL("got \"%s\", want \"%s\"", got, want);
|
||||
if ((have != want) &&
|
||||
((have == NULL) || (want == NULL) || strcmp(have, want))) {
|
||||
RETURN_FAIL("have \"%s\", want \"%s\"", have, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+178
-173
@@ -76,7 +76,7 @@ const char* test_basic_bad_receiver() {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(NULL, &ic, NULL);
|
||||
if (status.repr != wuffs_base__error__bad_receiver) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__bad_receiver);
|
||||
}
|
||||
return NULL;
|
||||
@@ -89,7 +89,7 @@ const char* test_basic_bad_sizeof_receiver() {
|
||||
&dec, 0, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status.repr != wuffs_base__error__bad_sizeof_receiver) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__bad_sizeof_receiver);
|
||||
}
|
||||
return NULL;
|
||||
@@ -102,7 +102,7 @@ const char* test_basic_bad_wuffs_version() {
|
||||
&dec, sizeof dec, WUFFS_VERSION ^ 0x123456789ABC,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status.repr != wuffs_base__error__bad_wuffs_version) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__bad_wuffs_version);
|
||||
}
|
||||
return NULL;
|
||||
@@ -115,7 +115,7 @@ const char* test_basic_initialize_not_called() {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, NULL);
|
||||
if (status.repr != wuffs_base__error__initialize_not_called) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
return NULL;
|
||||
@@ -151,11 +151,11 @@ const char* test_basic_sub_struct_initializer() {
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
if (dec.private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
RETURN_FAIL("outer magic: got %" PRIu32 ", want %" PRIu32 "",
|
||||
RETURN_FAIL("outer magic: have %" PRIu32 ", want %" PRIu32 "",
|
||||
dec.private_impl.magic, WUFFS_BASE__MAGIC);
|
||||
}
|
||||
if (dec.private_data.f_lzw.private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
RETURN_FAIL("inner magic: got %" PRIu32 ", want %" PRIu32,
|
||||
RETURN_FAIL("inner magic: have %" PRIu32 ", want %" PRIu32,
|
||||
dec.private_data.f_lzw.private_impl.magic, WUFFS_BASE__MAGIC);
|
||||
}
|
||||
return NULL;
|
||||
@@ -234,8 +234,8 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
const char* indexes_filename,
|
||||
uint64_t rlimit,
|
||||
wuffs_base__pixel_format dst_pixfmt) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -257,22 +257,22 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, &src));
|
||||
if (wuffs_base__pixel_config__pixel_format(&ic.pixcfg).repr !=
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
RETURN_FAIL("pixel_format: got 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
RETURN_FAIL("pixel_format: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
wuffs_base__pixel_config__pixel_format(&ic.pixcfg).repr,
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY);
|
||||
}
|
||||
|
||||
// bricks-dither.gif is a 160 × 120, opaque, still (not animated) GIF.
|
||||
if (wuffs_base__pixel_config__width(&ic.pixcfg) != 160) {
|
||||
RETURN_FAIL("width: got %" PRIu32 ", want 160",
|
||||
RETURN_FAIL("width: have %" PRIu32 ", want 160",
|
||||
wuffs_base__pixel_config__width(&ic.pixcfg));
|
||||
}
|
||||
if (wuffs_base__pixel_config__height(&ic.pixcfg) != 120) {
|
||||
RETURN_FAIL("height: got %" PRIu32 ", want 120",
|
||||
RETURN_FAIL("height: have %" PRIu32 ", want 120",
|
||||
wuffs_base__pixel_config__height(&ic.pixcfg));
|
||||
}
|
||||
if (!wuffs_base__image_config__first_frame_is_opaque(&ic)) {
|
||||
RETURN_FAIL("first_frame_is_opaque: got false, want true");
|
||||
RETURN_FAIL("first_frame_is_opaque: have false, want true");
|
||||
}
|
||||
|
||||
wuffs_base__pixel_config__set(&ic.pixcfg, dst_pixfmt.repr,
|
||||
@@ -282,9 +282,9 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
CHECK_STATUS("set_from_slice", wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, &ic.pixcfg, global_pixel_slice));
|
||||
|
||||
uint32_t got = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
if (got != 1) {
|
||||
RETURN_FAIL("num_animation_loops: got %" PRIu32 ", want 1", got);
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
if (have != 1) {
|
||||
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want 1", have);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
break;
|
||||
}
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_frame_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
break;
|
||||
}
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
@@ -341,15 +341,15 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
|
||||
CHECK_STRING(copy_to_io_buffer_from_pixel_buffer(
|
||||
&got, &pb, wuffs_base__frame_config__bounds(&fc)));
|
||||
&have, &pb, wuffs_base__frame_config__bounds(&fc)));
|
||||
|
||||
if (rlimit < UINT64_MAX) {
|
||||
if (num_iters <= 2) {
|
||||
RETURN_FAIL("num_iters: got %d, want > 2", num_iters);
|
||||
RETURN_FAIL("num_iters: have %d, want > 2", num_iters);
|
||||
}
|
||||
} else {
|
||||
if (num_iters != 2) {
|
||||
RETURN_FAIL("num_iters: got %d, want 2", num_iters);
|
||||
RETURN_FAIL("num_iters: have %d, want 2", num_iters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,11 +362,11 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
});
|
||||
CHECK_STRING(read_file(&pal_want, palette_filename));
|
||||
if (dst_pixfmt.repr == WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
wuffs_base__io_buffer pal_got = ((wuffs_base__io_buffer){
|
||||
wuffs_base__io_buffer pal_have = ((wuffs_base__io_buffer){
|
||||
.data = wuffs_base__pixel_buffer__palette(&pb),
|
||||
});
|
||||
pal_got.meta.wi = pal_got.data.len;
|
||||
CHECK_STRING(check_io_buffers_equal("palette ", &pal_got, &pal_want));
|
||||
pal_have.meta.wi = pal_have.data.len;
|
||||
CHECK_STRING(check_io_buffers_equal("palette ", &pal_have, &pal_want));
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer ind_want = ((wuffs_base__io_buffer){
|
||||
@@ -374,7 +374,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
});
|
||||
CHECK_STRING(read_file(&ind_want, indexes_filename));
|
||||
if (dst_pixfmt.repr == WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
CHECK_STRING(check_io_buffers_equal("indexes ", &got, &ind_want));
|
||||
CHECK_STRING(check_io_buffers_equal("indexes ", &have, &ind_want));
|
||||
} else {
|
||||
wuffs_base__io_buffer expanded_want = ((wuffs_base__io_buffer){
|
||||
.data = global_work_slice,
|
||||
@@ -437,7 +437,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
return "unsupported pixel format";
|
||||
}
|
||||
|
||||
CHECK_STRING(check_io_buffers_equal("pixels ", &got, &expanded_want));
|
||||
CHECK_STRING(check_io_buffers_equal("pixels ", &have, &expanded_want));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -447,7 +447,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, global_work_slice, NULL);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
if (src.meta.ri != src.meta.wi) {
|
||||
@@ -483,14 +483,14 @@ const char* do_test_wuffs_gif_decode_expecting(wuffs_base__io_buffer src,
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, global_work_slice, NULL);
|
||||
if (status.repr != want_status) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
want_status);
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 r = wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||
bool dirty_rect_is_empty = wuffs_base__rect_ie_u32__is_empty(&r);
|
||||
if (dirty_rect_is_empty != want_dirty_rect_is_empty) {
|
||||
RETURN_FAIL("dirty_rect.is_empty: got %s, want %s",
|
||||
RETURN_FAIL("dirty_rect.is_empty: have %s, want %s",
|
||||
dirty_rect_is_empty ? "true" : "false",
|
||||
want_dirty_rect_is_empty ? "true" : "false");
|
||||
}
|
||||
@@ -516,7 +516,7 @@ const char* test_wuffs_gif_call_interleaved() {
|
||||
wuffs_gif__decoder__decode_frame_config(&dec, NULL, &limited_src);
|
||||
src.meta.ri += limited_src.meta.ri;
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_frame_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
}
|
||||
@@ -529,7 +529,7 @@ const char* test_wuffs_gif_call_interleaved() {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__error__interleaved_coroutine_calls) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
}
|
||||
@@ -556,7 +556,7 @@ const char* test_wuffs_gif_call_sequence() {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__error__bad_call_sequence) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__error__bad_call_sequence);
|
||||
}
|
||||
return NULL;
|
||||
@@ -583,9 +583,9 @@ const char* do_test_wuffs_gif_decode_animated(
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, &src));
|
||||
|
||||
uint32_t got_num_loops = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
if (got_num_loops != want_num_loops) {
|
||||
RETURN_FAIL("num_loops: got %" PRIu32 ", want %" PRIu32, got_num_loops,
|
||||
uint32_t have_num_loops = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
if (have_num_loops != want_num_loops) {
|
||||
RETURN_FAIL("num_loops: have %" PRIu32 ", want %" PRIu32, have_num_loops,
|
||||
want_num_loops);
|
||||
}
|
||||
|
||||
@@ -603,14 +603,14 @@ const char* do_test_wuffs_gif_decode_animated(
|
||||
}
|
||||
|
||||
if (want_frame_config_bounds) {
|
||||
wuffs_base__rect_ie_u32 got = wuffs_base__frame_config__bounds(&fc);
|
||||
wuffs_base__rect_ie_u32 have = wuffs_base__frame_config__bounds(&fc);
|
||||
wuffs_base__rect_ie_u32 want = want_frame_config_bounds[i];
|
||||
if (!wuffs_base__rect_ie_u32__equals(&got, want)) {
|
||||
RETURN_FAIL("decode_frame_config #%" PRIu32 ": bounds: got (%" PRIu32
|
||||
if (!wuffs_base__rect_ie_u32__equals(&have, want)) {
|
||||
RETURN_FAIL("decode_frame_config #%" PRIu32 ": bounds: have (%" PRIu32
|
||||
", %" PRIu32 ")-(%" PRIu32 ", %" PRIu32 "), want (%" PRIu32
|
||||
", %" PRIu32 ")-(%" PRIu32 ", %" PRIu32 ")",
|
||||
i, got.min_incl_x, got.min_incl_y, got.max_excl_x,
|
||||
got.max_excl_y, want.min_incl_x, want.min_incl_y,
|
||||
i, have.min_incl_x, have.min_incl_y, have.max_excl_x,
|
||||
have.max_excl_y, want.min_incl_x, want.min_incl_y,
|
||||
want.max_excl_x, want.max_excl_y);
|
||||
}
|
||||
}
|
||||
@@ -635,14 +635,14 @@ const char* do_test_wuffs_gif_decode_animated(
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, global_work_slice, NULL);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t got_num_frames = wuffs_gif__decoder__num_decoded_frames(&dec);
|
||||
if (got_num_frames != want_num_frames) {
|
||||
RETURN_FAIL("frame_count: got %" PRIu64 ", want %" PRIu32, got_num_frames,
|
||||
uint64_t have_num_frames = wuffs_gif__decoder__num_decoded_frames(&dec);
|
||||
if (have_num_frames != want_num_frames) {
|
||||
RETURN_FAIL("frame_count: have %" PRIu64 ", want %" PRIu32, have_num_frames,
|
||||
want_num_frames);
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ const char* test_wuffs_gif_decode_delay_num_frames_decoded() {
|
||||
|
||||
// A GIF image should end with the 0x3B Trailer byte.
|
||||
if (src.data.ptr[src.meta.wi - 1] != 0x3B) {
|
||||
RETURN_FAIL("final byte: got 0x%02X, want 0x%02X",
|
||||
RETURN_FAIL("final byte: have 0x%02X, want 0x%02X",
|
||||
src.data.ptr[src.meta.wi - 1], 0x3B);
|
||||
}
|
||||
// Replace that final byte with something invalid: neither 0x21 (Extension
|
||||
@@ -718,11 +718,11 @@ const char* test_wuffs_gif_decode_delay_num_frames_decoded() {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t got = wuffs_gif__decoder__num_decoded_frames(&dec);
|
||||
uint64_t have = wuffs_gif__decoder__num_decoded_frames(&dec);
|
||||
uint64_t want = q ? 3 : 4;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("q=%d: num_decoded_frames: got %" PRIu64 ", want %" PRIu64, q,
|
||||
got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("q=%d: num_decoded_frames: have %" PRIu64 ", want %" PRIu64,
|
||||
q, have, want);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -767,8 +767,8 @@ const char* test_wuffs_gif_decode_empty_palette() {
|
||||
global_work_slice, NULL);
|
||||
if ((q == 1) && (i == 1)) {
|
||||
if (status.repr != wuffs_gif__error__bad_palette) {
|
||||
RETURN_FAIL("q=%d: i=%d: decode_frame: got \"%s\", want \"%s\"", q, i,
|
||||
status.repr, wuffs_gif__error__bad_palette);
|
||||
RETURN_FAIL("q=%d: i=%d: decode_frame: have \"%s\", want \"%s\"", q,
|
||||
i, status.repr, wuffs_gif__error__bad_palette);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -778,7 +778,7 @@ const char* test_wuffs_gif_decode_empty_palette() {
|
||||
|
||||
wuffs_base__slice_u8 pal = wuffs_base__pixel_buffer__palette(&pb);
|
||||
if (pal.len < 4) {
|
||||
RETURN_FAIL("q=%d: i=%d: palette length: got %d, want >= 4", q, i,
|
||||
RETURN_FAIL("q=%d: i=%d: palette length: have %d, want >= 4", q, i,
|
||||
(int)(pal.len));
|
||||
}
|
||||
uint8_t* p = pal.ptr;
|
||||
@@ -786,7 +786,7 @@ const char* test_wuffs_gif_decode_empty_palette() {
|
||||
if ((p[0] != blue) || (p[1] != 0x00) || (p[2] != 0x00) ||
|
||||
(p[3] != 0xFF)) {
|
||||
RETURN_FAIL(
|
||||
"q=%d: i=%d: palette[0] BGRA: got (0x%02X, 0x%02X, 0x%02X, "
|
||||
"q=%d: i=%d: palette[0] BGRA: have (0x%02X, 0x%02X, 0x%02X, "
|
||||
"0x%02X), want (0x%02X, 0x00, 0x00, 0xFF)",
|
||||
q, i, (int)(p[0]), (int)(p[1]), (int)(p[2]), (int)(p[3]), blue);
|
||||
}
|
||||
@@ -821,12 +821,13 @@ const char* test_wuffs_gif_decode_background_color() {
|
||||
RETURN_FAIL("q=%d: decode_frame_config: \"%s\"", q, status.repr);
|
||||
}
|
||||
|
||||
wuffs_base__color_u32_argb_premul got =
|
||||
wuffs_base__color_u32_argb_premul have =
|
||||
wuffs_base__frame_config__background_color(&fc);
|
||||
wuffs_base__color_u32_argb_premul want = q ? 0xFF80C3C3 : 0x00000000;
|
||||
|
||||
if (got != want) {
|
||||
RETURN_FAIL("q=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32, q, got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("q=%d: have 0x%08" PRIX32 ", want 0x%08" PRIX32, q, have,
|
||||
want);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -858,11 +859,11 @@ const char* test_wuffs_gif_decode_first_frame_is_opaque() {
|
||||
RETURN_FAIL("q=%d: decode_image_config: \"%s\"", q, status.repr);
|
||||
}
|
||||
|
||||
bool got = wuffs_base__image_config__first_frame_is_opaque(&ic);
|
||||
bool have = wuffs_base__image_config__first_frame_is_opaque(&ic);
|
||||
bool want = q;
|
||||
|
||||
if (got != want) {
|
||||
RETURN_FAIL("q=%d: got %s, want %s", q, got ? "true" : "false",
|
||||
if (have != want) {
|
||||
RETURN_FAIL("q=%d: have %s, want %s", q, have ? "true" : "false",
|
||||
want ? "true" : "false");
|
||||
}
|
||||
}
|
||||
@@ -904,11 +905,11 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
const uint32_t height = 2;
|
||||
|
||||
if (wuffs_base__pixel_config__width(&ic.pixcfg) != width) {
|
||||
RETURN_FAIL("q=%d: width: got %" PRIu32 ", want %" PRIu32, q,
|
||||
RETURN_FAIL("q=%d: width: have %" PRIu32 ", want %" PRIu32, q,
|
||||
wuffs_base__pixel_config__width(&ic.pixcfg), width);
|
||||
}
|
||||
if (wuffs_base__pixel_config__height(&ic.pixcfg) != height) {
|
||||
RETURN_FAIL("q=%d: height: got %" PRIu32 ", want %" PRIu32, q,
|
||||
RETURN_FAIL("q=%d: height: have %" PRIu32 ", want %" PRIu32, q,
|
||||
wuffs_base__pixel_config__height(&ic.pixcfg), height);
|
||||
}
|
||||
|
||||
@@ -948,7 +949,7 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
if (i == WUFFS_TESTLIB_ARRAY_SIZE(want_frame_config_bounds)) {
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("q=%d: decode_frame_config #%" PRIu32
|
||||
": got \"%s\", want \"%s\"",
|
||||
": have \"%s\", want \"%s\"",
|
||||
q, i, status.repr, wuffs_base__note__end_of_data);
|
||||
}
|
||||
break;
|
||||
@@ -958,15 +959,15 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
status.repr);
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 got = wuffs_base__frame_config__bounds(&fc);
|
||||
wuffs_base__rect_ie_u32 have = wuffs_base__frame_config__bounds(&fc);
|
||||
wuffs_base__rect_ie_u32 want = want_frame_config_bounds[i];
|
||||
if (!wuffs_base__rect_ie_u32__equals(&got, want)) {
|
||||
if (!wuffs_base__rect_ie_u32__equals(&have, want)) {
|
||||
RETURN_FAIL("q=%d: decode_frame_config #%" PRIu32
|
||||
": bounds: got (%" PRIu32 ", %" PRIu32 ")-(%" PRIu32
|
||||
": bounds: have (%" PRIu32 ", %" PRIu32 ")-(%" PRIu32
|
||||
", %" PRIu32 "), want (%" PRIu32 ", %" PRIu32
|
||||
")-(%" PRIu32 ", %" PRIu32 ")",
|
||||
q, i, got.min_incl_x, got.min_incl_y, got.max_excl_x,
|
||||
got.max_excl_y, want.min_incl_x, want.min_incl_y,
|
||||
q, i, have.min_incl_x, have.min_incl_y, have.max_excl_x,
|
||||
have.max_excl_y, want.min_incl_x, want.min_incl_y,
|
||||
want.max_excl_x, want.max_excl_y);
|
||||
}
|
||||
}
|
||||
@@ -1017,20 +1018,20 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
q);
|
||||
}
|
||||
|
||||
char got[(width * height) + 1];
|
||||
char have[(width * height) + 1];
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
uint8_t index = 0x0F & p.ptr[(y * p.stride) + x];
|
||||
got[(y * width) + x] = index ? ('0' + index) : '.';
|
||||
have[(y * width) + x] = index ? ('0' + index) : '.';
|
||||
}
|
||||
}
|
||||
got[width * height] = 0;
|
||||
have[width * height] = 0;
|
||||
|
||||
const char* want = want_pixel_indexes[i];
|
||||
if (memcmp(got, want, width * height)) {
|
||||
if (memcmp(have, want, width * height)) {
|
||||
RETURN_FAIL("q=%d: decode_frame #%" PRIu32
|
||||
": got \"%s\", want \"%s\"",
|
||||
q, i, got, want);
|
||||
": have \"%s\", want \"%s\"",
|
||||
q, i, have, want);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1086,10 +1087,10 @@ const char* test_wuffs_gif_decode_zero_width_frame() {
|
||||
RETURN_FAIL("q=%d: set_from_slice: \"%s\"", q, status.repr);
|
||||
}
|
||||
|
||||
wuffs_base__status got = wuffs_gif__decoder__decode_frame(
|
||||
wuffs_base__status have = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, global_work_slice, NULL);
|
||||
if (got.repr != want) {
|
||||
RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, got.repr,
|
||||
if (have.repr != want) {
|
||||
RETURN_FAIL("q=%d: decode_frame: have \"%s\", want \"%s\"", q, have.repr,
|
||||
want);
|
||||
}
|
||||
}
|
||||
@@ -1193,7 +1194,7 @@ const char* test_wuffs_gif_decode_input_is_a_png() {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, &src);
|
||||
if (status.repr != wuffs_gif__error__bad_header) {
|
||||
RETURN_FAIL("decode_image_config: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_image_config: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_gif__error__bad_header);
|
||||
}
|
||||
return NULL;
|
||||
@@ -1217,16 +1218,16 @@ const char* test_wuffs_gif_decode_interlaced_truncated() {
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, &src));
|
||||
if (wuffs_base__pixel_config__width(&ic.pixcfg) != 36) {
|
||||
RETURN_FAIL("width: got %" PRIu32 ", want 36",
|
||||
RETURN_FAIL("width: have %" PRIu32 ", want 36",
|
||||
wuffs_base__pixel_config__width(&ic.pixcfg));
|
||||
}
|
||||
if (wuffs_base__pixel_config__height(&ic.pixcfg) != 28) {
|
||||
RETURN_FAIL("height: got %" PRIu32 ", want 28",
|
||||
RETURN_FAIL("height: have %" PRIu32 ", want 28",
|
||||
wuffs_base__pixel_config__height(&ic.pixcfg));
|
||||
}
|
||||
if (wuffs_base__pixel_config__pixel_format(&ic.pixcfg).repr !=
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
RETURN_FAIL("pixel_format: got 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
RETURN_FAIL("pixel_format: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
wuffs_base__pixel_config__pixel_format(&ic.pixcfg).repr,
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY);
|
||||
}
|
||||
@@ -1239,27 +1240,27 @@ const char* test_wuffs_gif_decode_interlaced_truncated() {
|
||||
memset(pixel_ptr, 0xEE, num_pixel_indexes);
|
||||
|
||||
if (pixel_ptr[num_pixel_indexes - 1] != 0xEE) {
|
||||
RETURN_FAIL("final pixel index, before: got 0x%02X, want 0x%02X",
|
||||
RETURN_FAIL("final pixel index, before: have 0x%02X, want 0x%02X",
|
||||
pixel_ptr[num_pixel_indexes - 1], 0xEE);
|
||||
}
|
||||
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, global_work_slice, NULL);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
// Even though the source GIF data was truncated, replicating the interlaced
|
||||
// rows should have set the bottom right pixel.
|
||||
if (pixel_ptr[num_pixel_indexes - 1] == 0xEE) {
|
||||
RETURN_FAIL("final pixel index, after: got 0x%02X, want not 0x%02X",
|
||||
RETURN_FAIL("final pixel index, after: have 0x%02X, want not 0x%02X",
|
||||
pixel_ptr[num_pixel_indexes - 1], 0xEE);
|
||||
}
|
||||
|
||||
wuffs_base__rect_ie_u32 r = wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||
if (r.max_excl_y != 28) {
|
||||
RETURN_FAIL("frame_dirty_rect max_excl_y: got %" PRIu32 ", want 28",
|
||||
RETURN_FAIL("frame_dirty_rect max_excl_y: have %" PRIu32 ", want 28",
|
||||
r.max_excl_y);
|
||||
}
|
||||
return NULL;
|
||||
@@ -1305,14 +1306,14 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
break;
|
||||
} else if (status.repr != wuffs_base__note__metadata_reported) {
|
||||
RETURN_FAIL(
|
||||
"decode_image_config (iccp=%d, xmp=%d): got \"%s\", want \"%s\"",
|
||||
"decode_image_config (iccp=%d, xmp=%d): have \"%s\", want \"%s\"",
|
||||
iccp, xmp, status.repr, wuffs_base__note__metadata_reported);
|
||||
}
|
||||
|
||||
const char* want = "";
|
||||
char got_buffer[100];
|
||||
int got_length = 0;
|
||||
uint32_t got_fourcc = wuffs_gif__decoder__metadata_fourcc(&dec);
|
||||
char have_buffer[100];
|
||||
int have_length = 0;
|
||||
uint32_t have_fourcc = wuffs_gif__decoder__metadata_fourcc(&dec);
|
||||
|
||||
switch (wuffs_gif__decoder__metadata_fourcc(&dec)) {
|
||||
case WUFFS_BASE__FOURCC__ICCP:
|
||||
@@ -1327,12 +1328,12 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
RETURN_FAIL(
|
||||
"metadata_fourcc (iccp=%d, xmp=%d): unexpected FourCC "
|
||||
"0x%08" PRIX32,
|
||||
iccp, xmp, got_fourcc);
|
||||
iccp, xmp, have_fourcc);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
uint64_t n = wuffs_gif__decoder__metadata_chunk_length(&dec);
|
||||
if ((n > 100) || (n + got_length > 100)) {
|
||||
if ((n > 100) || (n + have_length > 100)) {
|
||||
RETURN_FAIL(
|
||||
"metadata_chunk_length (iccp=%d, xmp=%d): too much "
|
||||
"metadata (vs buffer size)",
|
||||
@@ -1344,8 +1345,8 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
"metadata (vs available)",
|
||||
iccp, xmp);
|
||||
}
|
||||
memcpy(got_buffer + got_length, src.data.ptr + src.meta.ri, n);
|
||||
got_length += n;
|
||||
memcpy(have_buffer + have_length, src.data.ptr + src.meta.ri, n);
|
||||
have_length += n;
|
||||
src.meta.ri += n;
|
||||
|
||||
wuffs_base__status status =
|
||||
@@ -1354,45 +1355,47 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
break;
|
||||
} else if (status.repr != wuffs_base__note__metadata_reported) {
|
||||
RETURN_FAIL(
|
||||
"ack_metadata_chunk (iccp=%d, xmp=%d): got \"%s\", want \"%s\"",
|
||||
"ack_metadata_chunk (iccp=%d, xmp=%d): have \"%s\", want "
|
||||
"\"%s\"",
|
||||
iccp, xmp, status.repr, wuffs_base__note__metadata_reported);
|
||||
}
|
||||
}
|
||||
|
||||
int want_length = strlen(want);
|
||||
if ((got_length != want_length) ||
|
||||
strncmp(got_buffer, want, want_length)) {
|
||||
if ((have_length != want_length) ||
|
||||
strncmp(have_buffer, want, want_length)) {
|
||||
RETURN_FAIL("metadata (iccp=%d, xmp=%d): fourcc=0x%08" PRIX32
|
||||
": values differed",
|
||||
iccp, xmp, got_fourcc);
|
||||
iccp, xmp, have_fourcc);
|
||||
}
|
||||
}
|
||||
|
||||
if (iccp != seen_iccp) {
|
||||
RETURN_FAIL("seen_iccp (iccp=%d, xmp=%d): got %d, want %d", iccp, xmp,
|
||||
RETURN_FAIL("seen_iccp (iccp=%d, xmp=%d): have %d, want %d", iccp, xmp,
|
||||
seen_iccp, iccp);
|
||||
}
|
||||
|
||||
if (xmp != seen_xmp) {
|
||||
RETURN_FAIL("seen_xmp (iccp=%d, xmp=%d): got %d, want %d", iccp, xmp,
|
||||
RETURN_FAIL("seen_xmp (iccp=%d, xmp=%d): have %d, want %d", iccp, xmp,
|
||||
seen_xmp, xmp);
|
||||
}
|
||||
|
||||
{
|
||||
uint64_t got = wuffs_base__image_config__first_frame_io_position(&ic);
|
||||
uint64_t have = wuffs_base__image_config__first_frame_io_position(&ic);
|
||||
uint64_t want = 25;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("first_frame_io_position: got %" PRIu64 ", want %" PRIu64,
|
||||
got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("first_frame_io_position: have %" PRIu64
|
||||
", want %" PRIu64,
|
||||
have, want);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t got = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t want = 2001;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("num_animation_loops: got %" PRIu32 ", want %" PRIu32,
|
||||
got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want %" PRIu32,
|
||||
have, want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1404,13 +1407,13 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
RETURN_FAIL("decode_frame_config (iccp=%d, xmp=%d): %s", iccp, xmp,
|
||||
status.repr);
|
||||
}
|
||||
uint32_t got = wuffs_base__frame_config__width(&fc);
|
||||
uint32_t have = wuffs_base__frame_config__width(&fc);
|
||||
uint32_t want = 1;
|
||||
if (got != want) {
|
||||
if (have != want) {
|
||||
RETURN_FAIL(
|
||||
"decode_frame_config (iccp=%d, xmp=%d): width: got %" PRIu32
|
||||
"decode_frame_config (iccp=%d, xmp=%d): width: have %" PRIu32
|
||||
", want %" PRIu32,
|
||||
iccp, xmp, got, want);
|
||||
iccp, xmp, have, want);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1463,11 +1466,11 @@ const char* test_wuffs_gif_decode_multiple_graphic_controls() {
|
||||
CHECK_STATUS("decode_frame_config",
|
||||
wuffs_gif__decoder__decode_frame_config(&dec, &fc, &src));
|
||||
|
||||
int got = wuffs_base__frame_config__duration(&fc) /
|
||||
WUFFS_BASE__FLICKS_PER_MILLISECOND;
|
||||
int have = wuffs_base__frame_config__duration(&fc) /
|
||||
WUFFS_BASE__FLICKS_PER_MILLISECOND;
|
||||
int want = 300;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("duration: got %d, want %d", got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("duration: have %d, want %d", have, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1504,7 +1507,7 @@ const char* test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
if (i == WUFFS_TESTLIB_ARRAY_SIZE(want_num_animation_loops)) {
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config #%" PRIu32
|
||||
": got \"%s\", want \"%s\"",
|
||||
": have \"%s\", want \"%s\"",
|
||||
i, status.repr, wuffs_base__note__end_of_data);
|
||||
}
|
||||
break;
|
||||
@@ -1514,21 +1517,21 @@ const char* test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t got = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t want = want_num_animation_loops[i];
|
||||
if (got != want) {
|
||||
RETURN_FAIL("num_animation_loops #%" PRIu32 ": got %" PRIu32
|
||||
if (have != want) {
|
||||
RETURN_FAIL("num_animation_loops #%" PRIu32 ": have %" PRIu32
|
||||
", want %" PRIu32,
|
||||
i, got, want);
|
||||
i, have, want);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t got = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t want = 41;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("num_animation_loops #%" PRIu32 ": got %" PRIu32
|
||||
if (have != want) {
|
||||
RETURN_FAIL("num_animation_loops #%" PRIu32 ": have %" PRIu32
|
||||
", want %" PRIu32,
|
||||
i, got, want);
|
||||
i, have, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1626,13 +1629,13 @@ const char* test_wuffs_gif_frame_dirty_rect() {
|
||||
if (wuffs_base__status__is_ok(&status)) {
|
||||
break;
|
||||
} else if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_frame: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
}
|
||||
|
||||
if (i != WUFFS_TESTLIB_ARRAY_SIZE(wants)) {
|
||||
RETURN_FAIL("i: got %d, want %d", i,
|
||||
RETURN_FAIL("i: have %d, want %d", i,
|
||||
(int)(WUFFS_TESTLIB_ARRAY_SIZE(wants)));
|
||||
}
|
||||
return NULL;
|
||||
@@ -1664,12 +1667,13 @@ const char* do_test_wuffs_gif_num_decoded(bool frame_config) {
|
||||
bool end_of_data = false;
|
||||
uint64_t want = 0;
|
||||
while (true) {
|
||||
uint64_t got =
|
||||
uint64_t have =
|
||||
frame_config
|
||||
? (uint64_t)(wuffs_gif__decoder__num_decoded_frame_configs(&dec))
|
||||
: (uint64_t)(wuffs_gif__decoder__num_decoded_frames(&dec));
|
||||
if (got != want) {
|
||||
RETURN_FAIL("num_%ss: got %" PRIu64 ", want %" PRIu64, method, got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("num_%ss: have %" PRIu64 ", want %" PRIu64, method, have,
|
||||
want);
|
||||
}
|
||||
|
||||
if (end_of_data) {
|
||||
@@ -1690,13 +1694,13 @@ const char* do_test_wuffs_gif_num_decoded(bool frame_config) {
|
||||
} else if (status.repr == wuffs_base__note__end_of_data) {
|
||||
end_of_data = true;
|
||||
} else {
|
||||
RETURN_FAIL("%s: got \"%s\", want \"%s\"", method, status.repr,
|
||||
RETURN_FAIL("%s: have \"%s\", want \"%s\"", method, status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
}
|
||||
|
||||
if (want != 4) {
|
||||
RETURN_FAIL("%s: got %" PRIu64 ", want 4", method, want);
|
||||
RETURN_FAIL("%s: have %" PRIu64 ", want 4", method, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1735,7 +1739,7 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("decode_image_config (chunked): got \"%s\", want \"%s\"",
|
||||
RETURN_FAIL("decode_image_config (chunked): have \"%s\", want \"%s\"",
|
||||
status.repr, wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
@@ -1743,11 +1747,12 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
src.meta.closed = saved_closed;
|
||||
|
||||
if (src.meta.pos != 0) {
|
||||
RETURN_FAIL("src.meta.pos: got %" PRIu64 ", want zero", src.meta.pos);
|
||||
RETURN_FAIL("src.meta.pos: have %" PRIu64 ", want zero", src.meta.pos);
|
||||
}
|
||||
wuffs_base__io_buffer__compact(&src);
|
||||
if (src.meta.pos == 0) {
|
||||
RETURN_FAIL("src.meta.pos: got %" PRIu64 ", want non-zero", src.meta.pos);
|
||||
RETURN_FAIL("src.meta.pos: have %" PRIu64 ", want non-zero",
|
||||
src.meta.pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1766,42 +1771,42 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
RETURN_FAIL("decode_frame_config #%d: \"%s\"", i, status.repr);
|
||||
}
|
||||
|
||||
uint64_t index_got = wuffs_base__frame_config__index(&fcs[i]);
|
||||
uint64_t index_have = wuffs_base__frame_config__index(&fcs[i]);
|
||||
uint64_t index_want = i;
|
||||
if (index_got != index_want) {
|
||||
RETURN_FAIL("index #%d: got %" PRIu64 ", want %" PRIu64, i, index_got,
|
||||
if (index_have != index_want) {
|
||||
RETURN_FAIL("index #%d: have %" PRIu64 ", want %" PRIu64, i, index_have,
|
||||
index_want);
|
||||
}
|
||||
|
||||
uint32_t width_got = wuffs_base__frame_config__width(&fcs[i]);
|
||||
uint32_t width_have = wuffs_base__frame_config__width(&fcs[i]);
|
||||
uint32_t width_want = width_wants[i];
|
||||
if (width_got != width_want) {
|
||||
RETURN_FAIL("width #%d: got %" PRIu32 ", want %" PRIu32, i, width_got,
|
||||
if (width_have != width_want) {
|
||||
RETURN_FAIL("width #%d: have %" PRIu32 ", want %" PRIu32, i, width_have,
|
||||
width_want);
|
||||
}
|
||||
|
||||
uint64_t pos_got = wuffs_base__frame_config__io_position(&fcs[i]);
|
||||
uint64_t pos_have = wuffs_base__frame_config__io_position(&fcs[i]);
|
||||
uint64_t pos_want = pos_wants[i];
|
||||
if (pos_got != pos_want) {
|
||||
RETURN_FAIL("io_position #%d: got %" PRIu64 ", want %" PRIu64, i, pos_got,
|
||||
pos_want);
|
||||
if (pos_have != pos_want) {
|
||||
RETURN_FAIL("io_position #%d: have %" PRIu64 ", want %" PRIu64, i,
|
||||
pos_have, pos_want);
|
||||
}
|
||||
|
||||
// Look for the 0x21 byte that's a GIF's Extension Introducer. Not every
|
||||
// GIF's frame_config's I/O position will point to 0x21, as an 0x2C Image
|
||||
// Separator is also valid. But for animated-red-blue.gif, it'll be 0x21.
|
||||
if (pos_got < src.meta.pos) {
|
||||
RETURN_FAIL("io_position #%d: got %" PRIu64 ", was too small", i,
|
||||
pos_got);
|
||||
if (pos_have < src.meta.pos) {
|
||||
RETURN_FAIL("io_position #%d: have %" PRIu64 ", was too small", i,
|
||||
pos_have);
|
||||
}
|
||||
uint64_t src_ptr_offset = pos_got - src.meta.pos;
|
||||
uint64_t src_ptr_offset = pos_have - src.meta.pos;
|
||||
if (src_ptr_offset >= src.meta.wi) {
|
||||
RETURN_FAIL("io_position #%d: got %" PRIu64 ", was too large", i,
|
||||
pos_got);
|
||||
RETURN_FAIL("io_position #%d: have %" PRIu64 ", was too large", i,
|
||||
pos_have);
|
||||
}
|
||||
uint8_t x = src.data.ptr[src_ptr_offset];
|
||||
if (x != 0x21) {
|
||||
RETURN_FAIL("Image Descriptor byte #%d: got 0x%02X, want 0x2C", i,
|
||||
RETURN_FAIL("Image Descriptor byte #%d: have 0x%02X, want 0x2C", i,
|
||||
(int)x);
|
||||
}
|
||||
}
|
||||
@@ -1809,8 +1814,8 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_frame_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config EOD: got \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
RETURN_FAIL("decode_frame_config EOD: have \"%s\", want \"%s\"",
|
||||
status.repr, wuffs_base__note__end_of_data);
|
||||
}
|
||||
|
||||
// If we're chunked, we've discarded some source bytes due to an earlier
|
||||
@@ -1837,24 +1842,24 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
RETURN_FAIL("decode_frame_config #%d, #%d: \"%s\"", i, j, status.repr);
|
||||
}
|
||||
|
||||
uint64_t index_got = wuffs_base__frame_config__index(&fc);
|
||||
uint64_t index_have = wuffs_base__frame_config__index(&fc);
|
||||
uint64_t index_want = j;
|
||||
if (index_got != index_want) {
|
||||
RETURN_FAIL("index #%d, #%d: got %" PRIu64 ", want %" PRIu64, i, j,
|
||||
index_got, index_want);
|
||||
if (index_have != index_want) {
|
||||
RETURN_FAIL("index #%d, #%d: have %" PRIu64 ", want %" PRIu64, i, j,
|
||||
index_have, index_want);
|
||||
}
|
||||
|
||||
uint32_t width_got = wuffs_base__frame_config__width(&fc);
|
||||
uint32_t width_have = wuffs_base__frame_config__width(&fc);
|
||||
uint32_t width_want = width_wants[j];
|
||||
if (width_got != width_want) {
|
||||
RETURN_FAIL("width #%d, #%d: got %" PRIu32 ", want %" PRIu32, i, j,
|
||||
width_got, width_want);
|
||||
if (width_have != width_want) {
|
||||
RETURN_FAIL("width #%d, #%d: have %" PRIu32 ", want %" PRIu32, i, j,
|
||||
width_have, width_want);
|
||||
}
|
||||
}
|
||||
|
||||
status = wuffs_gif__decoder__decode_frame_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config #%d: got \"%s\", want \"%s\"", i,
|
||||
RETURN_FAIL("decode_frame_config #%d: have \"%s\", want \"%s\"", i,
|
||||
status.repr, wuffs_base__note__end_of_data);
|
||||
}
|
||||
}
|
||||
@@ -1890,11 +1895,11 @@ const char* test_wuffs_gif_small_frame_interlaced() {
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_gif__decoder__decode_image_config(&dec, &ic, &src));
|
||||
if (wuffs_base__pixel_config__width(&ic.pixcfg) != 5) {
|
||||
RETURN_FAIL("width: got %" PRIu32 ", want 5",
|
||||
RETURN_FAIL("width: have %" PRIu32 ", want 5",
|
||||
wuffs_base__pixel_config__width(&ic.pixcfg));
|
||||
}
|
||||
if (wuffs_base__pixel_config__height(&ic.pixcfg) != 5) {
|
||||
RETURN_FAIL("height: got %" PRIu32 ", want 5",
|
||||
RETURN_FAIL("height: have %" PRIu32 ", want 5",
|
||||
wuffs_base__pixel_config__height(&ic.pixcfg));
|
||||
}
|
||||
|
||||
@@ -1908,7 +1913,7 @@ const char* test_wuffs_gif_small_frame_interlaced() {
|
||||
|
||||
wuffs_base__rect_ie_u32 fr = wuffs_base__frame_config__bounds(&fc);
|
||||
if (fr.max_excl_y != 3) {
|
||||
RETURN_FAIL("frame rect max_excl_y: got %" PRIu32 ", want 3",
|
||||
RETURN_FAIL("frame rect max_excl_y: have %" PRIu32 ", want 3",
|
||||
fr.max_excl_y);
|
||||
}
|
||||
|
||||
@@ -1919,7 +1924,7 @@ const char* test_wuffs_gif_small_frame_interlaced() {
|
||||
|
||||
wuffs_base__rect_ie_u32 dr = wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||
if (dr.max_excl_y != 3) {
|
||||
RETURN_FAIL("dirty rect max_excl_y: got %" PRIu32 ", want 3",
|
||||
RETURN_FAIL("dirty rect max_excl_y: have %" PRIu32 ", want 3",
|
||||
dr.max_excl_y);
|
||||
}
|
||||
|
||||
@@ -1951,11 +1956,11 @@ const char* do_test_mimic_gif_decode(const char* filename) {
|
||||
CHECK_STRING(read_file(&src, filename));
|
||||
|
||||
src.meta.ri = 0;
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
CHECK_STRING(
|
||||
wuffs_gif_decode(&got, 0,
|
||||
wuffs_gif_decode(&have, 0,
|
||||
wuffs_base__make_pixel_format(
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY),
|
||||
&src));
|
||||
@@ -1970,7 +1975,7 @@ const char* do_test_mimic_gif_decode(const char* filename) {
|
||||
WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY),
|
||||
&src));
|
||||
|
||||
CHECK_STRING(check_io_buffers_equal("", &got, &want));
|
||||
CHECK_STRING(check_io_buffers_equal("", &have, &want));
|
||||
|
||||
// TODO: check the palette RGB values, not just the palette indexes
|
||||
// (pixels).
|
||||
@@ -2056,8 +2061,8 @@ const char* do_bench_gif_decode(
|
||||
const char* filename,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
uint64_t iters_unscaled) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -2069,10 +2074,10 @@ const char* do_bench_gif_decode(
|
||||
uint64_t i;
|
||||
uint64_t iters = iters_unscaled * iterscale;
|
||||
for (i = 0; i < iters; i++) {
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
CHECK_STRING(decode_func(&got, wuffs_initialize_flags, pixfmt, &src));
|
||||
n_bytes += got.meta.wi;
|
||||
CHECK_STRING(decode_func(&have, wuffs_initialize_flags, pixfmt, &src));
|
||||
n_bytes += have.meta.wi;
|
||||
}
|
||||
bench_finish(iters, n_bytes);
|
||||
return NULL;
|
||||
|
||||
+8
-8
@@ -127,8 +127,8 @@ const char* wuffs_gzip_decode(wuffs_base__io_buffer* dst,
|
||||
|
||||
const char* do_test_wuffs_gzip_checksum(bool ignore_checksum,
|
||||
uint32_t bad_checksum) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -152,7 +152,7 @@ const char* do_test_wuffs_gzip_checksum(bool ignore_checksum,
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
wuffs_gzip__decoder__set_ignore_checksum(&dec, ignore_checksum);
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
|
||||
// Decode the src data in 1 or 2 chunks, depending on whether end_limit is
|
||||
@@ -177,12 +177,12 @@ const char* do_test_wuffs_gzip_checksum(bool ignore_checksum,
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer limited_src = make_limited_reader(src, rlimit);
|
||||
wuffs_base__status got_z = wuffs_gzip__decoder__transform_io(
|
||||
&dec, &got, &limited_src, global_work_slice);
|
||||
wuffs_base__status have_z = wuffs_gzip__decoder__transform_io(
|
||||
&dec, &have, &limited_src, global_work_slice);
|
||||
src.meta.ri += limited_src.meta.ri;
|
||||
if (got_z.repr != want_z) {
|
||||
RETURN_FAIL("end_limit=%d: got \"%s\", want \"%s\"", end_limit,
|
||||
got_z.repr, want_z);
|
||||
if (have_z.repr != want_z) {
|
||||
RETURN_FAIL("end_limit=%d: have \"%s\", want \"%s\"", end_limit,
|
||||
have_z.repr, want_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -138,10 +138,10 @@ const char* test_strconv_parse_number_u64() {
|
||||
wuffs_base__result_u64 r =
|
||||
wuffs_base__parse_number_u64(wuffs_base__make_slice_u8(
|
||||
(void*)test_cases[i].str, strlen(test_cases[i].str)));
|
||||
uint64_t got = (r.status.repr == NULL) ? r.value : fail;
|
||||
if (got != test_cases[i].want) {
|
||||
RETURN_FAIL("\"%s\": got 0x%" PRIX64 ", want 0x%" PRIX64,
|
||||
test_cases[i].str, got, test_cases[i].want);
|
||||
uint64_t have = (r.status.repr == NULL) ? r.value : fail;
|
||||
if (have != test_cases[i].want) {
|
||||
RETURN_FAIL("\"%s\": have 0x%" PRIX64 ", want 0x%" PRIX64,
|
||||
test_cases[i].str, have, test_cases[i].want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ const char* test_wuffs_json_decode_tokens() {
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__token_buffer got = ((wuffs_base__token_buffer){
|
||||
.data = global_got_token_slice,
|
||||
wuffs_base__token_buffer have = ((wuffs_base__token_buffer){
|
||||
.data = global_have_token_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -167,12 +167,12 @@ const char* test_wuffs_json_decode_tokens() {
|
||||
CHECK_STRING(read_file(&src, "test/data/github-tags.json"));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_json__decoder__decode_tokens(&dec, &got, &src);
|
||||
wuffs_json__decoder__decode_tokens(&dec, &have, &src);
|
||||
if (0) {
|
||||
uint64_t pos = 0;
|
||||
size_t i;
|
||||
for (i = got.meta.ri; i < got.meta.wi; i++) {
|
||||
wuffs_base__token* t = &got.data.ptr[i];
|
||||
for (i = have.meta.ri; i < have.meta.wi; i++) {
|
||||
wuffs_base__token* t = &have.data.ptr[i];
|
||||
uint64_t len = wuffs_base__token__length(t);
|
||||
uint64_t bc = wuffs_base__token__value_base_category(t);
|
||||
uint64_t bd = wuffs_base__token__value_base_detail(t);
|
||||
|
||||
+40
-40
@@ -84,8 +84,8 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
uint64_t want_size,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
@@ -96,20 +96,20 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
|
||||
CHECK_STRING(read_file(&src, src_filename));
|
||||
if (src.meta.wi != src_size) {
|
||||
RETURN_FAIL("src size: got %d, want %d", (int)(src.meta.wi),
|
||||
RETURN_FAIL("src size: have %d, want %d", (int)(src.meta.wi),
|
||||
(int)(src_size));
|
||||
}
|
||||
// The first byte in that file, the LZW literal width, should be 0x08.
|
||||
uint8_t literal_width = src.data.ptr[0];
|
||||
if (literal_width != 0x08) {
|
||||
RETURN_FAIL("LZW literal width: got %d, want %d", (int)(src.data.ptr[0]),
|
||||
RETURN_FAIL("LZW literal width: have %d, want %d", (int)(src.data.ptr[0]),
|
||||
0x08);
|
||||
}
|
||||
src.meta.ri++;
|
||||
|
||||
CHECK_STRING(read_file(&want, want_filename));
|
||||
if (want.meta.wi != want_size) {
|
||||
RETURN_FAIL("want size: got %d, want %d", (int)(want.meta.wi),
|
||||
RETURN_FAIL("want size: have %d, want %d", (int)(want.meta.wi),
|
||||
(int)(want_size));
|
||||
}
|
||||
|
||||
@@ -122,14 +122,14 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
int num_iters = 0;
|
||||
while (true) {
|
||||
num_iters++;
|
||||
wuffs_base__io_buffer limited_got = make_limited_writer(got, wlimit);
|
||||
wuffs_base__io_buffer limited_have = make_limited_writer(have, wlimit);
|
||||
wuffs_base__io_buffer limited_src = make_limited_reader(src, rlimit);
|
||||
size_t old_wi = got.meta.wi;
|
||||
size_t old_wi = have.meta.wi;
|
||||
size_t old_ri = src.meta.ri;
|
||||
|
||||
wuffs_base__status status = wuffs_lzw__decoder__transform_io(
|
||||
&dec, &limited_got, &limited_src, global_work_slice);
|
||||
got.meta.wi += limited_got.meta.wi;
|
||||
&dec, &limited_have, &limited_src, global_work_slice);
|
||||
have.meta.wi += limited_have.meta.wi;
|
||||
src.meta.ri += limited_src.meta.ri;
|
||||
if (wuffs_base__status__is_ok(&status)) {
|
||||
if (src.meta.ri != src.meta.wi) {
|
||||
@@ -139,33 +139,33 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
}
|
||||
if ((status.repr != wuffs_base__suspension__short_read) &&
|
||||
(status.repr != wuffs_base__suspension__short_write)) {
|
||||
RETURN_FAIL("transform_io: got \"%s\", want \"%s\" or \"%s\"",
|
||||
RETURN_FAIL("transform_io: have \"%s\", want \"%s\" or \"%s\"",
|
||||
status.repr, wuffs_base__suspension__short_read,
|
||||
wuffs_base__suspension__short_write);
|
||||
}
|
||||
|
||||
if (got.meta.wi < old_wi) {
|
||||
RETURN_FAIL("write index got.wi went backwards");
|
||||
if (have.meta.wi < old_wi) {
|
||||
RETURN_FAIL("write index have.wi went backwards");
|
||||
}
|
||||
if (src.meta.ri < old_ri) {
|
||||
RETURN_FAIL("read index src.ri went backwards");
|
||||
}
|
||||
if ((got.meta.wi == old_wi) && (src.meta.ri == old_ri)) {
|
||||
if ((have.meta.wi == old_wi) && (src.meta.ri == old_ri)) {
|
||||
RETURN_FAIL("no progress was made");
|
||||
}
|
||||
}
|
||||
|
||||
if ((wlimit < UINT64_MAX) || (rlimit < UINT64_MAX)) {
|
||||
if (num_iters <= 1) {
|
||||
RETURN_FAIL("num_iters: got %d, want > 1", num_iters);
|
||||
RETURN_FAIL("num_iters: have %d, want > 1", num_iters);
|
||||
}
|
||||
} else {
|
||||
if (num_iters != 1) {
|
||||
RETURN_FAIL("num_iters: got %d, want 1", num_iters);
|
||||
RETURN_FAIL("num_iters: have %d, want 1", num_iters);
|
||||
}
|
||||
}
|
||||
|
||||
return check_io_buffers_equal("", &got, &want);
|
||||
return check_io_buffers_equal("", &have, &want);
|
||||
}
|
||||
|
||||
const char* test_wuffs_lzw_decode_bricks_dither() {
|
||||
@@ -206,8 +206,8 @@ const char* test_wuffs_lzw_decode_pi() {
|
||||
const char* test_wuffs_lzw_decode_output_bad() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -234,17 +234,17 @@ const char* test_wuffs_lzw_decode_output_bad() {
|
||||
wuffs_lzw__decoder__set_literal_width(&dec, 7);
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_lzw__decoder__transform_io(&dec, &got, &src, global_work_slice);
|
||||
wuffs_lzw__decoder__transform_io(&dec, &have, &src, global_work_slice);
|
||||
if (status.repr != wuffs_lzw__error__bad_code) {
|
||||
RETURN_FAIL("transform_io: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("transform_io: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_lzw__error__bad_code);
|
||||
}
|
||||
|
||||
if (got.meta.wi != 3) {
|
||||
RETURN_FAIL("got.meta.wi: got %d, want 3", (int)(got.meta.wi));
|
||||
if (have.meta.wi != 3) {
|
||||
RETURN_FAIL("have.meta.wi: have %d, want 3", (int)(have.meta.wi));
|
||||
}
|
||||
if (src.meta.ri != 4) {
|
||||
RETURN_FAIL("src.meta.ri: got %d, want 4", (int)(src.meta.ri));
|
||||
RETURN_FAIL("src.meta.ri: have %d, want 4", (int)(src.meta.ri));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -252,8 +252,8 @@ const char* test_wuffs_lzw_decode_output_bad() {
|
||||
const char* test_wuffs_lzw_decode_output_empty() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -277,13 +277,13 @@ const char* test_wuffs_lzw_decode_output_empty() {
|
||||
wuffs_lzw__decoder__set_literal_width(&dec, 8);
|
||||
|
||||
CHECK_STATUS("transform_io", wuffs_lzw__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice));
|
||||
&dec, &have, &src, global_work_slice));
|
||||
|
||||
if (got.meta.wi != 0) {
|
||||
RETURN_FAIL("got.meta.wi: got %d, want 0", (int)(got.meta.wi));
|
||||
if (have.meta.wi != 0) {
|
||||
RETURN_FAIL("have.meta.wi: have %d, want 0", (int)(have.meta.wi));
|
||||
}
|
||||
if (src.meta.ri != 2) {
|
||||
RETURN_FAIL("src.meta.ri: got %d, want 2", (int)(src.meta.ri));
|
||||
RETURN_FAIL("src.meta.ri: have %d, want 2", (int)(src.meta.ri));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -298,13 +298,13 @@ const char* do_test_wuffs_lzw_decode_width(uint32_t width,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
wuffs_lzw__decoder__set_literal_width(&dec, width);
|
||||
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
CHECK_STATUS("transform_io", wuffs_lzw__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice));
|
||||
&dec, &have, &src, global_work_slice));
|
||||
|
||||
return check_io_buffers_equal("", &got, &want);
|
||||
return check_io_buffers_equal("", &have, &want);
|
||||
}
|
||||
|
||||
// A zero literal width isn't very practical: the output bytes can only be 0x00
|
||||
@@ -374,8 +374,8 @@ const char* test_wuffs_lzw_decode_width_1() {
|
||||
|
||||
const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
uint64_t iters_unscaled) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -383,11 +383,11 @@ const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
|
||||
CHECK_STRING(read_file(&src, filename));
|
||||
if (src.meta.wi <= 0) {
|
||||
RETURN_FAIL("src size: got %d, want > 0", (int)(src.meta.wi));
|
||||
RETURN_FAIL("src size: have %d, want > 0", (int)(src.meta.wi));
|
||||
}
|
||||
uint8_t literal_width = src.data.ptr[0];
|
||||
if (literal_width != 0x08) {
|
||||
RETURN_FAIL("LZW literal width: got %d, want %d", (int)(src.data.ptr[0]),
|
||||
RETURN_FAIL("LZW literal width: have %d, want %d", (int)(src.data.ptr[0]),
|
||||
0x08);
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
uint64_t i;
|
||||
uint64_t iters = iters_unscaled * iterscale;
|
||||
for (i = 0; i < iters; i++) {
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
src.meta.ri = 1; // Skip the literal width.
|
||||
wuffs_lzw__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
@@ -404,8 +404,8 @@ const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
CHECK_STATUS("transform_io", wuffs_lzw__decoder__transform_io(
|
||||
&dec, &got, &src, global_work_slice));
|
||||
n_bytes += got.meta.wi;
|
||||
&dec, &have, &src, global_work_slice));
|
||||
n_bytes += have.meta.wi;
|
||||
}
|
||||
bench_finish(iters, n_bytes);
|
||||
return NULL;
|
||||
|
||||
+7
-7
@@ -100,7 +100,7 @@ const char* test_wuffs_wbmp_decode_frame_config() {
|
||||
wuffs_base__status status =
|
||||
wuffs_wbmp__decoder__decode_frame_config(&dec, &fc, &src);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config #1: got \"%s\", want \"%s\"", status.repr,
|
||||
RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
if (src.meta.ri != src.meta.wi) {
|
||||
@@ -126,15 +126,15 @@ const char* test_wuffs_wbmp_decode_image_config() {
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_wbmp__decoder__decode_image_config(&dec, &ic, &src));
|
||||
|
||||
uint32_t got_width = wuffs_base__pixel_config__width(&ic.pixcfg);
|
||||
uint32_t have_width = wuffs_base__pixel_config__width(&ic.pixcfg);
|
||||
uint32_t want_width = 160;
|
||||
if (got_width != want_width) {
|
||||
RETURN_FAIL("width: got %" PRIu32 ", want %" PRIu32, got_width, want_width);
|
||||
if (have_width != want_width) {
|
||||
RETURN_FAIL("width: have %" PRIu32 ", want %" PRIu32, have_width, want_width);
|
||||
}
|
||||
uint32_t got_height = wuffs_base__pixel_config__height(&ic.pixcfg);
|
||||
uint32_t have_height = wuffs_base__pixel_config__height(&ic.pixcfg);
|
||||
uint32_t want_height = 120;
|
||||
if (got_height != want_height) {
|
||||
RETURN_FAIL("height: got %" PRIu32 ", want %" PRIu32, got_height,
|
||||
if (have_height != want_height) {
|
||||
RETURN_FAIL("height: have %" PRIu32 ", want %" PRIu32, have_height,
|
||||
want_height);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
+22
-22
@@ -138,8 +138,8 @@ const char* wuffs_zlib_decode(wuffs_base__io_buffer* dst,
|
||||
|
||||
const char* do_test_wuffs_zlib_checksum(bool ignore_checksum,
|
||||
uint32_t bad_checksum) {
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
@@ -162,7 +162,7 @@ const char* do_test_wuffs_zlib_checksum(bool ignore_checksum,
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
wuffs_zlib__decoder__set_ignore_checksum(&dec, ignore_checksum);
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
|
||||
// Decode the src data in 1 or 2 chunks, depending on whether end_limit is
|
||||
@@ -188,12 +188,12 @@ const char* do_test_wuffs_zlib_checksum(bool ignore_checksum,
|
||||
|
||||
wuffs_base__io_buffer limited_src = make_limited_reader(src, rlimit);
|
||||
|
||||
wuffs_base__status got_z = wuffs_zlib__decoder__transform_io(
|
||||
&dec, &got, &limited_src, global_work_slice);
|
||||
wuffs_base__status have_z = wuffs_zlib__decoder__transform_io(
|
||||
&dec, &have, &limited_src, global_work_slice);
|
||||
src.meta.ri += limited_src.meta.ri;
|
||||
if (got_z.repr != want_z) {
|
||||
RETURN_FAIL("end_limit=%d: got \"%s\", want \"%s\"", end_limit,
|
||||
got_z.repr, want_z);
|
||||
if (have_z.repr != want_z) {
|
||||
RETURN_FAIL("end_limit=%d: have \"%s\", want \"%s\"", end_limit,
|
||||
have_z.repr, want_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,8 +234,8 @@ const char* test_wuffs_zlib_decode_pi() {
|
||||
|
||||
const char* test_wuffs_zlib_decode_sheep() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src =
|
||||
make_io_buffer_from_string(zlib_sheep_src_ptr, zlib_sheep_src_len);
|
||||
@@ -248,18 +248,18 @@ const char* test_wuffs_zlib_decode_sheep() {
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
wuffs_base__status status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &got, &src, global_work_slice);
|
||||
wuffs_zlib__decoder__transform_io(&dec, &have, &src, global_work_slice);
|
||||
|
||||
if (status.repr != wuffs_zlib__note__dictionary_required) {
|
||||
RETURN_FAIL("transform_io (before dict): got \"%s\", want \"%s\"",
|
||||
RETURN_FAIL("transform_io (before dict): have \"%s\", want \"%s\"",
|
||||
status.repr, wuffs_zlib__note__dictionary_required);
|
||||
}
|
||||
|
||||
uint32_t dict_id_got = wuffs_zlib__decoder__dictionary_id(&dec);
|
||||
uint32_t dict_id_have = wuffs_zlib__decoder__dictionary_id(&dec);
|
||||
uint32_t dict_id_want = 0x0BE0026E;
|
||||
if (dict_id_got != dict_id_want) {
|
||||
RETURN_FAIL("dictionary_id: got 0x%08" PRIX32 ", want 0x%08x" PRIX32,
|
||||
dict_id_got, dict_id_want);
|
||||
if (dict_id_have != dict_id_want) {
|
||||
RETURN_FAIL("dictionary_id: have 0x%08" PRIX32 ", want 0x%08x" PRIX32,
|
||||
dict_id_have, dict_id_want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,11 +271,11 @@ const char* test_wuffs_zlib_decode_sheep() {
|
||||
|
||||
CHECK_STATUS(
|
||||
"transform_io (after dict)",
|
||||
wuffs_zlib__decoder__transform_io(&dec, &got, &src, global_work_slice));
|
||||
wuffs_zlib__decoder__transform_io(&dec, &have, &src, global_work_slice));
|
||||
|
||||
wuffs_base__io_buffer want =
|
||||
make_io_buffer_from_string(zlib_sheep_want_ptr, zlib_sheep_want_len);
|
||||
return check_io_buffers_equal("", &got, &want);
|
||||
return check_io_buffers_equal("", &have, &want);
|
||||
}
|
||||
|
||||
// ---------------- Mimic Tests
|
||||
@@ -296,8 +296,8 @@ const char* test_mimic_zlib_decode_pi() {
|
||||
|
||||
const char* test_mimic_zlib_decode_sheep() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src =
|
||||
make_io_buffer_from_string(zlib_sheep_src_ptr, zlib_sheep_src_len);
|
||||
@@ -305,13 +305,13 @@ const char* test_mimic_zlib_decode_sheep() {
|
||||
.ptr = ((uint8_t*)(zlib_sheep_dict_ptr)),
|
||||
.len = zlib_sheep_dict_len,
|
||||
});
|
||||
const char* status = mimic_zlib_decode_with_dictionary(&got, &src, dict);
|
||||
const char* status = mimic_zlib_decode_with_dictionary(&have, &src, dict);
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
wuffs_base__io_buffer want =
|
||||
make_io_buffer_from_string(zlib_sheep_want_ptr, zlib_sheep_want_len);
|
||||
return check_io_buffers_equal("", &got, &want);
|
||||
return check_io_buffers_equal("", &have, &want);
|
||||
}
|
||||
|
||||
#endif // WUFFS_MIMIC
|
||||
|
||||
+54
-53
@@ -25,27 +25,27 @@
|
||||
|
||||
#define WUFFS_TESTLIB_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
uint8_t global_got_array[BUFFER_SIZE];
|
||||
uint8_t global_have_array[BUFFER_SIZE];
|
||||
uint8_t global_want_array[BUFFER_SIZE];
|
||||
uint8_t global_work_array[BUFFER_SIZE];
|
||||
uint8_t global_src_array[BUFFER_SIZE];
|
||||
uint8_t global_pixel_array[BUFFER_SIZE];
|
||||
|
||||
wuffs_base__token global_got_token_array[TOKEN_BUFFER_SIZE];
|
||||
wuffs_base__token global_have_token_array[TOKEN_BUFFER_SIZE];
|
||||
wuffs_base__token global_want_token_array[TOKEN_BUFFER_SIZE];
|
||||
|
||||
wuffs_base__slice_u8 global_got_slice;
|
||||
wuffs_base__slice_u8 global_have_slice;
|
||||
wuffs_base__slice_u8 global_want_slice;
|
||||
wuffs_base__slice_u8 global_work_slice;
|
||||
wuffs_base__slice_u8 global_src_slice;
|
||||
wuffs_base__slice_u8 global_pixel_slice;
|
||||
|
||||
wuffs_base__slice_token global_got_token_slice;
|
||||
wuffs_base__slice_token global_have_token_slice;
|
||||
wuffs_base__slice_token global_want_token_slice;
|
||||
|
||||
void wuffs_testlib__initialize_global_xxx_slices() {
|
||||
global_got_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_got_array,
|
||||
global_have_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_have_array,
|
||||
.len = BUFFER_SIZE,
|
||||
});
|
||||
global_want_slice = ((wuffs_base__slice_u8){
|
||||
@@ -65,8 +65,8 @@ void wuffs_testlib__initialize_global_xxx_slices() {
|
||||
.len = BUFFER_SIZE,
|
||||
});
|
||||
|
||||
global_got_token_slice = ((wuffs_base__slice_token){
|
||||
.ptr = global_got_token_array,
|
||||
global_have_token_slice = ((wuffs_base__slice_token){
|
||||
.ptr = global_have_token_array,
|
||||
.len = TOKEN_BUFFER_SIZE,
|
||||
});
|
||||
global_want_token_slice = ((wuffs_base__slice_token){
|
||||
@@ -623,30 +623,30 @@ char* hex_dump(char* msg, wuffs_base__io_buffer* buf, size_t i) {
|
||||
}
|
||||
|
||||
const char* check_io_buffers_equal(const char* prefix,
|
||||
wuffs_base__io_buffer* got,
|
||||
wuffs_base__io_buffer* have,
|
||||
wuffs_base__io_buffer* want) {
|
||||
if (!got || !want) {
|
||||
if (!have || !want) {
|
||||
RETURN_FAIL("%sio_buffers_equal: NULL argument", prefix);
|
||||
}
|
||||
char* msg = fail_msg;
|
||||
size_t i;
|
||||
size_t n = got->meta.wi < want->meta.wi ? got->meta.wi : want->meta.wi;
|
||||
size_t n = have->meta.wi < want->meta.wi ? have->meta.wi : want->meta.wi;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (got->data.ptr[i] != want->data.ptr[i]) {
|
||||
if (have->data.ptr[i] != want->data.ptr[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (got->meta.wi != want->meta.wi) {
|
||||
INCR_FAIL(msg, "%sio_buffers_equal: wi: got %zu, want %zu.\n", prefix,
|
||||
got->meta.wi, want->meta.wi);
|
||||
} else if (i < got->meta.wi) {
|
||||
if (have->meta.wi != want->meta.wi) {
|
||||
INCR_FAIL(msg, "%sio_buffers_equal: wi: have %zu, want %zu.\n", prefix,
|
||||
have->meta.wi, want->meta.wi);
|
||||
} else if (i < have->meta.wi) {
|
||||
INCR_FAIL(msg, "%sio_buffers_equal: wi=%zu:\n", prefix, n);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
INCR_FAIL(msg, "contents differ at byte %zu (in hex: 0x%06zx):\n", i, i);
|
||||
msg = hex_dump(msg, got, i);
|
||||
INCR_FAIL(msg, "excerpts of got (above) versus want (below):\n");
|
||||
msg = hex_dump(msg, have, i);
|
||||
INCR_FAIL(msg, "excerpts of have (above) versus want (below):\n");
|
||||
msg = hex_dump(msg, want, i);
|
||||
return fail_msg;
|
||||
}
|
||||
@@ -683,8 +683,8 @@ const char* proc_io_buffers(const char* (*codec_func)(wuffs_base__io_buffer*,
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
@@ -715,10 +715,10 @@ const char* proc_io_buffers(const char* (*codec_func)(wuffs_base__io_buffer*,
|
||||
uint64_t n_bytes = 0;
|
||||
uint64_t i;
|
||||
for (i = 0; i < iters; i++) {
|
||||
got.meta.wi = 0;
|
||||
have.meta.wi = 0;
|
||||
src.meta.ri = gt->src_offset0;
|
||||
const char* status =
|
||||
codec_func(&got, &src, wuffs_initialize_flags, wlimit, rlimit);
|
||||
codec_func(&have, &src, wuffs_initialize_flags, wlimit, rlimit);
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
@@ -726,7 +726,7 @@ const char* proc_io_buffers(const char* (*codec_func)(wuffs_base__io_buffer*,
|
||||
case tc_neither:
|
||||
break;
|
||||
case tc_dst:
|
||||
n_bytes += got.meta.wi;
|
||||
n_bytes += have.meta.wi;
|
||||
break;
|
||||
case tc_src:
|
||||
n_bytes += src.meta.ri - gt->src_offset0;
|
||||
@@ -746,7 +746,7 @@ const char* proc_io_buffers(const char* (*codec_func)(wuffs_base__io_buffer*,
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return check_io_buffers_equal("", &got, &want);
|
||||
return check_io_buffers_equal("", &have, &want);
|
||||
}
|
||||
|
||||
const char* do_bench_io_buffers(
|
||||
@@ -789,13 +789,13 @@ const char* do_test__wuffs_base__hasher_u32(wuffs_base__hasher_u32* b,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
CHECK_STRING(read_file_fragment(&src, src_filename, src_ri, src_wi));
|
||||
uint32_t got = wuffs_base__hasher_u32__update_u32(
|
||||
uint32_t have = wuffs_base__hasher_u32__update_u32(
|
||||
b, ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(src.data.ptr + src.meta.ri),
|
||||
.len = (size_t)(src.meta.wi - src.meta.ri),
|
||||
}));
|
||||
if (got != want) {
|
||||
RETURN_FAIL("got 0x%08" PRIX32 ", want 0x%08" PRIX32, got, want);
|
||||
if (have != want) {
|
||||
RETURN_FAIL("have 0x%08" PRIX32 ", want 0x%08" PRIX32, have, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -811,8 +811,8 @@ const char* do_test__wuffs_base__image_config_decoder(
|
||||
});
|
||||
CHECK_STRING(read_file_fragment(&src, src_filename, src_ri, src_wi));
|
||||
|
||||
uint64_t got_num_frames;
|
||||
for (got_num_frames = 0;; got_num_frames++) {
|
||||
uint64_t have_num_frames;
|
||||
for (have_num_frames = 0;; have_num_frames++) {
|
||||
wuffs_base__status status =
|
||||
wuffs_base__image_decoder__decode_frame_config(b, NULL, &src);
|
||||
if (status.repr == wuffs_base__note__end_of_data) {
|
||||
@@ -822,8 +822,8 @@ const char* do_test__wuffs_base__image_config_decoder(
|
||||
}
|
||||
}
|
||||
|
||||
if (got_num_frames != want_num_frames) {
|
||||
RETURN_FAIL("num_frames: got %" PRIu64 ", want %" PRIu64, got_num_frames,
|
||||
if (have_num_frames != want_num_frames) {
|
||||
RETURN_FAIL("num_frames: have %" PRIu64 ", want %" PRIu64, have_num_frames,
|
||||
want_num_frames);
|
||||
}
|
||||
return NULL;
|
||||
@@ -850,13 +850,14 @@ const char* do_test__wuffs_base__image_decoder(
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_base__image_decoder__decode_image_config(b, &ic, &src));
|
||||
|
||||
uint32_t got_width = wuffs_base__pixel_config__width(&ic.pixcfg);
|
||||
if (got_width != want_width) {
|
||||
RETURN_FAIL("width: got %" PRIu32 ", want %" PRIu32, got_width, want_width);
|
||||
uint32_t have_width = wuffs_base__pixel_config__width(&ic.pixcfg);
|
||||
if (have_width != want_width) {
|
||||
RETURN_FAIL("width: have %" PRIu32 ", want %" PRIu32, have_width,
|
||||
want_width);
|
||||
}
|
||||
uint32_t got_height = wuffs_base__pixel_config__height(&ic.pixcfg);
|
||||
if (got_height != want_height) {
|
||||
RETURN_FAIL("height: got %" PRIu32 ", want %" PRIu32, got_height,
|
||||
uint32_t have_height = wuffs_base__pixel_config__height(&ic.pixcfg);
|
||||
if (have_height != want_height) {
|
||||
RETURN_FAIL("height: have %" PRIu32 ", want %" PRIu32, have_height,
|
||||
want_height);
|
||||
}
|
||||
wuffs_base__pixel_config__set(
|
||||
@@ -876,21 +877,21 @@ const char* do_test__wuffs_base__image_decoder(
|
||||
} else if (n > BUFFER_SIZE) {
|
||||
RETURN_FAIL("pixbuf_len too large");
|
||||
} else {
|
||||
wuffs_base__color_u32_argb_premul got_final_pixel =
|
||||
wuffs_base__color_u32_argb_premul have_final_pixel =
|
||||
wuffs_base__load_u32le(&global_pixel_array[n - 4]);
|
||||
if (got_final_pixel != want_final_pixel) {
|
||||
RETURN_FAIL("final pixel: got 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
got_final_pixel, want_final_pixel);
|
||||
if (have_final_pixel != want_final_pixel) {
|
||||
RETURN_FAIL("final pixel: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
have_final_pixel, want_final_pixel);
|
||||
}
|
||||
}
|
||||
|
||||
if ((want_width > 0) && (want_height > 0)) {
|
||||
wuffs_base__color_u32_argb_premul got_final_pixel =
|
||||
wuffs_base__color_u32_argb_premul have_final_pixel =
|
||||
wuffs_base__pixel_buffer__color_u32_at(&pb, want_width - 1,
|
||||
want_height - 1);
|
||||
if (got_final_pixel != want_final_pixel) {
|
||||
RETURN_FAIL("final pixel: got 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
got_final_pixel, want_final_pixel);
|
||||
if (have_final_pixel != want_final_pixel) {
|
||||
RETURN_FAIL("final pixel: have 0x%08" PRIX32 ", want 0x%08" PRIX32,
|
||||
have_final_pixel, want_final_pixel);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -914,21 +915,21 @@ const char* do_test__wuffs_base__io_transformer(wuffs_base__io_transformer* b,
|
||||
return "workbuf_len is too large";
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
wuffs_base__io_buffer have = ((wuffs_base__io_buffer){
|
||||
.data = global_have_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
CHECK_STRING(read_file_fragment(&src, src_filename, src_ri, src_wi));
|
||||
CHECK_STATUS("transform_io", wuffs_base__io_transformer__transform_io(
|
||||
b, &got, &src, global_work_slice));
|
||||
if (got.meta.wi != want_wi) {
|
||||
RETURN_FAIL("dst wi: got %zu, want %zu", got.meta.wi, want_wi);
|
||||
b, &have, &src, global_work_slice));
|
||||
if (have.meta.wi != want_wi) {
|
||||
RETURN_FAIL("dst wi: have %zu, want %zu", have.meta.wi, want_wi);
|
||||
}
|
||||
if ((want_wi > 0) && (got.data.ptr[want_wi - 1] != want_final_byte)) {
|
||||
RETURN_FAIL("final byte: got 0x%02X, want 0x%02X",
|
||||
got.data.ptr[want_wi - 1], want_final_byte);
|
||||
if ((want_wi > 0) && (have.data.ptr[want_wi - 1] != want_final_byte)) {
|
||||
RETURN_FAIL("final byte: have 0x%02X, want 0x%02X",
|
||||
have.data.ptr[want_wi - 1], want_final_byte);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user