forked from src-d/flamingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_test.go
32 lines (27 loc) · 900 Bytes
/
message_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
package flamingo
import (
"regexp"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMessageMatchString(t *testing.T) {
msg := Message{Text: " foo Bar Baz "}
assert.True(t, msg.MatchString("foo bar baz"))
assert.True(t, msg.MatchString(" foo bar baz "))
assert.True(t, msg.MatchString("foo Bar baz"))
}
func TestMessageMatchStringCase(t *testing.T) {
msg := Message{Text: " foo Bar Baz "}
assert.False(t, msg.MatchStringCase("foo Bar baz"))
assert.True(t, msg.MatchStringCase("foo Bar Baz"))
assert.True(t, msg.MatchStringCase(" foo Bar Baz "))
}
func TestMessageMatchRegex(t *testing.T) {
msg := Message{Text: " foo Bar Baz "}
r := regexp.MustCompile(`foo( Ba[rz])+`)
r2 := regexp.MustCompile(`foo( ba[rz])+`)
r3 := regexp.MustCompile(` foo( Ba[rz])+`)
assert.True(t, msg.MatchRegex(r))
assert.False(t, msg.MatchRegex(r2))
assert.False(t, msg.MatchRegex(r3))
}