-
Notifications
You must be signed in to change notification settings - Fork 1
/
hints_test.go
54 lines (41 loc) · 1010 Bytes
/
hints_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
package jtdinfer
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHintSet(t *testing.T) {
hs := HintSet{
Values: [][]string{
{"a", "b", "c"},
},
}
assert.False(t, hs.IsActive())
v, found := hs.PeekActive()
assert.Empty(t, v)
assert.False(t, found)
hsA := hs.SubHints("a")
assert.False(t, hsA.IsActive())
v, found = hsA.PeekActive()
assert.Empty(t, v)
assert.False(t, found)
hsB := hs.SubHints("a").SubHints("b")
assert.False(t, hsB.IsActive())
v, found = hsB.PeekActive()
assert.Equal(t, "c", v)
assert.True(t, found)
hsC := hs.SubHints("a").SubHints("b").SubHints("c")
assert.True(t, hsC.IsActive())
v, found = hsC.PeekActive()
assert.Empty(t, v)
assert.False(t, found)
}
func TestHintSetWildcard(t *testing.T) {
hs := HintSet{
Values: [][]string{
{"a", "b", "c"},
{"d", "-", "e"},
},
}
assert.False(t, hs.SubHints("a").SubHints("x").SubHints("c").IsActive())
assert.True(t, hs.SubHints("d").SubHints("x").SubHints("e").IsActive())
}