diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-12-20 18:24:09 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-12-20 18:24:09 +0100 |
| commit | 73c4a664b03f8afa8edb527fb6a8cc310bdb3380 (patch) | |
| tree | 9ba2d2af2149024ea0dc05a88dfcecb351c90139 /markdown/ast_test.go | |
| parent | 90246ee314cfbb6b6f0b43b51e392b6b5293b867 (diff) | |
test(markdown): use subtest to clean
Diffstat (limited to 'markdown/ast_test.go')
| -rw-r--r-- | markdown/ast_test.go | 29 |
1 files changed, 20 insertions, 9 deletions
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 = ` </figure> ` -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", ""))) + }) +} |
