mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fix tests for Go1.16
This commit is contained in:
parent
920c3818d4
commit
a816d4652e
1 changed files with 15 additions and 10 deletions
|
|
@ -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) {
|
func TestDeepNestedLabelPerformance(t *testing.T) {
|
||||||
markdown := New(WithRendererOptions(
|
markdown := New(WithRendererOptions(
|
||||||
html.WithXHTML(),
|
html.WithXHTML(),
|
||||||
html.WithUnsafe(),
|
html.WithUnsafe(),
|
||||||
))
|
))
|
||||||
|
|
||||||
started := time.Now().UnixMilli()
|
started := nowMillis()
|
||||||
n := 50000
|
n := 50000
|
||||||
source := []byte(strings.Repeat("[", n) + strings.Repeat("]", n))
|
source := []byte(strings.Repeat("[", n) + strings.Repeat("]", n))
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
_ = markdown.Convert(source, &b)
|
_ = markdown.Convert(source, &b)
|
||||||
finished := time.Now().UnixMilli()
|
finished := nowMillis()
|
||||||
if (finished - started) > 5000 {
|
if (finished - started) > 5000 {
|
||||||
t.Error("Parsing deep nested labels took more 5 secs")
|
t.Error("Parsing deep nested labels took more 5 secs")
|
||||||
}
|
}
|
||||||
|
|
@ -111,12 +116,12 @@ func TestManyProcessingInstructionPerformance(t *testing.T) {
|
||||||
html.WithUnsafe(),
|
html.WithUnsafe(),
|
||||||
))
|
))
|
||||||
|
|
||||||
started := time.Now().UnixMilli()
|
started := nowMillis()
|
||||||
n := 50000
|
n := 50000
|
||||||
source := []byte("a " + strings.Repeat("<?", n))
|
source := []byte("a " + strings.Repeat("<?", n))
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
_ = markdown.Convert(source, &b)
|
_ = markdown.Convert(source, &b)
|
||||||
finished := time.Now().UnixMilli()
|
finished := nowMillis()
|
||||||
if (finished - started) > 5000 {
|
if (finished - started) > 5000 {
|
||||||
t.Error("Parsing processing instructions took more 5 secs")
|
t.Error("Parsing processing instructions took more 5 secs")
|
||||||
}
|
}
|
||||||
|
|
@ -128,12 +133,12 @@ func TestManyCDATAPerformance(t *testing.T) {
|
||||||
html.WithUnsafe(),
|
html.WithUnsafe(),
|
||||||
))
|
))
|
||||||
|
|
||||||
started := time.Now().UnixMilli()
|
started := nowMillis()
|
||||||
n := 50000
|
n := 50000
|
||||||
source := []byte(strings.Repeat("a <![CDATA[", n))
|
source := []byte(strings.Repeat("a <![CDATA[", n))
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
_ = markdown.Convert(source, &b)
|
_ = markdown.Convert(source, &b)
|
||||||
finished := time.Now().UnixMilli()
|
finished := nowMillis()
|
||||||
if (finished - started) > 5000 {
|
if (finished - started) > 5000 {
|
||||||
t.Error("Parsing processing instructions took more 5 secs")
|
t.Error("Parsing processing instructions took more 5 secs")
|
||||||
}
|
}
|
||||||
|
|
@ -145,12 +150,12 @@ func TestManyDeclPerformance(t *testing.T) {
|
||||||
html.WithUnsafe(),
|
html.WithUnsafe(),
|
||||||
))
|
))
|
||||||
|
|
||||||
started := time.Now().UnixMilli()
|
started := nowMillis()
|
||||||
n := 50000
|
n := 50000
|
||||||
source := []byte(strings.Repeat("a <!A ", n))
|
source := []byte(strings.Repeat("a <!A ", n))
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
_ = markdown.Convert(source, &b)
|
_ = markdown.Convert(source, &b)
|
||||||
finished := time.Now().UnixMilli()
|
finished := nowMillis()
|
||||||
if (finished - started) > 5000 {
|
if (finished - started) > 5000 {
|
||||||
t.Error("Parsing processing instructions took more 5 secs")
|
t.Error("Parsing processing instructions took more 5 secs")
|
||||||
}
|
}
|
||||||
|
|
@ -162,12 +167,12 @@ func TestManyCommentPerformance(t *testing.T) {
|
||||||
html.WithUnsafe(),
|
html.WithUnsafe(),
|
||||||
))
|
))
|
||||||
|
|
||||||
started := time.Now().UnixMilli()
|
started := nowMillis()
|
||||||
n := 50000
|
n := 50000
|
||||||
source := []byte(strings.Repeat("a <!-- ", n))
|
source := []byte(strings.Repeat("a <!-- ", n))
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
_ = markdown.Convert(source, &b)
|
_ = markdown.Convert(source, &b)
|
||||||
finished := time.Now().UnixMilli()
|
finished := nowMillis()
|
||||||
if (finished - started) > 5000 {
|
if (finished - started) > 5000 {
|
||||||
t.Error("Parsing processing instructions took more 5 secs")
|
t.Error("Parsing processing instructions took more 5 secs")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue