From 73c4a664b03f8afa8edb527fb6a8cc310bdb3380 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sat, 20 Dec 2025 18:24:09 +0100 Subject: test(markdown): use subtest to clean --- markdown/ast_test.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'markdown/ast_test.go') diff --git a/markdown/ast_test.go b/markdown/ast_test.go index 8f701f4..ed2ef87 100644 --- a/markdown/ast_test.go +++ b/markdown/ast_test.go @@ -45,14 +45,25 @@ var parsed = ` ` -func TestAst(t *testing.T) { - res, err := Parse(raw, nil) - if err != nil { - t.Fatal(err) - } - wanted := strings.ReplaceAll(parsed, "\n", "") - if string(res) != wanted { - t.Errorf("invalid string, got\n%s", res) - t.Logf("wanted\n%s", wanted) +func test(input, expected string) func(*testing.T) { + return testWithOptions(nil, input, expected) +} + +func testWithOptions(opt *Option, input, expected string) func(*testing.T) { + return func(t *testing.T) { + t.Parallel() + got, err := Parse(input, opt) + if err != nil { + t.Fatal(err) + } + if string(got) != expected { + t.Errorf("invalid value, got %s", got) + } } } + +func TestAst(t *testing.T) { + t.Run("ast", func(t *testing.T) { + t.Run("complete", test(raw, strings.ReplaceAll(parsed, "\n", ""))) + }) +} -- cgit v1.2.3