Backoff and Randomness additions for use in client utilities
Updated String to use int, and int not to panic, and panic to test panic Format fixes.
This commit is contained in:
@@ -37,6 +37,27 @@ func TestString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm that panic occurs on invalid input.
|
||||
func TestRangePanic(t *testing.T) {
|
||||
defer func() {
|
||||
if err := recover(); err == nil {
|
||||
t.Errorf("Panic didn't occur!")
|
||||
}
|
||||
}()
|
||||
// Should result in an error...
|
||||
Intn(0)
|
||||
}
|
||||
|
||||
func TestIntn(t *testing.T) {
|
||||
// 0 is invalid.
|
||||
for _, max := range []int{1, 2, 10, 123} {
|
||||
inrange := Intn(max)
|
||||
if inrange < 0 || inrange > max {
|
||||
t.Errorf("%v out of range (0,%v)", inrange, max)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPerm(t *testing.T) {
|
||||
Seed(5)
|
||||
rand.Seed(5)
|
||||
|
Reference in New Issue
Block a user