From 30329bcc35d6fac2105f31c673bc7bbcda7a478d Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 31 Jul 2022 10:26:23 +0200 Subject: Improved main test to check for expected output --- src/main.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3