-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbetween_test.go
More file actions
37 lines (32 loc) · 1013 Bytes
/
between_test.go
File metadata and controls
37 lines (32 loc) · 1013 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
package str
import "testing"
func TestBetween(t *testing.T) {
t.Parallel()
if got := Of("This is my name").Between("This", "name").String(); got != " is my " {
t.Fatalf("Between = %q", got)
}
if got := Of("abc").Between("a", "z").String(); got != "" {
t.Fatalf("Between missing end")
}
if got := Of("abc").Between("bc", "a").String(); got != "" {
t.Fatalf("Between overlapping order")
}
if got := Of("abc").Between("", "c").String(); got != "" {
t.Fatalf("Between empty start should be empty")
}
}
func TestBetweenFirst(t *testing.T) {
t.Parallel()
if got := Of("[a] bc [d]").BetweenFirst("[", "]").String(); got != "a" {
t.Fatalf("BetweenFirst = %q", got)
}
if got := Of("abc").BetweenFirst("a", "x").String(); got != "" {
t.Fatalf("BetweenFirst missing end")
}
if got := Of("abc").BetweenFirst("x", "c").String(); got != "" {
t.Fatalf("BetweenFirst missing start")
}
if got := Of("abc").BetweenFirst("", "c").String(); got != "" {
t.Fatalf("BetweenFirst empty start")
}
}