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("prefix=/usr/bin", MatchOptions{})
18 t.Errorf("Should match =/usr/bin", output)
20 if output[0] != "/usr/bin" {
21 t.Errorf("Doesn't match statement correctly", output)
24 output = GetAllMatches("/var//log", MatchOptions{})
26 t.Errorf("Matches double //", output)
29 output = GetAllMatches("s/+//", MatchOptions{})
31 t.Errorf("Doesn't match substitute", output)
34 output = GetAllMatches("s/^//", MatchOptions{})
36 t.Errorf("Doesn't match substitute", output)
39 output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
41 t.Errorf("Doesn't match escaped", output)
43 if output[0] != "/usr/bin/env" {
44 t.Errorf("Doesn't match escaped exactly", output)
47 output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
49 t.Errorf("Doesn't match shebang", output)
51 if output[0] != "/usr/bin/env" {
52 t.Errorf("Doesn't match shebang exactly", output)
55 output = GetAllMatches("hello .gitignore", MatchOptions{})
56 if output[0] != ".gitignore" {
57 t.Errorf("Doesnt match hidden files", output)
60 output = GetAllMatches(" this.user ", MatchOptions{})
62 t.Errorf("Matches this.user", output)
65 output = GetAllMatches(" mail@mail.com ", MatchOptions{})
67 t.Errorf("Matches email adresses", output)
70 output = GetAllMatches(" logo@2x.png ", MatchOptions{})
72 t.Errorf("Doesn't match retina asset", output)
75 output = GetAllMatches("and/or", MatchOptions{})
77 t.Errorf("Matches and/or adresses", output)
80 output = GetAllMatches("v1.2", MatchOptions{})
82 t.Errorf("Matches version number", output)
85 output = GetAllMatches("obj.slice()", MatchOptions{})
87 t.Errorf("Matches function call", output)
90 output = GetAllMatches("fs.read(arg)", MatchOptions{})
92 t.Errorf("Matches function call", output)
95 output = GetAllMatches("~/www", MatchOptions{})
96 if len(output) == 0 || output[0] != "~/www" {
97 t.Errorf("Doesnt match home", output)
100 output = GetAllMatches("origin/master", MatchOptions{})
101 if len(output) != 0 {
102 t.Errorf("Matches remote name", output)
105 output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
106 if len(output) != 0 {
107 t.Errorf("Matches date", output)
110 output = GetAllMatches("john doe ,dead on 28/04/2014", MatchOptions{})
111 if len(output) != 0 {
112 t.Errorf("Matches date", output)
115 output = GetAllMatches(".gitignore , ~/www", MatchOptions{})
116 if len(output) != 2 {
117 t.Errorf("Doesnt match multi", output)
120 output = GetAllMatches("user.test.js", MatchOptions{})
121 if len(output) != 1 {
122 t.Errorf("Doesnt match multiple extensions", output)
125 output = GetAllMatches("(user.js)", MatchOptions{})
126 if len(output) != 1 {
127 t.Errorf("Doesnt match surrounded by parens", output)
129 if output[0] != "user.js" {
130 t.Errorf("matches surrounded by parens badly", output)
133 output = GetAllMatches("var/", MatchOptions{})
134 if len(output) != 1 {
135 t.Errorf("Doesnt match dir", output)
138 output = GetAllMatches("//", MatchOptions{})
139 if len(output) != 0 {
140 t.Errorf("Comment matches", output)
143 output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
144 if len(output) != 1 {
145 t.Errorf("Ackmate doesnt match", output)
147 if output[0] == "test.js" {
148 t.Errorf("Ackmate should not forget number", output)
150 if output[0] != "test.js:45" {
151 t.Errorf("Ackmate should output right line number", output)