]> Sergey Matveev's repositories - path-extractor.git/blob - pe_test.go
6038afe9722e3f1fe3ee805737abed9e83e7e4cd
[path-extractor.git] / pe_test.go
1 package pathextractor
2
3 import "testing"
4
5 func TestGitIgnore(t *testing.T) {
6         output := GetAllMatches("?? alt/generateStore.php")
7         if output[0] != "alt/generateStore.php" {
8                 t.Errorf("Doesnt match files", output)
9         }
10
11         output = GetAllMatches("I have a cat.")
12         if len(output) != 0 {
13                 t.Errorf("Matches sentence", output)
14         }
15
16         output = GetAllMatches("hello .gitignore")
17         if output[0] != ".gitignore" {
18                 t.Errorf("Doesnt match hidden files", output)
19         }
20
21         output = GetAllMatches(" this.user ")
22         if len(output) != 0 {
23                 t.Errorf("Matches this.user", output)
24         }
25
26         output = GetAllMatches(" mail@mail.com ")
27         if len(output) != 0 {
28                 t.Errorf("Matches email adresses", output)
29         }
30
31         output = GetAllMatches(" logo@2x.png ")
32         if len(output) == 0 {
33                 t.Errorf("Doesn't match retina asset", output)
34         }
35
36         output = GetAllMatches("and/or")
37         if len(output) != 0 {
38                 t.Errorf("Matches and/or adresses", output)
39         }
40
41         output = GetAllMatches("v1.2")
42         if len(output) != 0 {
43                 t.Errorf("Matches version number", output)
44         }
45
46         output = GetAllMatches("obj.slice()")
47         if len(output) != 0 {
48                 t.Errorf("Matches function call", output)
49         }
50
51         output = GetAllMatches("~/www")
52         if len(output) == 0 || output[0] != "~/www" {
53                 t.Errorf("Doesnt match home", output)
54         }
55
56         output = GetAllMatches("origin/master")
57         if len(output) != 0 {
58                 t.Errorf("Matches remote name", output)
59         }
60
61         output = GetAllMatches("john doe (dead on 28/04/2014)")
62         if len(output) != 0 {
63                 t.Errorf("Matches date", output)
64         }
65
66         output = GetAllMatches("john doe ,dead on 28/04/2014")
67         if len(output) != 0 {
68                 t.Errorf("Matches date", output)
69         }
70
71         output = GetAllMatches(".gitignore , ~/www")
72         if len(output) != 2 {
73                 t.Errorf("Doesnt match multi", output)
74         }
75
76         output = GetAllMatches("user.test.js")
77         if len(output) != 1 {
78                 t.Errorf("Doesnt match multiple extensions", output)
79         }
80
81         output = GetAllMatches("(user.js)")
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/")
90         if len(output) != 1 {
91                 t.Errorf("Doesnt match dir", output)
92         }
93
94         output = GetAllMatches("//")
95         if len(output) != 0 {
96                 t.Errorf("Comment matches", output)
97         }
98 }