Skip to content

Commit a816d46

Browse files
committed
Fix tests for Go1.16
1 parent 920c381 commit a816d46

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

extra_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,23 @@ func TestAutogeneratedIDs(t *testing.T) {
8888
}
8989
}
9090

91+
func nowMillis() int64 {
92+
// TODO: replace UnixNano to UnixMillis(drops Go1.16 support)
93+
return time.Now().UnixNano() / 1000000
94+
}
95+
9196
func TestDeepNestedLabelPerformance(t *testing.T) {
9297
markdown := New(WithRendererOptions(
9398
html.WithXHTML(),
9499
html.WithUnsafe(),
95100
))
96101

97-
started := time.Now().UnixMilli()
102+
started := nowMillis()
98103
n := 50000
99104
source := []byte(strings.Repeat("[", n) + strings.Repeat("]", n))
100105
var b bytes.Buffer
101106
_ = markdown.Convert(source, &b)
102-
finished := time.Now().UnixMilli()
107+
finished := nowMillis()
103108
if (finished - started) > 5000 {
104109
t.Error("Parsing deep nested labels took more 5 secs")
105110
}
@@ -111,12 +116,12 @@ func TestManyProcessingInstructionPerformance(t *testing.T) {
111116
html.WithUnsafe(),
112117
))
113118

114-
started := time.Now().UnixMilli()
119+
started := nowMillis()
115120
n := 50000
116121
source := []byte("a " + strings.Repeat("<?", n))
117122
var b bytes.Buffer
118123
_ = markdown.Convert(source, &b)
119-
finished := time.Now().UnixMilli()
124+
finished := nowMillis()
120125
if (finished - started) > 5000 {
121126
t.Error("Parsing processing instructions took more 5 secs")
122127
}
@@ -128,12 +133,12 @@ func TestManyCDATAPerformance(t *testing.T) {
128133
html.WithUnsafe(),
129134
))
130135

131-
started := time.Now().UnixMilli()
136+
started := nowMillis()
132137
n := 50000
133138
source := []byte(strings.Repeat("a <![CDATA[", n))
134139
var b bytes.Buffer
135140
_ = markdown.Convert(source, &b)
136-
finished := time.Now().UnixMilli()
141+
finished := nowMillis()
137142
if (finished - started) > 5000 {
138143
t.Error("Parsing processing instructions took more 5 secs")
139144
}
@@ -145,12 +150,12 @@ func TestManyDeclPerformance(t *testing.T) {
145150
html.WithUnsafe(),
146151
))
147152

148-
started := time.Now().UnixMilli()
153+
started := nowMillis()
149154
n := 50000
150155
source := []byte(strings.Repeat("a <!A ", n))
151156
var b bytes.Buffer
152157
_ = markdown.Convert(source, &b)
153-
finished := time.Now().UnixMilli()
158+
finished := nowMillis()
154159
if (finished - started) > 5000 {
155160
t.Error("Parsing processing instructions took more 5 secs")
156161
}
@@ -162,12 +167,12 @@ func TestManyCommentPerformance(t *testing.T) {
162167
html.WithUnsafe(),
163168
))
164169

165-
started := time.Now().UnixMilli()
170+
started := nowMillis()
166171
n := 50000
167172
source := []byte(strings.Repeat("a <!-- ", n))
168173
var b bytes.Buffer
169174
_ = markdown.Convert(source, &b)
170-
finished := time.Now().UnixMilli()
175+
finished := nowMillis()
171176
if (finished - started) > 5000 {
172177
t.Error("Parsing processing instructions took more 5 secs")
173178
}

0 commit comments

Comments
 (0)