diff options
author | Julien Dessaux | 2022-07-31 10:26:23 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-07-31 10:26:23 +0200 |
commit | 30329bcc35d6fac2105f31c673bc7bbcda7a478d (patch) | |
tree | a28da974ff88f95af878f9efff9290d5ff149003 /src | |
parent | Reworked io functions to take a configurable reader or writer (diff) | |
download | zigfunge98-30329bcc35d6fac2105f31c673bc7bbcda7a478d.tar.gz zigfunge98-30329bcc35d6fac2105f31c673bc7bbcda7a478d.tar.bz2 zigfunge98-30329bcc35d6fac2105f31c673bc7bbcda7a478d.zip |
Improved main test to check for expected output
Diffstat (limited to 'src')
-rw-r--r-- | src/main.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index 4eb46a3..e83a2fd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -27,8 +27,13 @@ test "all" { test "sanity" { var file = try std.fs.cwd().openFile("mycology/sanity.bf", .{}); defer file.close(); + var stdin = std.io.fixedBufferStream(""); + var stdout = std.ArrayList(u8).init(std.testing.allocator); + defer stdout.deinit(); + const expected = "0123456789"; const args = [_][]const u8{"sanity"}; var i = try interpreter.Interpreter.init(std.testing.allocator, file.reader(), args[0..]); defer i.deinit(); - try std.testing.expectEqual(try i.run(io.context(std.io.getStdIn().reader(), std.io.getStdOut().writer())), 0); + try std.testing.expectEqual(try i.run(io.context(stdin.reader(), stdout.writer())), 0); + try std.testing.expectEqual(std.mem.eql(u8, stdout.items, expected), true); } |