blob: 4ba42b3a341c1889c6701d6929b575162f8de811 [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
Akron740f3d72021-08-03 12:12:34 +020013 tok := ParseFile("testdata/bauamt.fst")
14 tok.ToDoubleArray()
15 assert.True(tok.Match("bau"))
16 assert.True(tok.Match("bauamt"))
17 assert.False(tok.Match("baum"))
Akron8ef408b2021-08-02 22:11:04 +020018}
Akron75ebe7f2021-08-03 10:34:10 +020019
20func TestSimpleBranches(t *testing.T) {
21 assert := assert.New(t)
22
23 // (bau | wahl) (amt | en)
Akron740f3d72021-08-03 12:12:34 +020024 tok := ParseFile("testdata/wahlamt.fst")
25 tok.ToDoubleArray()
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"))
Akron75ebe7f2021-08-03 10:34:10 +020032}
Akron730a79c2021-08-03 11:05:29 +020033
34func TestSimpleTokenizer(t *testing.T) {
35 assert := assert.New(t)
Akron740f3d72021-08-03 12:12:34 +020036 tok := ParseFile("testdata/simpletok.fst")
37 tok.ToDoubleArray()
38 assert.True(tok.Match("bau"))
39 assert.True(tok.Match("bad"))
40 assert.True(tok.Match("wald gehen"))
Akron730a79c2021-08-03 11:05:29 +020041}
Akron740f3d72021-08-03 12:12:34 +020042
43/*
44func TestFullTokenizer(t *testing.T) {
45 assert := assert.New(t)
46 tok := ParseFile("testdata/tokenizer.fst")
47 tok.ToDoubleArray()
48 assert.True(tok.Match("bau"))
49 assert.True(tok.Match("bad"))
50 assert.True(tok.Match("wald gehen"))
51}
52*/