diff options
Diffstat (limited to 'internal/nametransform/names_test.go')
-rw-r--r-- | internal/nametransform/names_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/nametransform/names_test.go b/internal/nametransform/names_test.go index 9d77c2d..b4e98d4 100644 --- a/internal/nametransform/names_test.go +++ b/internal/nametransform/names_test.go @@ -2,6 +2,7 @@ package nametransform import ( "bytes" + "strings" "testing" ) @@ -51,3 +52,26 @@ func TestUnpad16Garbage(t *testing.T) { } } } + +func TestIsValidName(t *testing.T) { + cases := []struct { + in string + want bool + }{ + {"", false}, + {".", false}, + {"..", false}, + {"...", true}, + {"asdasd/asdasd", false}, + {"asdasd\000asdasd", false}, + {"hello", true}, + {strings.Repeat("x", 255), true}, + {strings.Repeat("x", 256), false}, + } + for _, c := range cases { + have := IsValidName(c.in) + if (have == nil) != c.want { + t.Errorf("IsValidName(%q): want %v have %v", c.in, c.want, have) + } + } +} |