/
common_test.go
63 lines (53 loc) · 1.36 KB
/
common_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
53
54
55
56
57
58
59
60
61
62
63
package igtest
import (
"fmt"
"path/filepath"
"regexp"
"testing"
)
func TestMatch(t *testing.T) {
// val := b_reg_cmt.ReplaceAll(
// []byte(`
// /*
// */
// kkdkfs
// /*
// kkk*/`), []byte(""))
// fmt.Println(string(val))
fmt.Println(regexp.MatchString("^INC[\\ \\t]+", "INC abcc"))
fmt.Println(regexp.MatchString("^INC[\\ \\t]+", "INCabcc"))
fmt.Println(regexp.MustCompile("^INC[\\ \\t]+").ReplaceAllString("INC abcc", "ss"))
}
func TestValY(t *testing.T) {
ValY(nil)
ValY(1)
ValY(0)
ValY("ss")
ValY("")
}
func TestYesOnExeced(t *testing.T) {
YesOnExeced(&Line{T: "EXP"}, true, nil, Err("kk"))
YesOnExeced(&Line{T: "EXP"}, true, 1, nil)
YesOnExeced(&Line{T: "EXP"}, true, 0, nil)
YesOnExeced(&Line{T: "EXP"}, false, 0, nil)
}
func TestExpYesOnExeced(t *testing.T) {
ExpYesOnExeced(nil, true, nil, nil)
ExpYesOnExeced(&Line{T: "EXP"}, true, nil, Err("kk"))
ExpYesOnExeced(&Line{T: "EXP"}, true, nil, nil)
ExpYesOnExeced(&Line{T: "EXP"}, true, 1, nil)
ExpYesOnExeced(&Line{T: "EXP"}, true, 0, nil)
ExpYesOnExeced(&Line{T: "ABC"}, true, 1, nil)
ExpYesOnExeced(&Line{T: "EXP"}, false, 1, nil)
}
func TestFpath(t *testing.T) {
fmt.Println(filepath.Join("a", "a/"))
fmt.Println(filepath.Dir("test/inc.ig"))
}
func TestComment(t *testing.T) {
fmt.Println(regexp.MustCompile("(?U)//.*\\n").ReplaceAllString(`
//kkk
sdfs
kfdf //kk
`, "\n"))
}