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)
11 output = GetAllMatches("I have a cat.", MatchOptions{})
13 t.Errorf("Matches sentence", output)
16 output = GetAllMatches("'/usr/bin", MatchOptions{})
17 if output[0] != "/usr/bin" {
18 t.Errorf("Doesn't match statement correctly", output)
21 output = GetAllMatches("/usr_b/bin", MatchOptions{})
22 if output[0] != "/usr_b/bin" {
23 t.Errorf("Doesn't match statement correctly", output)
26 output = GetAllMatches("\"/usr/bin", MatchOptions{})
27 if output[0] != "/usr/bin" {
28 t.Errorf("Doesn't match statement correctly", output)
31 output = GetAllMatches("`/usr/bin", MatchOptions{})
32 if output[0] != "/usr/bin" {
33 t.Errorf("Doesn't match statement correctly", output)
36 output = GetAllMatches("€/usr/bin", MatchOptions{})
37 if output[0] != "/usr/bin" {
38 t.Errorf("Doesn't match statement correctly", output)
41 output = GetAllMatches("prefix=/usr/bin", MatchOptions{})
43 t.Errorf("Should match =/usr/bin", output)
45 if output[0] != "/usr/bin" {
46 t.Errorf("Doesn't match statement correctly", output)
49 output = GetAllMatches("/var//log", MatchOptions{})
51 t.Errorf("Matches double //", output)
54 output = GetAllMatches("s/+//", MatchOptions{})
56 t.Errorf("Doesn't match substitute", output)
59 output = GetAllMatches("s/^//", MatchOptions{})
61 t.Errorf("Doesn't match substitute", output)
64 output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
66 t.Errorf("Doesn't match escaped", output)
68 if output[0] != "/usr/bin/env" {
69 t.Errorf("Doesn't match escaped exactly", output)
72 output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
74 t.Errorf("Doesn't match shebang", output)
76 if output[0] != "/usr/bin/env" {
77 t.Errorf("Doesn't match shebang exactly", output)
80 output = GetAllMatches("hello .gitignore", MatchOptions{})
81 if output[0] != ".gitignore" {
82 t.Errorf("Doesnt match hidden files", output)
85 output = GetAllMatches(" this.user ", MatchOptions{})
87 t.Errorf("Matches this.user", output)
90 output = GetAllMatches("To https://test@test.org/88/ls.git", MatchOptions{})
92 t.Errorf("Matches email adresses", output)
95 output = GetAllMatches(" mail@mail.com ", MatchOptions{})
97 t.Errorf("Matches email adresses", output)
100 output = GetAllMatches(" logo@2x.png ", MatchOptions{})
101 if len(output) == 0 {
102 t.Errorf("Doesn't match retina asset", output)
105 output = GetAllMatches("and/or", MatchOptions{})
106 if len(output) != 0 {
107 t.Errorf("Matches and/or adresses", output)
110 output = GetAllMatches("v1.2", MatchOptions{})
111 if len(output) != 0 {
112 t.Errorf("Matches version number", output)
115 output = GetAllMatches("obj.slice()", MatchOptions{})
116 if len(output) != 0 {
117 t.Errorf("Matches function call", output)
120 output = GetAllMatches("fs.read(arg)", MatchOptions{})
121 if len(output) != 0 {
122 t.Errorf("Matches function call", output)
125 output = GetAllMatches("~/www", MatchOptions{})
126 if len(output) == 0 || output[0] != "~/www" {
127 t.Errorf("Doesnt match home", output)
130 output = GetAllMatches("origin/master", MatchOptions{})
131 if len(output) != 0 {
132 t.Errorf("Matches remote name", output)
135 output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
136 if len(output) != 0 {
137 t.Errorf("Matches date", output)
140 output = GetAllMatches("john doe ,dead on 28/04/2014", MatchOptions{})
141 if len(output) != 0 {
142 t.Errorf("Matches date", output)
145 output = GetAllMatches(".gitignore , ~/www", MatchOptions{})
146 if len(output) != 2 {
147 t.Errorf("Doesnt match multi", output)
150 output = GetAllMatches("user.test.js", MatchOptions{})
151 if len(output) != 1 {
152 t.Errorf("Doesnt match multiple extensions", output)
155 output = GetAllMatches("(user.js)", MatchOptions{})
156 if len(output) != 1 {
157 t.Errorf("Doesnt match surrounded by parens", output)
159 if output[0] != "user.js" {
160 t.Errorf("matches surrounded by parens badly", output)
163 output = GetAllMatches("var/", MatchOptions{})
164 if len(output) != 1 {
165 t.Errorf("Doesnt match dir", output)
168 output = GetAllMatches("//", MatchOptions{})
169 if len(output) != 0 {
170 t.Errorf("Comment matches", output)
173 output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
174 if len(output) != 1 {
175 t.Errorf("Ackmate doesnt match", output)
177 if output[0] == "test.js" {
178 t.Errorf("Ackmate should not forget number", output)
180 if output[0] != "test.js:45" {
181 t.Errorf("Ackmate should output right line number", output)