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 | |
Akron | a854faa | 2021-10-22 19:31:08 +0200 | [diff] [blame^] | 24 | tws.SentenceEnd(0) |
| 25 | |
| 26 | tws.TextEnd(0) |
Akron | e396a93 | 2021-10-19 01:06:13 +0200 | [diff] [blame] | 27 | |
| 28 | tws.Flush() |
| 29 | |
Akron | a854faa | 2021-10-22 19:31:08 +0200 | [diff] [blame^] | 30 | assert.Equal("abc\ndef\n\n\n", w.String()) |
Akron | e396a93 | 2021-10-19 01:06:13 +0200 | [diff] [blame] | 31 | } |