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