-
Notifications
You must be signed in to change notification settings - Fork 0
/
nstr_test.go
60 lines (52 loc) · 1.45 KB
/
nstr_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
package dirsyn
import (
"testing"
)
func TestNumericString(t *testing.T) {
var r RFC4517
for _, raw := range []any{
`01 37 3748`,
483982,
`483982`,
0,
`00 00 00000000000000`,
} {
if ns, err := r.NumericString(raw); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else {
_ = ns.String()
if !numericString(raw).True() {
t.Errorf("%s failed: failed to parse numericString", t.Name())
}
}
}
marshalNumericString(`ABC`)
}
func TestNumericString_SubstringsMatch(t *testing.T) {
result, err := numericStringSubstringsMatch(`48 129 647`, `48*12* 6*7`)
if err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if !result.True() {
t.Errorf("%s failed:\nwant: %s\ngot: %s", t.Name(), `TRUE`, result)
}
}
func TestNumericString_NumericStringMatch(t *testing.T) {
result, err := numericStringMatch(`01 37 47`, `013747`)
if err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if !result.True() {
t.Errorf("%s failed:\nwant: TRUE\ngot: %s", t.Name(), result)
}
}
func TestNumericString_OrderingMatch(t *testing.T) {
result, err := numericStringOrderingMatch(`01 47 47`, `01 37 47`)
if err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if !result.False() {
t.Errorf("%s failed:\nwant: FALSE\ngot: %s", t.Name(), result)
}
}
func TestNumericString_codecov(t *testing.T) {
_, _, _ = prepareNumericStringAssertion(struct{}{}, `ok`)
_, _, _ = prepareNumericStringAssertion(`ok`, struct{}{})
}