blob: 64631c43b5aca3f964d16f9eaf71219f1c340325 [file] [log] [blame]
Akron8ef408b2021-08-02 22:11:04 +02001package datokenizer
2
3import (
Akron730a79c2021-08-03 11:05:29 +02004 "fmt"
Akron8ef408b2021-08-02 22:11:04 +02005 "testing"
6
7 "github.com/stretchr/testify/assert"
8)
9
10func TestSimpleString(t *testing.T) {
11 assert := assert.New(t)
12
13 // bau | bauamt
Akron75ebe7f2021-08-03 10:34:10 +020014 tok := parse_file("testdata/bauamt.fst")
Akron8ef408b2021-08-02 22:11:04 +020015 tok.buildDA()
16 assert.True(tok.match("bau"))
17 assert.True(tok.match("bauamt"))
18 assert.False(tok.match("baum"))
19}
Akron75ebe7f2021-08-03 10:34:10 +020020
21func 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}
Akron730a79c2021-08-03 11:05:29 +020034
35func 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}