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