Fix for alphabets of 256 characters.
Also, panic if given more.
This commit is contained in:
parent
7dd3037eec
commit
b09047d1ee
2 changed files with 23 additions and 3 deletions
|
|
@ -50,4 +50,20 @@ func TestNewLenChars(t *testing.T) {
|
|||
}
|
||||
// Check that only allowed characters are present
|
||||
validateChars(t, u, chars)
|
||||
|
||||
// Check that two generated strings are different
|
||||
u2 := NewLenChars(length, chars)
|
||||
if u == u2 {
|
||||
t.Fatalf("not unique: %q and %q", u, u2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewLenCharsMaxLength(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
t.Fatal("didn't panic")
|
||||
}
|
||||
}()
|
||||
chars := make([]byte, 257)
|
||||
NewLenChars(32, chars)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue