Source file
src/io/fs/fs_test.go
Documentation: io/fs
1
2
3
4
5 package fs_test
6
7 import (
8 . "io/fs"
9 "testing"
10 )
11
12 var isValidPathTests = []struct {
13 name string
14 ok bool
15 }{
16 {".", true},
17 {"x", true},
18 {"x/y", true},
19
20 {"", false},
21 {"..", false},
22 {"/", false},
23 {"x/", false},
24 {"/x", false},
25 {"x/y/", false},
26 {"/x/y", false},
27 {"./", false},
28 {"./x", false},
29 {"x/.", false},
30 {"x/./y", false},
31 {"../", false},
32 {"../x", false},
33 {"x/..", false},
34 {"x/../y", false},
35 {"x//y", false},
36 {`x\`, true},
37 {`x\y`, true},
38 {`x:y`, true},
39 {`\x`, true},
40 }
41
42 func TestValidPath(t *testing.T) {
43 for _, tt := range isValidPathTests {
44 ok := ValidPath(tt.name)
45 if ok != tt.ok {
46 t.Errorf("ValidPath(%q) = %v, want %v", tt.name, ok, tt.ok)
47 }
48 }
49 }
50
View as plain text