-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregext_test.go
52 lines (40 loc) · 1.3 KB
/
regext_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
package regext
import (
"testing"
)
func TestFull(t *testing.T) {
result := NewRegext([]byte(`seafood FoOl2 fool3 fool4 fool5 fool6 `)).PrintRaw().
Trim().PrintRaw().
ToLower().PrintRaw().
FindAll(`foo..?`).PrintRaw().
Trim().PrintRaw().
FindAll(`(fool[4-6])`).Println("\tFall=", "").
ReplaceAll(`ol`, `od`).Println("\t\tRall=", "").
FilterOut(`food4`, `food.*`).Println("\t\tFout=", "").
FilterAny(`food6`, `food5`).Println("\t\tFany=", "").
FilterOutAny(`food3`, `food4`).Println("\t\tFony=", "").
DeleteAny(`o`, `5`).Println("\t\tDany=", "").
FilterOutByLen(2, 2).Println("\t\tFobl=", "").
Split(`d`, `f`).Println("\t\tSplt=", "").
String()
if result != "6" {
t.Errorf("TestFull failed, expected %v, got %v", "6", result)
}
}
func TestTrim(t *testing.T) {
result := NewRegext([]byte(`
Trimmed Value is Trim
`)).
Trim().PrintRaw().String()
if result != "Trimmed Value is Trim" {
t.Errorf("TestFull failed, expected \"%v\", got \"%v\"", "Trimmed Value is Trim", result)
}
}
func TestJoin(t *testing.T) {
result := NewRegext([]byte(`Test1 Test2 Test3 Test4 Test5`)).
SplitIgnoreBlanks()
if result != "Trimmed Value is Trim" {
t.Errorf("TestFull failed, expected \"%v\", got \"%v\"", "Trimmed Value is Trim", result)
}
}
//TODO: fill out test cases...