]> Sergey Matveev's repositories - path-extractor.git/blobdiff - pe_test.go
Small refactor
[path-extractor.git] / pe_test.go
index f560e37249949d7b17c04e94956ae8fd2d317078..7e52783ef9be9d5d92ebc37c3578884d7746081e 100644 (file)
@@ -13,6 +13,70 @@ func TestEverything(t *testing.T) {
                t.Errorf("Matches sentence", output)
        }
 
+       output = GetAllMatches("'/usr/bin", MatchOptions{})
+       if output[0] != "/usr/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("/usr_b/bin", MatchOptions{})
+       if output[0] != "/usr_b/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("\"/usr/bin", MatchOptions{})
+       if output[0] != "/usr/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("`/usr/bin", MatchOptions{})
+       if output[0] != "/usr/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("€/usr/bin", MatchOptions{})
+       if output[0] != "/usr/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("prefix=/usr/bin", MatchOptions{})
+       if len(output) != 1 {
+               t.Errorf("Should match =/usr/bin", output)
+       }
+       if output[0] != "/usr/bin" {
+               t.Errorf("Doesn't match statement correctly", output)
+       }
+
+       output = GetAllMatches("/var//log", MatchOptions{})
+       if len(output) != 0 {
+               t.Errorf("Matches double //", output)
+       }
+
+       output = GetAllMatches("s/+//", MatchOptions{})
+       if len(output) != 0 {
+               t.Errorf("Doesn't match substitute", output)
+       }
+
+       output = GetAllMatches("s/^//", MatchOptions{})
+       if len(output) != 0 {
+               t.Errorf("Doesn't match substitute", output)
+       }
+
+       output = GetAllMatches("/usr/bin/env\\", MatchOptions{})
+       if len(output) != 1 {
+               t.Errorf("Doesn't match escaped", output)
+       }
+       if output[0] != "/usr/bin/env" {
+               t.Errorf("Doesn't match escaped exactly", output)
+       }
+
+       output = GetAllMatches("!#/usr/bin/env", MatchOptions{})
+       if len(output) != 1 {
+               t.Errorf("Doesn't match shebang", output)
+       }
+       if output[0] != "/usr/bin/env" {
+               t.Errorf("Doesn't match shebang exactly", output)
+       }
+
        output = GetAllMatches("hello .gitignore", MatchOptions{})
        if output[0] != ".gitignore" {
                t.Errorf("Doesnt match hidden files", output)
@@ -23,6 +87,11 @@ func TestEverything(t *testing.T) {
                t.Errorf("Matches this.user", output)
        }
 
+       output = GetAllMatches("To https://test@test.org/88/ls.git", MatchOptions{})
+       if len(output) != 0 {
+               t.Errorf("Matches email adresses", output)
+       }
+
        output = GetAllMatches(" mail@mail.com ", MatchOptions{})
        if len(output) != 0 {
                t.Errorf("Matches email adresses", output)
@@ -43,11 +112,21 @@ func TestEverything(t *testing.T) {
                t.Errorf("Matches version number", output)
        }
 
+       output = GetAllMatches("~/v1.2/js", MatchOptions{})
+       if len(output) != 1 {
+               t.Errorf("Should match path with version inside", output)
+       }
+
        output = GetAllMatches("obj.slice()", MatchOptions{})
        if len(output) != 0 {
                t.Errorf("Matches function call", output)
        }
 
+       output = GetAllMatches("fs.read(arg)", MatchOptions{})
+       if len(output) != 0 {
+               t.Errorf("Matches function call", output)
+       }
+
        output = GetAllMatches("~/www", MatchOptions{})
        if len(output) == 0 || output[0] != "~/www" {
                t.Errorf("Doesnt match home", output)
@@ -100,10 +179,11 @@ func TestEverything(t *testing.T) {
        if len(output) != 1 {
                t.Errorf("Ackmate doesnt match", output)
        }
+
        if output[0] == "test.js" {
                t.Errorf("Ackmate should not forget number", output)
        }
-       if output[0] != "test.js:45" {
+       if output[0] != "test.js:45:1" {
                t.Errorf("Ackmate should output right line number", output)
        }
 }