From e6747ee62878f45862749f5c70b67875b8666287 Mon Sep 17 00:00:00 2001 From: jkboxomine <28672313+jkboxomine@users.noreply.github.com> Date: Fri, 6 Dec 2019 00:11:32 +0900 Subject: [PATCH] Update test case for auto heading ID generation - remove WithIDs option - add test cases with international characters and other conditions --- extra_test.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/extra_test.go b/extra_test.go index bddfe3f..6775ec2 100644 --- a/extra_test.go +++ b/extra_test.go @@ -71,17 +71,29 @@ func (s *myIDs) Put(value []byte) { } func TestAutogeneratedIDs(t *testing.T) { - ctx := parser.NewContext(parser.WithIDs(&myIDs{})) + ctx := parser.NewContext() markdown := New(WithParserOptions(parser.WithAutoHeadingID())) - source := []byte("# Title1\n## Title2") + + source := []byte("## Não há quem goste de dor") var b bytes.Buffer err := markdown.Convert(source, &b, parser.WithContext(ctx)) if err != nil { t.Error(err.Error()) } - if b.String() != `

Title1

-

Title2

-` { + if b.String() != `

Não há quem goste de dor

+ ` { t.Errorf("%s\n---------\n%s", source, b.String()) } + + source = []byte("## 봄 꿀밤 단 꿀밤 v1.0 (2019년-1월-1일)\n### 가을 꿀밤 안단 꿀밤 v2.0 (2020년_12월_31일)") + var b2 bytes.Buffer + err = markdown.Convert(source, &b2, parser.WithContext(ctx)) + if err != nil { + t.Error(err.Error()) + } + if b2.String() != `

봄 꿀밤 단 꿀밤 v1.0 (2019년-1월-1일)

+

가을 꿀밤 안단 꿀밤 v2.0 (2020년_12월_31일)

+ ` { + t.Errorf("%s\n---------\n%s", source, b2.String()) + } }