Things like nul.whatever.txt are also not allowed.
This commit is contained in:
@@ -44,3 +44,29 @@ func TestCommonPrefix(t *testing.T) {
|
||||
test(`Audrius`, `Audrius`, `Audrius`)
|
||||
test(`.`, `.`, `.`)
|
||||
}
|
||||
|
||||
func TestWindowsInvalidFilename(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
err error
|
||||
}{
|
||||
{`asdf.txt`, nil},
|
||||
{`nul`, errInvalidFilenameWindowsReservedName},
|
||||
{`nul.txt`, errInvalidFilenameWindowsReservedName},
|
||||
{`nul.jpg.txt`, errInvalidFilenameWindowsReservedName},
|
||||
{`some.nul.jpg`, nil},
|
||||
{`foo>bar.txt`, errInvalidFilenameWindowsReservedChar},
|
||||
{`foo \bar.txt`, errInvalidFilenameWindowsSpacePeriod},
|
||||
{`foo.\bar.txt`, errInvalidFilenameWindowsSpacePeriod},
|
||||
{`foo.d\bar.txt`, nil},
|
||||
{`foo.d\bar .txt`, nil},
|
||||
{`foo.d\bar. txt`, nil},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
err := WindowsInvalidFilename(tc.name)
|
||||
if err != tc.err {
|
||||
t.Errorf("For %q, got %v, expected %v", tc.name, err, tc.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user