This commit is contained in:
@@ -490,3 +490,29 @@ func TestNewBasicFilesystem(t *testing.T) {
|
||||
t.Errorf(`newBasicFilesystem("relative/path").root == %q, expected absolutification`, fs.root)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRel(t *testing.T) {
|
||||
testCases := []struct {
|
||||
root string
|
||||
abs string
|
||||
expectedRel string
|
||||
}{
|
||||
{"/", "/", ""},
|
||||
{"/", "/test", "test"},
|
||||
{"/", "/Test", "Test"},
|
||||
{"/Test", "/Test/test", "test"},
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
for i := range testCases {
|
||||
testCases[i].root = filepath.FromSlash(testCases[i].root)
|
||||
testCases[i].abs = filepath.FromSlash(testCases[i].abs)
|
||||
testCases[i].expectedRel = filepath.FromSlash(testCases[i].expectedRel)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
if res := rel(tc.abs, tc.root); res != tc.expectedRel {
|
||||
t.Errorf(`rel("%v", "%v") == "%v", expected "%v"`, tc.abs, tc.root, res, tc.expectedRel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user