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