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)
11 output = GetAllMatches("2.0G", "")
13 t.Error("File size matches", output)
16 output = GetAllMatches("4.0K", "")
18 t.Error("File size matches", output)
21 output = GetAllMatches("72K", "")
23 t.Error("File size matches", output)
26 output = GetAllMatches("remotes/origin/master", "")
28 t.Error("Git branch matches", output)
31 output = GetAllMatches("I have a cat.", "")
33 t.Error("Matches sentence", output)
36 output = GetAllMatches("0.0.0.0:3000", "")
38 t.Error("Match ipadress", output)
41 output = GetAllMatches("'/usr/bin", "")
42 if output[0] != "/usr/bin" {
43 t.Error("Doesn't match statement correctly", output)
46 output = GetAllMatches("/usr_b/bin", "")
47 if output[0] != "/usr_b/bin" {
48 t.Error("Doesn't match statement correctly", output)
51 output = GetAllMatches("\"/usr/bin", "")
52 if output[0] != "/usr/bin" {
53 t.Error("Doesn't match statement correctly", output)
56 output = GetAllMatches("`/usr/bin", "")
57 if output[0] != "/usr/bin" {
58 t.Error("Doesn't match statement correctly", output)
61 output = GetAllMatches("€/usr/bin", "")
62 if output[0] != "/usr/bin" {
63 t.Error("Doesn't match statement correctly", output)
66 output = GetAllMatches("prefix=/usr/bin", "")
68 t.Error("Should match =/usr/bin", output)
70 if output[0] != "/usr/bin" {
71 t.Error("Doesn't match statement correctly", output)
74 output = GetAllMatches("/var//log", "")
76 t.Error("Matches double //", output)
79 output = GetAllMatches("s/+//", "")
81 t.Error("Doesn't match substitute", output)
84 output = GetAllMatches("s/^//", "")
86 t.Error("Doesn't match substitute", output)
89 output = GetAllMatches("/usr/bin/env\\", "")
91 t.Error("Doesn't match escaped", output)
93 if output[0] != "/usr/bin/env" {
94 t.Error("Doesn't match escaped exactly", output)
97 output = GetAllMatches("!#/usr/bin/env", "")
99 t.Error("Doesn't match shebang", output)
101 if output[0] != "/usr/bin/env" {
102 t.Error("Doesn't match shebang exactly", output)
105 output = GetAllMatches("hello .gitignore", "")
106 if output[0] != ".gitignore" {
107 t.Error("Doesnt match hidden files", output)
110 output = GetAllMatches(" this.user ", "")
111 if len(output) != 0 {
112 t.Error("Matches this.user", output)
115 output = GetAllMatches("To https://test@test.org/88/ls.git", "")
116 if len(output) != 0 {
117 t.Error("Matches email adresses", output)
120 output = GetAllMatches(" mail@mail.com ", "")
121 if len(output) != 0 {
122 t.Error("Matches email adresses", output)
125 output = GetAllMatches(" logo@2x.png ", "")
126 if len(output) == 0 {
127 t.Error("Doesn't match retina asset", output)
130 output = GetAllMatches("and/or", "")
131 if len(output) != 0 {
132 t.Error("Matches and/or adresses", output)
135 output = GetAllMatches("v1.2", "")
136 if len(output) != 0 {
137 t.Error("Matches version number", output)
140 output = GetAllMatches("14.22.2", "")
141 if len(output) != 0 {
142 t.Error("Matches version number", output)
145 output = GetAllMatches("~/v1.2/js", "")
146 if len(output) != 1 {
147 t.Error("Should match path with version inside", output)
150 output = GetAllMatches("obj.slice()", "")
151 if len(output) != 0 {
152 t.Error("Matches function call", output)
155 output = GetAllMatches("fs.read(arg)", "")
156 if len(output) != 0 {
157 t.Error("Matches function call", output)
160 output = GetAllMatches("~/www", "")
161 if len(output) == 0 || output[0] != "~/www" {
162 t.Error("Doesnt match home", output)
165 output = GetAllMatches("origin/master", "")
166 if len(output) != 0 {
167 t.Error("Matches remote name", output)
170 output = GetAllMatches("john doe (dead on 28/04/2014)", "")
171 if len(output) != 0 {
172 t.Error("Matches date", output)
175 output = GetAllMatches("john doe ,dead on 28/04/2014", "")
176 if len(output) != 0 {
177 t.Error("Matches date", output)
180 output = GetAllMatches(".gitignore , ~/www", "")
181 if len(output) != 2 {
182 t.Error("Doesnt match multi", output)
185 output = GetAllMatches("user.test.js", "")
186 if len(output) != 1 {
187 t.Error("Doesnt match multiple extensions", output)
190 output = GetAllMatches("[Error/foobar]", "")
191 if len(output) == 1 {
192 t.Error("Matches error", output)
195 output = GetAllMatches("[Object.foo]", "")
196 if len(output) == 1 {
197 t.Error("Matches Object.foo", output)
200 output = GetAllMatches("(user.js)", "")
201 if len(output) != 1 {
202 t.Error("Doesnt match surrounded by parens", output)
204 if output[0] != "user.js" {
205 t.Error("matches surrounded by parens badly", output)
208 output = GetAllMatches("var/", "")
209 if len(output) != 1 {
210 t.Error("Doesnt match dir", output)
213 output = GetAllMatches("//", "")
214 if len(output) != 0 {
215 t.Error("Comment matches", output)
218 output = GetAllMatches("test.js:45", "ackmate")
219 if len(output) != 1 {
220 t.Error("Ackmate doesnt match", output)
223 if output[0] == "test.js" {
224 t.Error("Ackmate should not forget number", output)
226 if output[0] != "test.js:45" {
227 t.Error("Ackmate should output right line number", output)
230 output = GetAllMatches("test.js:45:12", "ackmate")
231 if len(output) != 1 {
232 t.Error("Ackmate doesnt match", output)
235 if output[0] == "test.js" {
236 t.Error("Ackmate should not forget number", output)
238 if output[0] != "test.js:45:12" {
239 t.Error("Ackmate should output right line number", output)
242 output = GetAllMatches("test.js:45:12 foo bar", "ackmate")
243 if len(output) != 1 {
244 t.Error("Ackmate doesnt match", output)
247 if output[0] == "test.js" {
248 t.Error("Ackmate should not forget number", output)
250 if output[0] != "test.js:45:12" {
251 t.Error("Ackmate should output right line number", output)