-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregexp_test.go
43 lines (35 loc) · 943 Bytes
/
regexp_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
package assert_test
import (
"regexp"
"testing"
. "github.com/pierrre/assert"
"github.com/pierrre/assert/asserttest"
)
func TestRegexp(t *testing.T) {
ok := RegexpMatch(t, regexp.MustCompile("bc"), "abc")
True(t, ok)
}
func TestRegexpFailMatch(t *testing.T) {
report := asserttest.NewReportAuto(t)
ok := RegexpMatch(t, "z", "abc", Report(report))
False(t, ok)
}
func TestRegexpFailCompile(t *testing.T) {
report := asserttest.NewReportAuto(t)
ok := RegexpMatch(t, "\\", "abc", Report(report))
False(t, ok)
}
func TestNotRegexp(t *testing.T) {
ok := RegexpNotMatch(t, regexp.MustCompile("z"), "abc")
True(t, ok)
}
func TestNotRegexpFailMatch(t *testing.T) {
report := asserttest.NewReportAuto(t)
ok := RegexpNotMatch(t, "bc", "abc", Report(report))
False(t, ok)
}
func TestNotRegexpFailCompile(t *testing.T) {
report := asserttest.NewReportAuto(t)
ok := RegexpNotMatch(t, "\\", "abc", Report(report))
False(t, ok)
}