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)!; };