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:
jay vyas
2015-11-05 09:02:51 -05:00
committed by jay vyas
parent 3a5e7d15f7
commit 7ffaef63d1
4 changed files with 50 additions and 11 deletions

View File

@@ -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)