~sircmpwn/hare-compress

db4312a30b5a50e34b9f020fa9ed8bd6f5b35b72 — Alexey Yerin 1 year, 16 days ago ab6586b
zlib: Move decompress test to +test
2 files changed, 22 insertions(+), 22 deletions(-)

R compress/zlib/{data+test.ha => +test.ha}
M compress/zlib/reader.ha
R compress/zlib/data+test.ha => compress/zlib/+test.ha +22 -0
@@ 1,6 1,28 @@
// License: MPL-2.0
// (c) 2021 Ember Sawady <ecs@d2evs.net>

@test fn decompress() void = {
	for (let i = 1z; i < len(vectors); i += 1) {
		let in = bufio::fixed(*vectors[i].1, io::mode::READ);
		let out = bufio::dynamic(io::mode::WRITE);
		let d = match (decompress(&in)) {
		case let s: reader =>
			yield s;
		case let e: io::error =>
			fmt::errorln(io::strerror(e))!;
			abort();
		};
		match (io::copy(&out, &d)) {
		case size => void;
		case let e: io::error =>
			fmt::errorfln("vector {}: {}", i, io::strerror(e))!;
			abort();
		};
		let s = bufio::buffer(&out);
		assert(bytes::equal(s, *vectors[i].0));
	};
};

const null_in: []u8 = [
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

M compress/zlib/reader.ha => compress/zlib/reader.ha +0 -22
@@ 159,25 159,3 @@ const reader_vtable: io::vtable = io::vtable {
	closer = &close,
	...
};

@test fn decompress() void = {
	for (let i = 1z; i < len(vectors); i += 1) {
		let in = bufio::fixed(*vectors[i].1, io::mode::READ);
		let out = bufio::dynamic(io::mode::WRITE);
		let d = match (decompress(&in)) {
		case let s: reader =>
			yield s;
		case let e: io::error =>
			fmt::errorln(io::strerror(e))!;
			abort();
		};
		match (io::copy(&out, &d)) {
		case size => void;
		case let e: io::error =>
			fmt::errorfln("vector {}: {}", i, io::strerror(e))!;
			abort();
		};
		let s = bufio::buffer(&out);
		assert(bytes::equal(s, *vectors[i].0));
	};
};