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