]> Sergey Matveev's repositories - path-extractor.git/blobdiff - pe_test.go
Add multiple tests and fix them
[path-extractor.git] / pe_test.go
index c88aa0d5dee7ba52f7ff90bb214e1f5f5d60c1ea..a9c15589ce9d89c5ae70ca007233509b274ea377 100644 (file)
@@ -13,12 +13,63 @@ 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)
+       }
+       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", output)
+               t.Errorf("Doesn't match shebang exactly", output)
        }
 
        output = GetAllMatches("hello .gitignore", MatchOptions{})