From a816d4652e2da4e4ffb0d5779cb79434dbb748e4 Mon Sep 17 00:00:00 2001 From: yuin Date: Sat, 5 Mar 2022 18:56:34 +0900 Subject: [PATCH] Fix tests for Go1.16 --- extra_test.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/extra_test.go b/extra_test.go index 8378243..211ba2b 100644 --- a/extra_test.go +++ b/extra_test.go @@ -88,18 +88,23 @@ func TestAutogeneratedIDs(t *testing.T) { } } +func nowMillis() int64 { + // TODO: replace UnixNano to UnixMillis(drops Go1.16 support) + return time.Now().UnixNano() / 1000000 +} + func TestDeepNestedLabelPerformance(t *testing.T) { markdown := New(WithRendererOptions( html.WithXHTML(), html.WithUnsafe(), )) - started := time.Now().UnixMilli() + started := nowMillis() n := 50000 source := []byte(strings.Repeat("[", n) + strings.Repeat("]", n)) var b bytes.Buffer _ = markdown.Convert(source, &b) - finished := time.Now().UnixMilli() + finished := nowMillis() if (finished - started) > 5000 { t.Error("Parsing deep nested labels took more 5 secs") } @@ -111,12 +116,12 @@ func TestManyProcessingInstructionPerformance(t *testing.T) { html.WithUnsafe(), )) - started := time.Now().UnixMilli() + started := nowMillis() n := 50000 source := []byte("a " + strings.Repeat(" 5000 { t.Error("Parsing processing instructions took more 5 secs") } @@ -128,12 +133,12 @@ func TestManyCDATAPerformance(t *testing.T) { html.WithUnsafe(), )) - started := time.Now().UnixMilli() + started := nowMillis() n := 50000 source := []byte(strings.Repeat("a 5000 { t.Error("Parsing processing instructions took more 5 secs") } @@ -145,12 +150,12 @@ func TestManyDeclPerformance(t *testing.T) { html.WithUnsafe(), )) - started := time.Now().UnixMilli() + started := nowMillis() n := 50000 source := []byte(strings.Repeat("a 5000 { t.Error("Parsing processing instructions took more 5 secs") } @@ -162,12 +167,12 @@ func TestManyCommentPerformance(t *testing.T) { html.WithUnsafe(), )) - started := time.Now().UnixMilli() + started := nowMillis() n := 50000 source := []byte(strings.Repeat("a