-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtemplate_test.go
32 lines (23 loc) · 986 Bytes
/
template_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
package template_test
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
"github.com/go-qbit/template"
)
func TestTemplate_Parse(t *testing.T) {
tpl := template.New()
if !assert.NoError(t, tpl.ParseFile("test/templates/index.gtt")) {
return
}
if !assert.NoError(t, tpl.ParseFile("test/templates/test_syntax.gtt")) {
return
}
buf := &bytes.Buffer{}
tpl.WriteGo(buf, "test", "")
assert.Contains(t, buf.String(), `[]byte{0x20, 0x20, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x20, 0x20}`)
assert.Contains(t, buf.String(), `[]byte{0x72, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x20, 0x20}`)
assert.Contains(t, buf.String(), `[]byte{0x20, 0x20, 0x20, 0x6C, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73}`)
assert.Contains(t, buf.String(), `[]byte{0x22, 0x51, 0x75, 0x6F, 0x74, 0x65, 0x64, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0xA, 0x20, 0x20, 0x20, 0x20, 0x57, 0x69, 0x74, 0x68, 0x20, 0x6E, 0x65, 0x77, 0x20, 0x6C, 0x69, 0x6E, 0x65}`)
//fmt.Println(buf.String())
}