package pathextractor import "testing" func TestEverything(t *testing.T) { output := GetAllMatches("?? alt/generateStore.php", "") if output[0] != "alt/generateStore.php" { t.Error("Doesnt match files", output) } output = GetAllMatches("2.0G", "") if len(output) != 0 { t.Error("File size matches", output) } 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.Error("Doesn't match statement correctly", output) } output = GetAllMatches("/usr_b/bin", "") if output[0] != "/usr_b/bin" { t.Error("Doesn't match statement correctly", output) } output = GetAllMatches("\"/usr/bin", "") if output[0] != "/usr/bin" { t.Error("Doesn't match statement correctly", output) } output = GetAllMatches("`/usr/bin", "") if output[0] != "/usr/bin" { t.Error("Doesn't match statement correctly", output) } output = GetAllMatches("€/usr/bin", "") if output[0] != "/usr/bin" { t.Error("Doesn't match statement correctly", output) } output = GetAllMatches("prefix=/usr/bin", "") if len(output) != 1 { t.Error("Should match =/usr/bin", output) } if output[0] != "/usr/bin" { t.Error("Doesn't match statement correctly", output) } output = GetAllMatches("/var//log", "") if len(output) != 0 { t.Error("Matches double //", output) } output = GetAllMatches("s/+//", "") if len(output) != 0 { t.Error("Doesn't match substitute", output) } output = GetAllMatches("s/^//", "") if len(output) != 0 { t.Error("Doesn't match substitute", output) } output = GetAllMatches("/usr/bin/env\\", "") if len(output) != 1 { t.Error("Doesn't match escaped", output) } if output[0] != "/usr/bin/env" { t.Error("Doesn't match escaped exactly", output) } output = GetAllMatches("!#/usr/bin/env", "") if len(output) != 1 { t.Error("Doesn't match shebang", output) } if output[0] != "/usr/bin/env" { t.Error("Doesn't match shebang exactly", output) } output = GetAllMatches("hello .gitignore", "") if output[0] != ".gitignore" { t.Error("Doesnt match hidden files", output) } output = GetAllMatches(" this.user ", "") if len(output) != 0 { t.Error("Matches this.user", output) } output = GetAllMatches("To https://test@test.org/88/ls.git", "") if len(output) != 0 { t.Error("Matches email adresses", output) } output = GetAllMatches(" mail@mail.com ", "") if len(output) != 0 { t.Error("Matches email adresses", output) } output = GetAllMatches(" logo@2x.png ", "") if len(output) == 0 { t.Error("Doesn't match retina asset", output) } output = GetAllMatches("and/or", "") if len(output) != 0 { t.Error("Matches and/or adresses", output) } output = GetAllMatches("v1.2", "") if len(output) != 0 { 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()", "") if len(output) != 0 { t.Error("Matches function call", output) } output = GetAllMatches("fs.read(arg)", "") if len(output) != 0 { t.Error("Matches function call", output) } output = GetAllMatches("~/www", "") if len(output) == 0 || output[0] != "~/www" { t.Error("Doesnt match home", output) } output = GetAllMatches("origin/master", "") if len(output) != 0 { t.Error("Matches remote name", output) } output = GetAllMatches("john doe (dead on 28/04/2014)", "") if len(output) != 0 { t.Error("Matches date", output) } output = GetAllMatches("john doe ,dead on 28/04/2014", "") if len(output) != 0 { t.Error("Matches date", output) } output = GetAllMatches(".gitignore , ~/www", "") if len(output) != 2 { t.Error("Doesnt match multi", output) } output = GetAllMatches("user.test.js", "") if len(output) != 1 { 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)", "") if len(output) != 1 { t.Error("Doesnt match surrounded by parens", output) } if output[0] != "user.js" { t.Error("matches surrounded by parens badly", output) } output = GetAllMatches("var/", "") if len(output) != 1 { t.Error("Doesnt match dir", output) } output = GetAllMatches("//", "") if len(output) != 0 { t.Error("Comment matches", output) } output = GetAllMatches("test.js:45", "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" { 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) } }