]> Sergey Matveev's repositories - path-extractor.git/blob - pe_test.go
Tests workability
[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", "")
7         if output[0] != "alt/generateStore.php" {
8                 t.Error("Doesnt match files", output)
9         }
10
11         output = GetAllMatches("2.0G", "")
12         if len(output) != 0 {
13                 t.Error("File size matches", output)
14         }
15
16         output = GetAllMatches("4.0K", "")
17         if len(output) != 0 {
18                 t.Error("File size matches", output)
19         }
20
21         output = GetAllMatches("72K", "")
22         if len(output) != 0 {
23                 t.Error("File size matches", output)
24         }
25
26         output = GetAllMatches("remotes/origin/master", "")
27         if len(output) != 0 {
28                 t.Error("Git branch matches", output)
29         }
30
31         output = GetAllMatches("I have a cat.", "")
32         if len(output) != 0 {
33                 t.Error("Matches sentence", output)
34         }
35
36         output = GetAllMatches("0.0.0.0:3000", "")
37         if len(output) != 0 {
38                 t.Error("Match ipadress", output)
39         }
40
41         output = GetAllMatches("'/usr/bin", "")
42         if output[0] != "/usr/bin" {
43                 t.Error("Doesn't match statement correctly", output)
44         }
45
46         output = GetAllMatches("/usr_b/bin", "")
47         if output[0] != "/usr_b/bin" {
48                 t.Error("Doesn't match statement correctly", output)
49         }
50
51         output = GetAllMatches("\"/usr/bin", "")
52         if output[0] != "/usr/bin" {
53                 t.Error("Doesn't match statement correctly", output)
54         }
55
56         output = GetAllMatches("`/usr/bin", "")
57         if output[0] != "/usr/bin" {
58                 t.Error("Doesn't match statement correctly", output)
59         }
60
61         output = GetAllMatches("€/usr/bin", "")
62         if output[0] != "/usr/bin" {
63                 t.Error("Doesn't match statement correctly", output)
64         }
65
66         output = GetAllMatches("prefix=/usr/bin", "")
67         if len(output) != 1 {
68                 t.Error("Should match =/usr/bin", output)
69         }
70         if output[0] != "/usr/bin" {
71                 t.Error("Doesn't match statement correctly", output)
72         }
73
74         output = GetAllMatches("/var//log", "")
75         if len(output) != 0 {
76                 t.Error("Matches double //", output)
77         }
78
79         output = GetAllMatches("s/+//", "")
80         if len(output) != 0 {
81                 t.Error("Doesn't match substitute", output)
82         }
83
84         output = GetAllMatches("s/^//", "")
85         if len(output) != 0 {
86                 t.Error("Doesn't match substitute", output)
87         }
88
89         output = GetAllMatches("/usr/bin/env\\", "")
90         if len(output) != 1 {
91                 t.Error("Doesn't match escaped", output)
92         }
93         if output[0] != "/usr/bin/env" {
94                 t.Error("Doesn't match escaped exactly", output)
95         }
96
97         output = GetAllMatches("!#/usr/bin/env", "")
98         if len(output) != 1 {
99                 t.Error("Doesn't match shebang", output)
100         }
101         if output[0] != "/usr/bin/env" {
102                 t.Error("Doesn't match shebang exactly", output)
103         }
104
105         output = GetAllMatches("hello .gitignore", "")
106         if output[0] != ".gitignore" {
107                 t.Error("Doesnt match hidden files", output)
108         }
109
110         output = GetAllMatches(" this.user ", "")
111         if len(output) != 0 {
112                 t.Error("Matches this.user", output)
113         }
114
115         output = GetAllMatches("To https://test@test.org/88/ls.git", "")
116         if len(output) != 0 {
117                 t.Error("Matches email adresses", output)
118         }
119
120         output = GetAllMatches(" mail@mail.com ", "")
121         if len(output) != 0 {
122                 t.Error("Matches email adresses", output)
123         }
124
125         output = GetAllMatches(" logo@2x.png ", "")
126         if len(output) == 0 {
127                 t.Error("Doesn't match retina asset", output)
128         }
129
130         output = GetAllMatches("and/or", "")
131         if len(output) != 0 {
132                 t.Error("Matches and/or adresses", output)
133         }
134
135         output = GetAllMatches("v1.2", "")
136         if len(output) != 0 {
137                 t.Error("Matches version number", output)
138         }
139
140         output = GetAllMatches("14.22.2", "")
141         if len(output) != 0 {
142                 t.Error("Matches version number", output)
143         }
144
145         output = GetAllMatches("~/v1.2/js", "")
146         if len(output) != 1 {
147                 t.Error("Should match path with version inside", output)
148         }
149
150         output = GetAllMatches("obj.slice()", "")
151         if len(output) != 0 {
152                 t.Error("Matches function call", output)
153         }
154
155         output = GetAllMatches("fs.read(arg)", "")
156         if len(output) != 0 {
157                 t.Error("Matches function call", output)
158         }
159
160         output = GetAllMatches("~/www", "")
161         if len(output) == 0 || output[0] != "~/www" {
162                 t.Error("Doesnt match home", output)
163         }
164
165         output = GetAllMatches("origin/master", "")
166         if len(output) != 0 {
167                 t.Error("Matches remote name", output)
168         }
169
170         output = GetAllMatches("john doe (dead on 28/04/2014)", "")
171         if len(output) != 0 {
172                 t.Error("Matches date", output)
173         }
174
175         output = GetAllMatches("john doe ,dead on 28/04/2014", "")
176         if len(output) != 0 {
177                 t.Error("Matches date", output)
178         }
179
180         output = GetAllMatches(".gitignore , ~/www", "")
181         if len(output) != 2 {
182                 t.Error("Doesnt match multi", output)
183         }
184
185         output = GetAllMatches("user.test.js", "")
186         if len(output) != 1 {
187                 t.Error("Doesnt match multiple extensions", output)
188         }
189
190         output = GetAllMatches("[Error/foobar]", "")
191         if len(output) == 1 {
192                 t.Error("Matches error", output)
193         }
194
195         output = GetAllMatches("[Object.foo]", "")
196         if len(output) == 1 {
197                 t.Error("Matches Object.foo", output)
198         }
199
200         output = GetAllMatches("(user.js)", "")
201         if len(output) != 1 {
202                 t.Error("Doesnt match surrounded by parens", output)
203         }
204         if output[0] != "user.js" {
205                 t.Error("matches surrounded by parens badly", output)
206         }
207
208         output = GetAllMatches("var/", "")
209         if len(output) != 1 {
210                 t.Error("Doesnt match dir", output)
211         }
212
213         output = GetAllMatches("//", "")
214         if len(output) != 0 {
215                 t.Error("Comment matches", output)
216         }
217
218         output = GetAllMatches("test.js:45", "ackmate")
219         if len(output) != 1 {
220                 t.Error("Ackmate doesnt match", output)
221         }
222
223         if output[0] == "test.js" {
224                 t.Error("Ackmate should not forget number", output)
225         }
226         if output[0] != "test.js:45" {
227                 t.Error("Ackmate should output right line number", output)
228         }
229
230         output = GetAllMatches("test.js:45:12", "ackmate")
231         if len(output) != 1 {
232                 t.Error("Ackmate doesnt match", output)
233         }
234
235         if output[0] == "test.js" {
236                 t.Error("Ackmate should not forget number", output)
237         }
238         if output[0] != "test.js:45:12" {
239                 t.Error("Ackmate should output right line number", output)
240         }
241
242         output = GetAllMatches("test.js:45:12 foo bar", "ackmate")
243         if len(output) != 1 {
244                 t.Error("Ackmate doesnt match", output)
245         }
246
247         if output[0] == "test.js" {
248                 t.Error("Ackmate should not forget number", output)
249         }
250         if output[0] != "test.js:45:12" {
251                 t.Error("Ackmate should output right line number", output)
252         }
253 }