-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser_keywords_test.go
70 lines (53 loc) · 1.52 KB
/
parser_keywords_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package habari
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestKeywordGroups(t *testing.T) {
tests := []struct {
name string
input string
expectedTknValue string
keywordCat keywordCategory
}{
{"1", "BLU RAY 1080P", "BLU RAY", keywordCatSource},
{"2", "BLU-RAY 1080P", "BLU-RAY", keywordCatSource},
{"3", "TV RIP 1080P", "TV RIP", keywordCatSource},
{"4", "10 bits 1080P", "10 bits", keywordCatVideoTerm},
{"4", "10-bit 1080P", "10-bit", keywordCatVideoTerm},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := newParser(tt.input)
tm := p.tokenManager
tkn, _ := tm.tokens.getAtSafe(0)
found := p.identifyKeyword(tkn, "normal")
assert.True(t, found)
assert.Equal(t, tt.expectedTknValue, tkn.getValue())
assert.True(t, tkn.isKeywordCategory(tt.keywordCat))
t.Log(tm.tokens.sPrint())
})
}
}
func TestStandaloneKeywords(t *testing.T) {
tests := []struct {
name string
input string
expectedKeywordCat keywordCategory
}{
{"1", "BLURAY 1080P", keywordCatSource},
{"2", "60FPS 1080P", keywordCatVideoTerm},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := newParser(tt.input)
tm := p.tokenManager
tkn, _ := tm.tokens.getAtSafe(0)
found := p.identifyKeyword(tkn, "normal")
assert.True(t, found)
tknKeywordCat, found := tkn.getIdentifiedKeywordCategory()
assert.Equal(t, tt.expectedKeywordCat, tknKeywordCat)
t.Log(tm.tokens.sPrint())
})
}
}