forked from lukasjarosch/go-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
document_test.go
35 lines (30 loc) · 853 Bytes
/
document_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package docx
import "testing"
func BenchmarkDocument_ReplaceAll(b *testing.B) {
for n := 0; n < b.N; n++ {
replaceMap := PlaceholderMap{
"key": "REPLACE some more",
"key-with-dash": "REPLACE",
"key-with-dashes": "REPLACE",
"key with space": "REPLACE",
"key_with_underscore": "REPLACE",
"multiline": "REPLACE",
"key.with.dots": "REPLACE",
"mixed-key.separator_styles#": "REPLACE",
"yet-another_placeholder": "REPLACE",
"foo": "bar",
}
doc, err := Open("./examples/simple/template.docx")
if err != nil {
panic(err)
}
err = doc.ReplaceAll(replaceMap)
if err != nil {
panic(err)
}
err = doc.WriteToFile("/tmp/replaced.docx")
if err != nil {
panic(err)
}
}
}