diff options
Diffstat (limited to 'src/title.zig')
| -rw-r--r-- | src/title.zig | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/title.zig b/src/title.zig index 62d7929..a29cece 100644 --- a/src/title.zig +++ b/src/title.zig @@ -4,6 +4,7 @@ const Lexed = @import("lexer/Lexed.zig"); const Lexer = @import("lexer/Lexer.zig"); const Element = @import("dom/Element.zig"); const paragraph = @import("paragraph.zig"); +const testing = @import("testing.zig"); pub const Error = error{InvalidTitleContent} || paragraph.Error || Lexer.Error; @@ -31,21 +32,11 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { } fn doTest(alloc: Allocator, t: []const u8, v: []const u8) !void { - var l = try Lexer.init(t); - var p = try parse(alloc, &l); - defer p.deinit(); - const g = try p.render(alloc); - defer alloc.free(g); - std.testing.expect(std.mem.eql(u8, g, v)) catch |err| { - std.debug.print("{s}\n", .{g}); - return err; - }; + return testing.do(parse, alloc, t, v); } fn doTestError(alloc: Allocator, t: []const u8, err: Error) !void { - var l = try Lexer.init(t); - _ = parse(alloc, &l) catch |e| return std.testing.expect(err == e); - return std.testing.expect(false); + return testing.doError(parse, alloc, t, err); } test "parse title" { |
