]> Sergey Matveev's repositories - path-extractor.git/blob - pe_test.go
Remove = from match
[path-extractor.git] / pe_test.go
1 package pathextractor
2
3 import "testing"
4
5 func TestEverything(t *testing.T) {
6         output := GetAllMatches("?? alt/generateStore.php", MatchOptions{})
7         if output[0] != "alt/generateStore.php" {
8                 t.Errorf("Doesnt match files", output)
9         }
10
11         output = GetAllMatches("I have a cat.", MatchOptions{})
12         if len(output) != 0 {
13                 t.Errorf("Matches sentence", output)
14         }
15
16         output = GetAllMatches("prefix=/usr/bin", MatchOptions{})
17         if len(output) != 1 {
18                 t.Errorf("Should match =/usr/bin", output)
19         }
20         if output[0] != "/usr/bin" {
21                 t.Errorf("Doesn't match statement correctly", output)
22         }
23
24         output = GetAllMatches("/var//log", MatchOptions{})
25         if len(output) != 0 {
26                 t.Errorf("Matches double //", output)
27         }
28
29         output = GetAllMatches("s/+//", MatchOptions{})
30         if len(output) != 0 {
31                 t.Errorf("Doesn't match substitute", output)
32         }
33
34         output = GetAllMatches("s/^//", MatchOptions{})
35         if len(output) != 0 {
36                 t.Errorf("Doesn't match substitute", output)
37         }
38
39         output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
40         if len(output) != 1 {
41                 t.Errorf("Doesn't match escaped", output)
42         }
43         if output[0] != "/usr/bin/env" {
44                 t.Errorf("Doesn't match escaped exactly", output)
45         }
46
47         output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
48         if len(output) != 1 {
49                 t.Errorf("Doesn't match shebang", output)
50         }
51         if output[0] != "/usr/bin/env" {
52                 t.Errorf("Doesn't match shebang exactly", output)
53         }
54
55         output = GetAllMatches("hello .gitignore", MatchOptions{})
56         if output[0] != ".gitignore" {
57                 t.Errorf("Doesnt match hidden files", output)
58         }
59
60         output = GetAllMatches(" this.user ", MatchOptions{})
61         if len(output) != 0 {
62                 t.Errorf("Matches this.user", output)
63         }
64
65         output = GetAllMatches(" mail@mail.com ", MatchOptions{})
66         if len(output) != 0 {
67                 t.Errorf("Matches email adresses", output)
68         }
69
70         output = GetAllMatches(" logo@2x.png ", MatchOptions{})
71         if len(output) == 0 {
72                 t.Errorf("Doesn't match retina asset", output)
73         }
74
75         output = GetAllMatches("and/or", MatchOptions{})
76         if len(output) != 0 {
77                 t.Errorf("Matches and/or adresses", output)
78         }
79
80         output = GetAllMatches("v1.2", MatchOptions{})
81         if len(output) != 0 {
82                 t.Errorf("Matches version number", output)
83         }
84
85         output = GetAllMatches("obj.slice()", MatchOptions{})
86         if len(output) != 0 {
87                 t.Errorf("Matches function call", output)
88         }
89
90         output = GetAllMatches("fs.read(arg)", MatchOptions{})
91         if len(output) != 0 {
92                 t.Errorf("Matches function call", output)
93         }
94
95         output = GetAllMatches("~/www", MatchOptions{})
96         if len(output) == 0 || output[0] != "~/www" {
97                 t.Errorf("Doesnt match home", output)
98         }
99
100         output = GetAllMatches("origin/master", MatchOptions{})
101         if len(output) != 0 {
102                 t.Errorf("Matches remote name", output)
103         }
104
105         output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
106         if len(output) != 0 {
107                 t.Errorf("Matches date", output)
108         }
109
110         output = GetAllMatches("john doe ,dead on 28/04/2014", MatchOptions{})
111         if len(output) != 0 {
112                 t.Errorf("Matches date", output)
113         }
114
115         output = GetAllMatches(".gitignore , ~/www", MatchOptions{})
116         if len(output) != 2 {
117                 t.Errorf("Doesnt match multi", output)
118         }
119
120         output = GetAllMatches("user.test.js", MatchOptions{})
121         if len(output) != 1 {
122                 t.Errorf("Doesnt match multiple extensions", output)
123         }
124
125         output = GetAllMatches("(user.js)", MatchOptions{})
126         if len(output) != 1 {
127                 t.Errorf("Doesnt match surrounded by parens", output)
128         }
129         if output[0] != "user.js" {
130                 t.Errorf("matches surrounded by parens badly", output)
131         }
132
133         output = GetAllMatches("var/", MatchOptions{})
134         if len(output) != 1 {
135                 t.Errorf("Doesnt match dir", output)
136         }
137
138         output = GetAllMatches("//", MatchOptions{})
139         if len(output) != 0 {
140                 t.Errorf("Comment matches", output)
141         }
142
143         output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
144         if len(output) != 1 {
145                 t.Errorf("Ackmate doesnt match", output)
146         }
147         if output[0] == "test.js" {
148                 t.Errorf("Ackmate should not forget number", output)
149         }
150         if output[0] != "test.js:45" {
151                 t.Errorf("Ackmate should output right line number", output)
152         }
153 }