-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregexp_test.go
More file actions
54 lines (50 loc) · 988 Bytes
/
Copy pathregexp_test.go
File metadata and controls
54 lines (50 loc) · 988 Bytes
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 gomml_test
import (
"testing"
"github.com/utisam/gomml"
)
func TestRegexp(t *testing.T) {
tests := []struct {
name string
pattern string
value string
match bool
}{
{
pattern: "\\d+",
value: "1234",
match: true,
},
{
pattern: "\\d+",
value: "abc",
match: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := gomml.Regexp(tt.pattern); !got.Matches(tt.value) == tt.match {
t.Errorf("gomml.Regexp(%v).Matches(%v)", tt.pattern, tt.value)
}
})
}
}
func Test_regexpMatcher_String(t *testing.T) {
tests := []struct {
name string
pattern string
want string
}{
{
pattern: "^prefix-\\d+$",
want: "matches to the pattern of ^prefix-\\d+$",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := gomml.Regexp(tt.pattern).String(); got != tt.want {
t.Errorf("regexpMatcher.String() = %v, want %v", got, tt.want)
}
})
}
}