From fe3e8fe67b7f655699be321796af70d4bdff230f Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 19 Apr 2026 21:18:54 +0200 Subject: feat(ast): parse link --- src/title.zig | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/title.zig') diff --git a/src/title.zig b/src/title.zig index a29cece..352460f 100644 --- a/src/title.zig +++ b/src/title.zig @@ -5,6 +5,8 @@ const Lexer = @import("lexer/Lexer.zig"); const Element = @import("dom/Element.zig"); const paragraph = @import("paragraph.zig"); const testing = @import("testing.zig"); +const doTest = testing.do; +const doTestError = testing.doError; pub const Error = error{InvalidTitleContent} || paragraph.Error || Lexer.Error; @@ -31,24 +33,16 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { return el; } -fn doTest(alloc: Allocator, t: []const u8, v: []const u8) !void { - return testing.do(parse, alloc, t, v); -} - -fn doTestError(alloc: Allocator, t: []const u8, err: Error) !void { - return testing.doError(parse, alloc, t, err); -} - test "parse title" { var arena = std.heap.DebugAllocator(.{}).init; defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{}); const alloc = arena.allocator(); - try doTest(alloc, "# hey", "

hey

"); - try doTest(alloc, "## hey", "

hey

"); - try doTest(alloc, "### hey", "

hey

"); + try doTest(parse, alloc, "# hey", "

hey

"); + try doTest(parse, alloc, "## hey", "

hey

"); + try doTest(parse, alloc, "### hey", "

hey

"); - try doTest(alloc, "# hello *world*", "

hello world

"); + try doTest(parse, alloc, "# hello *world*", "

hello world

"); - try doTestError(alloc, "# aa :::", Error.InvalidTitleContent); + try doTestError(parse, alloc, "# aa :::", Error.InvalidTitleContent); } -- cgit v1.2.3