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