]> Sergey Matveev's repositories - path-extractor.git/blobdiff - pe_test.go
Getting line number now works
[path-extractor.git] / pe_test.go
index 719be92364388d95299b419e370c626b57fdd7c7..3f24886f209bf927c03132b674ad2ff36ec369c7 100644 (file)
@@ -13,6 +13,31 @@ 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)
@@ -62,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)
@@ -82,6 +112,11 @@ 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)
@@ -144,10 +179,23 @@ 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" {
                t.Errorf("Ackmate should output right line number", output)
        }
+
+       output = GetAllMatches("test.js:45:12", MatchOptions{format: "ackmate"})
+       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:12" {
+               t.Errorf("Ackmate should output right line number", output)
+       }
 }