diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-19 18:55:36 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-19 18:55:36 +0200 |
| commit | c46957f44e8b5ba0639b7092a1c5abd9516b1b22 (patch) | |
| tree | fdd20da760740866060a139958e2f84a0e7fc81b /src/parser.zig | |
| parent | cf6f08d1602841f8c337dc64365e2dcde1e4c528 (diff) | |
fix(ast): small memory leak in subs
Diffstat (limited to 'src/parser.zig')
| -rw-r--r-- | src/parser.zig | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/parser.zig b/src/parser.zig index 442d823..f109a88 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -49,20 +49,11 @@ fn doTest(alloc: Allocator, t: []const u8, v: []const u8) !void { }; } -fn doTestError(alloc: Allocator, t: []const u8, err: Error) !void { - _ = parse(alloc, t) catch |e| return std.testing.expect(err == e); - return std.testing.expect(false); -} - -test "parse paragraphs" { +test "parse multilines" { var arena = std.heap.DebugAllocator(.{}).init; defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{}); const alloc = arena.allocator(); - try doTest(alloc, "hello world", "<p>hello world</p>"); - try doTest(alloc, "*hello* world", "<p><b>hello</b> world</p>"); - try doTest(alloc, "*he_ll_o* world", "<p><b>he<em>ll</em>o</b> world</p>"); - try doTest(alloc, \\hello \\world @@ -71,29 +62,10 @@ test "parse paragraphs" { \\in new paragraph , "<p>hello world</p><p>foo bar in new paragraph</p>"); - try doTestError(alloc, "hello *world", Error.ModifierNotClosed); - try doTestError(alloc, "hello *wo_rld*", Error.ModifierNotClosed); - try doTestError(alloc, "*hell*o *wo_rld*", Error.ModifierNotClosed); - try doTestError(alloc, "hello ::: world", Error.IllegalPlacement); -} - -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", "<h1>hey</h1>"); - try doTest(alloc, "## hey", "<h2>hey</h2>"); - try doTest(alloc, "### hey", "<h3>hey</h3>"); - - try doTest(alloc, "# hello *world*", "<h1>hello <b>world</b></h1>"); - try doTest(alloc, \\# title \\hello world ;3 \\## subtitle \\hehe , "<h1>title</h1><p>hello world ;3</p><h2>subtitle</h2><p>hehe</p>"); - - try doTestError(alloc, "# aa :::", Error.InvalidTitleContent); } |
