~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH hare-compress] zlib: Move decompress test to +test

Details
Message ID
<20230607181835.1685-1-yyp@disroot.org>
DKIM signature
missing
Download raw message
Patch: +22 -22
---
Otherwise it fails to compile under latest harec

 compress/zlib/{data+test.ha => +test.ha} | 22 ++++++++++++++++++++++
 compress/zlib/reader.ha                  | 22 ----------------------
 2 files changed, 22 insertions(+), 22 deletions(-)
 rename compress/zlib/{data+test.ha => +test.ha} (99%)

diff --git a/compress/zlib/data+test.ha b/compress/zlib/+test.ha
similarity index 99%
rename from compress/zlib/data+test.ha
rename to compress/zlib/+test.ha
index bac8624..a376e0a 100644
--- a/compress/zlib/data+test.ha
+++ b/compress/zlib/+test.ha
@@ -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,
diff --git a/compress/zlib/reader.ha b/compress/zlib/reader.ha
index f54ae29..53e25c4 100644
--- a/compress/zlib/reader.ha
+++ b/compress/zlib/reader.ha
@@ -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));
	};
};
-- 
2.41.0
Details
Message ID
<CV6M6FRAYCYB.SM2PIYF1N2NI@taiga>
In-Reply-To
<20230607181835.1685-1-yyp@disroot.org> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/hare-compress
   159eb2b..890c1e6  master -> master
Reply to thread Export thread (mbox)