Akron | 8ef408b | 2021-08-02 22:11:04 +0200 | [diff] [blame] | 1 | package datokenizer |
| 2 | |
| 3 | import ( |
Akron | 8ef408b | 2021-08-02 22:11:04 +0200 | [diff] [blame] | 4 | "testing" |
| 5 | |
| 6 | "github.com/stretchr/testify/assert" |
| 7 | ) |
| 8 | |
| 9 | func TestSimpleString(t *testing.T) { |
| 10 | assert := assert.New(t) |
| 11 | |
| 12 | // bau | bauamt |
Akron | 75ebe7f | 2021-08-03 10:34:10 +0200 | [diff] [blame] | 13 | tok := parse_file("testdata/bauamt.fst") |
Akron | 8ef408b | 2021-08-02 22:11:04 +0200 | [diff] [blame] | 14 | tok.buildDA() |
| 15 | assert.True(tok.match("bau")) |
| 16 | assert.True(tok.match("bauamt")) |
| 17 | assert.False(tok.match("baum")) |
| 18 | } |
Akron | 75ebe7f | 2021-08-03 10:34:10 +0200 | [diff] [blame] | 19 | |
| 20 | func TestSimpleBranches(t *testing.T) { |
| 21 | assert := assert.New(t) |
| 22 | |
| 23 | // (bau | wahl) (amt | en) |
| 24 | tok := parse_file("testdata/wahlamt.fst") |
| 25 | tok.buildDA() |
| 26 | assert.False(tok.match("bau")) |
| 27 | assert.True(tok.match("bauamt")) |
| 28 | assert.True(tok.match("wahlamt")) |
| 29 | assert.True(tok.match("bauen")) |
| 30 | assert.True(tok.match("wahlen")) |
| 31 | assert.False(tok.match("baum")) |
| 32 | } |
Akron | 730a79c | 2021-08-03 11:05:29 +0200 | [diff] [blame] | 33 | |
| 34 | func TestSimpleTokenizer(t *testing.T) { |
| 35 | assert := assert.New(t) |
Akron | 730a79c | 2021-08-03 11:05:29 +0200 | [diff] [blame] | 36 | tok := parse_file("testdata/simpletok.fst") |
| 37 | tok.buildDA() |
| 38 | assert.True(tok.match("bau")) |
Akron | 465a099 | 2021-08-03 11:28:48 +0200 | [diff] [blame] | 39 | assert.True(tok.match("bad")) |
Akron | 49d27ee | 2021-08-03 11:58:13 +0200 | [diff] [blame^] | 40 | assert.True(tok.match("wald gehen")) |
Akron | 730a79c | 2021-08-03 11:05:29 +0200 | [diff] [blame] | 41 | } |