forked from valyala/quicktemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriter_test.go
48 lines (40 loc) · 876 Bytes
/
writer_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
36
37
38
39
40
41
42
43
44
45
46
47
48
package quicktemplate
import (
"testing"
)
func TestWriter(t *testing.T) {
bb := AcquireByteBuffer()
qw := AcquireWriter(bb)
w := qw.W()
bbNew, ok := w.(*ByteBuffer)
if !ok {
t.Fatalf("W() must return ByteBuffer, not %T", w)
}
if bbNew != bb {
t.Fatalf("unexpected ByteBuffer returned: %p. Expecting %p", bbNew, bb)
}
wn := qw.N()
we := qw.E()
wn.S("<a></a>")
wn.D(123)
wn.Z([]byte("'"))
wn.Q("foo")
wn.J("ds")
wn.F(1.23)
wn.U("абв")
we.V(struct{}{})
we.S("<a></a>")
we.D(321)
we.Z([]byte("'"))
we.Q("foo")
we.J("ds")
we.F(1.23)
we.U("абв")
we.V(struct{}{})
ReleaseWriter(qw)
expectedS := `<a></a>123'"foo"ds1.23%D0%B0%D0%B1%D0%B2{}<a></a>321'"foo"ds1.23%D0%B0%D0%B1%D0%B2{}`
if string(bb.B) != expectedS {
t.Fatalf("unexpected output: %q. Expecting %q", bb.B, expectedS)
}
ReleaseByteBuffer(bb)
}