-
Notifications
You must be signed in to change notification settings - Fork 0
/
guide_test.go
86 lines (74 loc) · 1.65 KB
/
guide_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package dirsyn
import (
"testing"
)
func TestEnhancedGuide(t *testing.T) {
var r RFC4517
for idx, raw := range []string{
`account#!(?true&?false&2.5.4.0$EQ)|?true#wholeSubtree`,
`person#((2.5.4.3$GE&!2.5.4.3$SUBSTR)|?false)#oneLevel`,
} {
if g, err := r.EnhancedGuide(raw); err != nil {
t.Errorf("%s[%d] failed: %v", t.Name(), idx, err)
} else if got := g.String(); raw != got {
t.Errorf("%s[%d] failed:\nwant: %s\ngot: %s", t.Name(), idx, raw, got)
}
}
}
func TestGuide(t *testing.T) {
var r RFC4517
for idx, raw := range []string{
`account#!(?true&?false)|?true`,
`((2.5.4.3$SUBSTR&!(2.5.4.7$LE&2.5.4.0$APPROX))|?false)`,
} {
if g, err := r.Guide(raw); err != nil {
t.Errorf("%s[%d] failed: %v", t.Name(), idx, err)
} else if got := g.String(); raw != got {
t.Errorf("%s[%d] failed:\nwant: %s\ngot: %s", t.Name(), idx, raw, got)
}
}
}
func TestGuide_codecov(t *testing.T) {
var amt AttributeMatchTerm
amt.IsZero()
_ = amt.String()
var bt BoolTerm
bt.IsZero()
_ = bt.String()
var crit Criteria
crit.IsZero()
_ = crit.String()
_ = crit.Index(7)
crit.Len()
var at AndTerm
at.IsZero()
_ = at.String()
_ = at.Index(7)
at.Paren = true
_ = at.String()
at.Len()
var r RFC4517
for _, bogus := range []any{
``,
nil,
`account#values`,
`___#baseOb`,
`___#baseOb#...`,
`___#:::::::#...`,
`#baseObject`,
`yo#()#1`,
`account##baseObject`,
`account#Jerry.Hello#baseObject`,
} {
g, _ := r.Guide(bogus)
_ = g.String()
eg, _ := r.EnhancedGuide(bogus)
_ = eg.String()
}
subsetToInt(`baseobject`)
subsetToInt(`onelevel`)
subsetToInt(`wholesubtree`)
intToSubset(0)
intToSubset(1)
intToSubset(2)
}