debugging DefaltApplyJitter, adding tests
This commit is contained in:
@@ -93,6 +93,8 @@ func Fibonacci(n int64) int64 {
|
||||
case n >= int64(len(TheFibonacciSequence)):
|
||||
panic(fmt.Sprintf("invalid input: %d overflows int64\n",
|
||||
n))
|
||||
case n < 0:
|
||||
panic(fmt.Sprintf("invalid input: %d would cause index out of range panic\n", n))
|
||||
default:
|
||||
return TheFibonacciSequence[n]
|
||||
}
|
||||
|
||||
@@ -2,19 +2,12 @@ package fibonacci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"code.wmdillon.com/wmdillon/backoff/utilities"
|
||||
)
|
||||
|
||||
func wouldOverflow(a, b int64) (product int64, overflows bool) {
|
||||
results := new(big.Int).Mul(big.NewInt(a), big.NewInt(b))
|
||||
return results.Int64(), results.IsInt64()
|
||||
}
|
||||
|
||||
func fibonacci(n int64) int64 {
|
||||
switch {
|
||||
case n <= 0:
|
||||
@@ -129,7 +122,6 @@ func TestFibonacciPauseLimit(t *testing.T) {
|
||||
t.Fatalf("error for %d: expected value in range %s - %s; got %s\n", input, min, max, got)
|
||||
}
|
||||
}
|
||||
fmt.Printf("finished\n")
|
||||
}
|
||||
|
||||
func TestFibonacciBackoffAfter(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user