]> Sergey Matveev's repositories - path-extractor.git/blobdiff - pe_test.go
Add tests for file surrounded by `()`
[path-extractor.git] / pe_test.go
index 378e79ac31a6950aee1c52e1acc5e75505fcc242..844a0e56a69255fb5c2bd59185dc468df7729cde 100644 (file)
@@ -1,65 +1,95 @@
-package main
+package pathextractor
 
 import "testing"
 
 func TestGitIgnore(t *testing.T) {
-    output:=getAllMatches("?? alt/generateStore.php")
-    if output[0] != "alt/generateStore.php" {
-        t.Errorf("Doesnt match files", output[0])
-    }
-
-    output=getAllMatches("hello .gitignore")
-    if output[0] != ".gitignore" {
-        t.Errorf("Doesnt match hidden files", output[0])
-    }
-
-    output=getAllMatches(" mail@mail.com ")
-    if len(output) != 0 {
-        t.Errorf("Matches email adresses", output[0])
-    }
-
-    output=getAllMatches("v1.2")
-    if len(output) != 0 {
-        t.Errorf("Matches version number", output[0])
-    }
-
-    output=getAllMatches("obj.slice()")
-    if len(output) != 0 {
-        t.Errorf("Matches function call", output[0])
-    }
-
-    output=getAllMatches("~/www")
-    if len(output) == 0 || output[0] != "~/www" {
-        t.Errorf("Doesnt match home", output[0])
-    }
-
-    output=getAllMatches("origin/master")
-    if len(output) != 0 {
-        t.Errorf("Matches remote name", output[0])
-    }
-
-    output=getAllMatches("john doe (dead on 28/04/2014)")
-    if len(output) != 0 {
-        t.Errorf("Matches date", output[0])
-    }
-
-    output=getAllMatches("john doe ,dead on 28/04/2014")
-    if len(output) != 0 {
-        t.Errorf("Matches date", output[0])
-    }
-
-    output=getAllMatches(".gitignore , ~/www")
-    if len(output) != 2 {
-        t.Errorf("Doesnt match multi", output[0])
-    }
-
-    output=getAllMatches("var/")
-    if len(output) != 1 {
-        t.Errorf("Doesnt match dir", output[0])
-    }
-
-    output=getAllMatches("//")
-    if len(output) != 0 {
-        t.Errorf("Comment matches", output[0])
-    }
+       output := GetAllMatches("?? alt/generateStore.php")
+       if output[0] != "alt/generateStore.php" {
+               t.Errorf("Doesnt match files", output)
+       }
+
+       output = GetAllMatches("I have a cat.")
+       if len(output) != 0 {
+               t.Errorf("Matches sentence", output)
+       }
+
+       output = GetAllMatches("hello .gitignore")
+       if output[0] != ".gitignore" {
+               t.Errorf("Doesnt match hidden files", output)
+       }
+
+       output = GetAllMatches(" this.user ")
+       if len(output) != 0 {
+               t.Errorf("Matches this.user", output)
+       }
+
+       output = GetAllMatches(" mail@mail.com ")
+       if len(output) != 0 {
+               t.Errorf("Matches email adresses", output)
+       }
+
+       output = GetAllMatches(" logo@2x.png ")
+       if len(output) == 0 {
+               t.Errorf("Doesn't match retina asset", output)
+       }
+
+       output = GetAllMatches("and/or")
+       if len(output) != 0 {
+               t.Errorf("Matches and/or adresses", output)
+       }
+
+       output = GetAllMatches("v1.2")
+       if len(output) != 0 {
+               t.Errorf("Matches version number", output)
+       }
+
+       output = GetAllMatches("obj.slice()")
+       if len(output) != 0 {
+               t.Errorf("Matches function call", output)
+       }
+
+       output = GetAllMatches("~/www")
+       if len(output) == 0 || output[0] != "~/www" {
+               t.Errorf("Doesnt match home", output)
+       }
+
+       output = GetAllMatches("origin/master")
+       if len(output) != 0 {
+               t.Errorf("Matches remote name", output)
+       }
+
+       output = GetAllMatches("john doe (dead on 28/04/2014)")
+       if len(output) != 0 {
+               t.Errorf("Matches date", output)
+       }
+
+       output = GetAllMatches("john doe ,dead on 28/04/2014")
+       if len(output) != 0 {
+               t.Errorf("Matches date", output)
+       }
+
+       output = GetAllMatches(".gitignore , ~/www")
+       if len(output) != 2 {
+               t.Errorf("Doesnt match multi", output)
+       }
+
+       output = GetAllMatches("user.test.js")
+       if len(output) != 1 {
+               t.Errorf("Doesnt match multiple extensions", output)
+       }
+
+       output = GetAllMatches("(user.js)")
+       if len(output) != 1 {
+               t.Errorf("Doesnt match surrounded by parens", output)
+       }
+
+       output = GetAllMatches("var/")
+       if len(output) != 1 {
+               t.Errorf("Doesnt match dir", output)
+       }
+
+       output = GetAllMatches("//")
+       if len(output) != 0 {
+               t.Errorf("Comment matches", output)
+       }
 }