]> Sergey Matveev's repositories - path-extractor.git/commitdiff
Add multiple tests and fix them
authorEdgar HIPP <hipp.edg@gmail.com>
Sun, 30 Aug 2015 15:07:13 +0000 (17:07 +0200)
committerEdgar HIPP <hipp.edg@gmail.com>
Sun, 30 Aug 2015 15:07:13 +0000 (17:07 +0200)
extractor.go
pe_test.go

index ad83d6eacf648a8ef98136f9534a92f97bf04e44..678f009e50a5b7c92375f0924744625036efac20 100644 (file)
@@ -9,7 +9,7 @@ type MatchOptions struct {
 }
 
 func pathExtractor(input string) [][][]byte {
-       surroundRegex := "[^]\\^\\+()!#[ \\t:'\"\\\\=]*"
+       surroundRegex := "[@~a-zA-Z/.]*"
        r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")")
        temp := [][][]byte{}
        temp = r.FindAllSubmatch([]byte(input), -1)
index 719be92364388d95299b419e370c626b57fdd7c7..a9c15589ce9d89c5ae70ca007233509b274ea377 100644 (file)
@@ -13,6 +13,26 @@ 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/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)