Fix hanging when requested zero-length string.

Add test for NewLen from 0 to 100.
This commit is contained in:
Dmitry Chestnykh 2015-01-21 18:36:13 +01:00
parent e80eb311f3
commit 7668ee6861
2 changed files with 12 additions and 0 deletions

View file

@ -46,6 +46,15 @@ func TestNew(t *testing.T) {
}
}
func TestNewLen(t *testing.T) {
for i := 0; i < 100; i++ {
u := NewLen(i)
if len(u) != i {
t.Fatalf("request length %d, got %d", i, len(u))
}
}
}
func TestNewLenChars(t *testing.T) {
length := 10
chars := []byte("01234567")