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("/var//log", MatchOptions{})
18 t.Errorf("Matches double //", output)
21 output = GetAllMatches("s/+//", MatchOptions{})
23 t.Errorf("Doesn't match substitute", output)
26 output = GetAllMatches("s/^//", MatchOptions{})
28 t.Errorf("Doesn't match substitute", output)
31 output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
33 t.Errorf("Doesn't match escaped", output)
35 if output[0] != "/usr/bin/env" {
36 t.Errorf("Doesn't match escaped exactly", output)
39 output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
41 t.Errorf("Doesn't match shebang", output)
43 if output[0] != "/usr/bin/env" {
44 t.Errorf("Doesn't match shebang exactly", output)
47 output = GetAllMatches("hello .gitignore", MatchOptions{})
48 if output[0] != ".gitignore" {
49 t.Errorf("Doesnt match hidden files", output)
52 output = GetAllMatches(" this.user ", MatchOptions{})
54 t.Errorf("Matches this.user", output)
57 output = GetAllMatches(" mail@mail.com ", MatchOptions{})
59 t.Errorf("Matches email adresses", output)
62 output = GetAllMatches(" logo@2x.png ", MatchOptions{})
64 t.Errorf("Doesn't match retina asset", output)
67 output = GetAllMatches("and/or", MatchOptions{})
69 t.Errorf("Matches and/or adresses", output)
72 output = GetAllMatches("v1.2", MatchOptions{})
74 t.Errorf("Matches version number", output)
77 output = GetAllMatches("obj.slice()", MatchOptions{})
79 t.Errorf("Matches function call", output)
82 output = GetAllMatches("fs.read(arg)", MatchOptions{})
84 t.Errorf("Matches function call", output)
87 output = GetAllMatches("~/www", MatchOptions{})
88 if len(output) == 0 || output[0] != "~/www" {
89 t.Errorf("Doesnt match home", output)
92 output = GetAllMatches("origin/master", MatchOptions{})
94 t.Errorf("Matches remote name", output)
97 output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
99 t.Errorf("Matches date", output)
102 output = GetAllMatches("john doe ,dead on 28/04/2014", MatchOptions{})
103 if len(output) != 0 {
104 t.Errorf("Matches date", output)
107 output = GetAllMatches(".gitignore , ~/www", MatchOptions{})
108 if len(output) != 2 {
109 t.Errorf("Doesnt match multi", output)
112 output = GetAllMatches("user.test.js", MatchOptions{})
113 if len(output) != 1 {
114 t.Errorf("Doesnt match multiple extensions", output)
117 output = GetAllMatches("(user.js)", MatchOptions{})
118 if len(output) != 1 {
119 t.Errorf("Doesnt match surrounded by parens", output)
121 if output[0] != "user.js" {
122 t.Errorf("matches surrounded by parens badly", output)
125 output = GetAllMatches("var/", MatchOptions{})
126 if len(output) != 1 {
127 t.Errorf("Doesnt match dir", output)
130 output = GetAllMatches("//", MatchOptions{})
131 if len(output) != 0 {
132 t.Errorf("Comment matches", output)
135 output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
136 if len(output) != 1 {
137 t.Errorf("Ackmate doesnt match", output)
139 if output[0] == "test.js" {
140 t.Errorf("Ackmate should not forget number", output)
142 if output[0] != "test.js:45" {
143 t.Errorf("Ackmate should output right line number", output)