]> Sergey Matveev's repositories - path-extractor.git/blob - pe_test.go
f560e37249949d7b17c04e94956ae8fd2d317078
[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("~/www", MatchOptions{})
52         if len(output) == 0 || output[0] != "~/www" {
53                 t.Errorf("Doesnt match home", output)
54         }
55
56         output = GetAllMatches("origin/master", MatchOptions{})
57         if len(output) != 0 {
58                 t.Errorf("Matches remote name", output)
59         }
60
61         output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
62         if len(output) != 0 {
63                 t.Errorf("Matches date", 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(".gitignore , ~/www", MatchOptions{})
72         if len(output) != 2 {
73                 t.Errorf("Doesnt match multi", output)
74         }
75
76         output = GetAllMatches("user.test.js", MatchOptions{})
77         if len(output) != 1 {
78                 t.Errorf("Doesnt match multiple extensions", output)
79         }
80
81         output = GetAllMatches("(user.js)", MatchOptions{})
82         if len(output) != 1 {
83                 t.Errorf("Doesnt match surrounded by parens", output)
84         }
85         if output[0] != "user.js" {
86                 t.Errorf("matches surrounded by parens badly", output)
87         }
88
89         output = GetAllMatches("var/", MatchOptions{})
90         if len(output) != 1 {
91                 t.Errorf("Doesnt match dir", output)
92         }
93
94         output = GetAllMatches("//", MatchOptions{})
95         if len(output) != 0 {
96                 t.Errorf("Comment matches", output)
97         }
98
99         output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
100         if len(output) != 1 {
101                 t.Errorf("Ackmate doesnt match", output)
102         }
103         if output[0] == "test.js" {
104                 t.Errorf("Ackmate should not forget number", output)
105         }
106         if output[0] != "test.js:45" {
107                 t.Errorf("Ackmate should output right line number", output)
108         }
109 }