blob: 7651c86aec01d54112a3824d0bd772bffaedb4dc [file] [log] [blame]
Akron8ef408b2021-08-02 22:11:04 +02001package datokenizer
2
3import (
Akron8ef408b2021-08-02 22:11:04 +02004 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestSimpleString(t *testing.T) {
10 assert := assert.New(t)
11
12 // bau | bauamt
Akron75ebe7f2021-08-03 10:34:10 +020013 tok := parse_file("testdata/bauamt.fst")
Akron8ef408b2021-08-02 22:11:04 +020014 tok.buildDA()
15 assert.True(tok.match("bau"))
16 assert.True(tok.match("bauamt"))
17 assert.False(tok.match("baum"))
18}
Akron75ebe7f2021-08-03 10:34:10 +020019
20func 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}
Akron730a79c2021-08-03 11:05:29 +020033
34func TestSimpleTokenizer(t *testing.T) {
35 assert := assert.New(t)
Akron730a79c2021-08-03 11:05:29 +020036 tok := parse_file("testdata/simpletok.fst")
37 tok.buildDA()
38 assert.True(tok.match("bau"))
Akron465a0992021-08-03 11:28:48 +020039 assert.True(tok.match("bad"))
Akron49d27ee2021-08-03 11:58:13 +020040 assert.True(tok.match("wald gehen"))
Akron730a79c2021-08-03 11:05:29 +020041}