Akron | e396a93 | 2021-10-19 01:06:13 +0200 | [diff] [blame] | 1 | package datok |
2 | |||||
3 | import ( | ||||
4 | "bytes" | ||||
5 | "testing" | ||||
6 | |||||
7 | "github.com/stretchr/testify/assert" | ||||
8 | ) | ||||
9 | |||||
10 | func 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 | |||||
24 | tws.SentenceEnd() | ||||
25 | |||||
26 | tws.Flush() | ||||
27 | |||||
28 | assert.Equal("abc\ndef\n\n", w.String()) | ||||
29 | } |