blob: 97651a36693ab317724c278f8e757552544a7897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use bufio;
use io;
use memio;
// Reads an IEND chunk from a [[reader]]. This function simply performs a sanity
// check and verifies the chunk checksum.
export fn iend_read(src: *reader) (void | error) = {
assert(chunk_type(src) == IEND,
"Attempted to call iend_read on non-IEND chunk");
io::copy(io::empty, src)?;
};
@test fn iend_reader() void = {
const src = memio::fixed(simple_png);
const read = newreader(&src) as reader;
assert(nextchunk(&read) as u32 == IHDR);
io::copy(io::empty, &read)!;
for (true) {
if (nextchunk(&read) as u32 == IEND) {
break;
};
io::copy(io::empty, &read)!;
};
iend_read(&read)!;
};
|