Create a unit7 for all unit tests.

This commit is contained in:
Christoffer Lerno
2025-02-24 01:05:45 +01:00
parent 70029cc4b8
commit 87725a3a9e
128 changed files with 9311 additions and 103 deletions

View File

@@ -0,0 +1,29 @@
module std::io::bytebuffer @test;
import std::io;
fn void write_read()
{
ByteBuffer buffer;
buffer.new_init(0);
defer buffer.free();
buffer.write("hello")!!;
char[8] bytes;
usz n = buffer.read(bytes[..])!!;
assert(n == 5);
assert((String)bytes[:n] == "hello");
buffer.write("hello world")!!;
n = buffer.read(bytes[..])!!;
assert(n == bytes.len);
assert((String)bytes[:n] == "hello wo");
assert(buffer.read_idx == 1);
char c = buffer.read_byte()!!;
assert(c == 'r');
buffer.pushback_byte()!!;
n = buffer.read(bytes[..])!!;
assert((String)bytes[:n] == "rld");
assert(buffer.read_idx == 1);
}