github.com/3JoB/vfs@v1.0.0/path_test.go (about) 1 package vfs 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestSplitPath(t *testing.T) { 9 const PathSeperator = "/" 10 if p := SplitPath("/", PathSeperator); !reflect.DeepEqual(p, []string{""}) { 11 t.Errorf("Invalid path: %q", p) 12 } 13 if p := SplitPath("./test", PathSeperator); !reflect.DeepEqual(p, []string{".", "test"}) { 14 t.Errorf("Invalid path: %q", p) 15 } 16 if p := SplitPath(".", PathSeperator); !reflect.DeepEqual(p, []string{"."}) { 17 t.Errorf("Invalid path: %q", p) 18 } 19 if p := SplitPath("test", PathSeperator); !reflect.DeepEqual(p, []string{".", "test"}) { 20 t.Errorf("Invalid path: %q", p) 21 } 22 if p := SplitPath("/usr/src/linux/", PathSeperator); !reflect.DeepEqual(p, []string{"", "usr", "src", "linux"}) { 23 t.Errorf("Invalid path: %q", p) 24 } 25 if p := SplitPath("usr/src/linux/", PathSeperator); !reflect.DeepEqual(p, []string{".", "usr", "src", "linux"}) { 26 t.Errorf("Invalid path: %q", p) 27 } 28 }