blob: 84a40748b8c722282a740bbebcf541c563e3865c [file] [log] [blame]
Akrone396a932021-10-19 01:06:13 +02001package datok
2
3import (
4 "bytes"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8)
9
10func TestTokenWriterSimple(t *testing.T) {
11 assert := assert.New(t)
12
13 b := make([]byte, 0, 2048)
14 w := bytes.NewBuffer(b)
15
16 tws := NewTokenWriterSimple(w)
17
18 assert.NotNil(tws)
19
20 tws.Token(0, []rune{'a', 'b', 'c'})
21
22 tws.Token(0, []rune{'d', 'e', 'f'})
23
Akrona854faa2021-10-22 19:31:08 +020024 tws.SentenceEnd(0)
25
26 tws.TextEnd(0)
Akrone396a932021-10-19 01:06:13 +020027
28 tws.Flush()
29
Akrona854faa2021-10-22 19:31:08 +020030 assert.Equal("abc\ndef\n\n\n", w.String())
Akrone396a932021-10-19 01:06:13 +020031}