-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathistr_test.go
59 lines (50 loc) · 1.49 KB
/
istr_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
package dirsyn
import (
"testing"
)
func TestIA5String(t *testing.T) {
var r RFC4517
var raw string = `Jerry. Hello.`
if ia, err := r.IA5String(raw); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if got := ia.String(); raw != got {
t.Errorf("%s failed:\nwant: %s\ngot: %s",
t.Name(), raw, got)
}
}
func TestIA5String_SubstringsMatch(t *testing.T) {
result, err := caseIgnoreIA5SubstringsMatch(`JERRY. HELLO.`, `JERR*.*HELL*.`)
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 TestIA5String_CaseMatch(t *testing.T) {
result, err := caseExactIA5Match(`This`, `This`)
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)
}
result, err = caseIgnoreIA5Match(`This`, `THIS`)
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 TestIA5String_codecov(t *testing.T) {
_ = iA5String("HELLO.")
_ = iA5String("[email protected]")
if err := checkIA5String(`[email protected]`); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
return
}
_, _ = caseBasedIA5Match(struct{}{}, `werd`, true)
_, _ = caseBasedIA5Match(`werd`, struct{}{}, false)
runes := []rune{rune(0xFFFF), 'ñ'}
_, _ = marshalIA5String(string(runes))
}