import "testing"
func TestEverything(t *testing.T) {
- output := GetAllMatches("?? alt/generateStore.php", MatchOptions{})
+ output := GetAllMatches("?? alt/generateStore.php", "")
if output[0] != "alt/generateStore.php" {
- t.Errorf("Doesnt match files", output)
+ t.Error("Doesnt match files", output)
}
- output = GetAllMatches("I have a cat.", MatchOptions{})
+ output = GetAllMatches("2.0G", "")
if len(output) != 0 {
- t.Errorf("Matches sentence", output)
+ t.Error("File size matches", output)
}
- output = GetAllMatches("'/usr/bin", MatchOptions{})
+ output = GetAllMatches("4.0K", "")
+ if len(output) != 0 {
+ t.Error("File size matches", output)
+ }
+
+ output = GetAllMatches("72K", "")
+ if len(output) != 0 {
+ t.Error("File size matches", output)
+ }
+
+ output = GetAllMatches("remotes/origin/master", "")
+ if len(output) != 0 {
+ t.Error("Git branch matches", output)
+ }
+
+ output = GetAllMatches("I have a cat.", "")
+ if len(output) != 0 {
+ t.Error("Matches sentence", output)
+ }
+
+ output = GetAllMatches("0.0.0.0:3000", "")
+ if len(output) != 0 {
+ t.Error("Match ipadress", output)
+ }
+
+ output = GetAllMatches("'/usr/bin", "")
if output[0] != "/usr/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("/usr_b/bin", MatchOptions{})
+ output = GetAllMatches("/usr_b/bin", "")
if output[0] != "/usr_b/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("\"/usr/bin", MatchOptions{})
+ output = GetAllMatches("\"/usr/bin", "")
if output[0] != "/usr/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("`/usr/bin", MatchOptions{})
+ output = GetAllMatches("`/usr/bin", "")
if output[0] != "/usr/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("€/usr/bin", MatchOptions{})
+ output = GetAllMatches("€/usr/bin", "")
if output[0] != "/usr/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("prefix=/usr/bin", MatchOptions{})
+ output = GetAllMatches("prefix=/usr/bin", "")
if len(output) != 1 {
- t.Errorf("Should match =/usr/bin", output)
+ t.Error("Should match =/usr/bin", output)
}
if output[0] != "/usr/bin" {
- t.Errorf("Doesn't match statement correctly", output)
+ t.Error("Doesn't match statement correctly", output)
}
- output = GetAllMatches("/var//log", MatchOptions{})
+ output = GetAllMatches("/var//log", "")
if len(output) != 0 {
- t.Errorf("Matches double //", output)
+ t.Error("Matches double //", output)
}
- output = GetAllMatches("s/+//", MatchOptions{})
+ output = GetAllMatches("s/+//", "")
if len(output) != 0 {
- t.Errorf("Doesn't match substitute", output)
+ t.Error("Doesn't match substitute", output)
}
- output = GetAllMatches("s/^//", MatchOptions{})
+ output = GetAllMatches("s/^//", "")
if len(output) != 0 {
- t.Errorf("Doesn't match substitute", output)
+ t.Error("Doesn't match substitute", output)
}
- output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
+ output = GetAllMatches("/usr/bin/env\\", "")
if len(output) != 1 {
- t.Errorf("Doesn't match escaped", output)
+ t.Error("Doesn't match escaped", output)
}
if output[0] != "/usr/bin/env" {
- t.Errorf("Doesn't match escaped exactly", output)
+ t.Error("Doesn't match escaped exactly", output)
}
- output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
+ output = GetAllMatches("!#/usr/bin/env", "")
if len(output) != 1 {
- t.Errorf("Doesn't match shebang", output)
+ t.Error("Doesn't match shebang", output)
}
if output[0] != "/usr/bin/env" {
- t.Errorf("Doesn't match shebang exactly", output)
+ t.Error("Doesn't match shebang exactly", output)
}
- output = GetAllMatches("hello .gitignore", MatchOptions{})
+ output = GetAllMatches("hello .gitignore", "")
if output[0] != ".gitignore" {
- t.Errorf("Doesnt match hidden files", output)
+ t.Error("Doesnt match hidden files", output)
}
- output = GetAllMatches(" this.user ", MatchOptions{})
+ output = GetAllMatches(" this.user ", "")
if len(output) != 0 {
- t.Errorf("Matches this.user", output)
+ t.Error("Matches this.user", output)
}
- output = GetAllMatches("To https://test@test.org/88/ls.git", MatchOptions{})
+ output = GetAllMatches("To https://test@test.org/88/ls.git", "")
if len(output) != 0 {
- t.Errorf("Matches email adresses", output)
+ t.Error("Matches email adresses", output)
}
- output = GetAllMatches(" mail@mail.com ", MatchOptions{})
+ output = GetAllMatches(" mail@mail.com ", "")
if len(output) != 0 {
- t.Errorf("Matches email adresses", output)
+ t.Error("Matches email adresses", output)
}
- output = GetAllMatches(" logo@2x.png ", MatchOptions{})
+ output = GetAllMatches(" logo@2x.png ", "")
if len(output) == 0 {
- t.Errorf("Doesn't match retina asset", output)
+ t.Error("Doesn't match retina asset", output)
}
- output = GetAllMatches("and/or", MatchOptions{})
+ output = GetAllMatches("and/or", "")
if len(output) != 0 {
- t.Errorf("Matches and/or adresses", output)
+ t.Error("Matches and/or adresses", output)
}
- output = GetAllMatches("v1.2", MatchOptions{})
+ output = GetAllMatches("v1.2", "")
if len(output) != 0 {
- t.Errorf("Matches version number", output)
+ t.Error("Matches version number", output)
+ }
+
+ output = GetAllMatches("14.22.2", "")
+ if len(output) != 0 {
+ t.Error("Matches version number", output)
+ }
+
+ output = GetAllMatches("~/v1.2/js", "")
+ if len(output) != 1 {
+ t.Error("Should match path with version inside", output)
}
- output = GetAllMatches("obj.slice()", MatchOptions{})
+ output = GetAllMatches("obj.slice()", "")
if len(output) != 0 {
- t.Errorf("Matches function call", output)
+ t.Error("Matches function call", output)
}
- output = GetAllMatches("fs.read(arg)", MatchOptions{})
+ output = GetAllMatches("fs.read(arg)", "")
if len(output) != 0 {
- t.Errorf("Matches function call", output)
+ t.Error("Matches function call", output)
}
- output = GetAllMatches("~/www", MatchOptions{})
+ output = GetAllMatches("~/www", "")
if len(output) == 0 || output[0] != "~/www" {
- t.Errorf("Doesnt match home", output)
+ t.Error("Doesnt match home", output)
}
- output = GetAllMatches("origin/master", MatchOptions{})
+ output = GetAllMatches("origin/master", "")
if len(output) != 0 {
- t.Errorf("Matches remote name", output)
+ t.Error("Matches remote name", output)
}
- output = GetAllMatches("john doe (dead on 28/04/2014)", MatchOptions{})
+ output = GetAllMatches("john doe (dead on 28/04/2014)", "")
if len(output) != 0 {
- t.Errorf("Matches date", output)
+ t.Error("Matches date", output)
}
- output = GetAllMatches("john doe ,dead on 28/04/2014", MatchOptions{})
+ output = GetAllMatches("john doe ,dead on 28/04/2014", "")
if len(output) != 0 {
- t.Errorf("Matches date", output)
+ t.Error("Matches date", output)
}
- output = GetAllMatches(".gitignore , ~/www", MatchOptions{})
+ output = GetAllMatches(".gitignore , ~/www", "")
if len(output) != 2 {
- t.Errorf("Doesnt match multi", output)
+ t.Error("Doesnt match multi", output)
}
- output = GetAllMatches("user.test.js", MatchOptions{})
+ output = GetAllMatches("user.test.js", "")
if len(output) != 1 {
- t.Errorf("Doesnt match multiple extensions", output)
+ t.Error("Doesnt match multiple extensions", output)
+ }
+
+ output = GetAllMatches("[Error/foobar]", "")
+ if len(output) == 1 {
+ t.Error("Matches error", output)
+ }
+
+ output = GetAllMatches("[Object.foo]", "")
+ if len(output) == 1 {
+ t.Error("Matches Object.foo", output)
}
- output = GetAllMatches("(user.js)", MatchOptions{})
+ output = GetAllMatches("(user.js)", "")
if len(output) != 1 {
- t.Errorf("Doesnt match surrounded by parens", output)
+ t.Error("Doesnt match surrounded by parens", output)
}
if output[0] != "user.js" {
- t.Errorf("matches surrounded by parens badly", output)
+ t.Error("matches surrounded by parens badly", output)
}
- output = GetAllMatches("var/", MatchOptions{})
+ output = GetAllMatches("var/", "")
if len(output) != 1 {
- t.Errorf("Doesnt match dir", output)
+ t.Error("Doesnt match dir", output)
}
- output = GetAllMatches("//", MatchOptions{})
+ output = GetAllMatches("//", "")
if len(output) != 0 {
- t.Errorf("Comment matches", output)
+ t.Error("Comment matches", output)
}
- output = GetAllMatches("test.js:45", MatchOptions{format: "ackmate"})
+ output = GetAllMatches("test.js:45", "ackmate")
if len(output) != 1 {
- t.Errorf("Ackmate doesnt match", output)
+ t.Error("Ackmate doesnt match", output)
}
+
if output[0] == "test.js" {
- t.Errorf("Ackmate should not forget number", output)
+ t.Error("Ackmate should not forget number", output)
}
if output[0] != "test.js:45" {
- t.Errorf("Ackmate should output right line number", output)
+ t.Error("Ackmate should output right line number", output)
+ }
+
+ output = GetAllMatches("test.js:45:12", "ackmate")
+ if len(output) != 1 {
+ t.Error("Ackmate doesnt match", output)
+ }
+
+ if output[0] == "test.js" {
+ t.Error("Ackmate should not forget number", output)
+ }
+ if output[0] != "test.js:45:12" {
+ t.Error("Ackmate should output right line number", output)
+ }
+
+ output = GetAllMatches("test.js:45:12 foo bar", "ackmate")
+ if len(output) != 1 {
+ t.Error("Ackmate doesnt match", output)
+ }
+
+ if output[0] == "test.js" {
+ t.Error("Ackmate should not forget number", output)
+ }
+ if output[0] != "test.js:45:12" {
+ t.Error("Ackmate should output right line number", output)
}
}