github.com/songzhibin97/gkit@v1.2.13/distributed/retry/fibonacci_test.go (about) 1 package retry 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6 ) 7 8 func TestFibonacci(t *testing.T) { 9 fibonacci := Fibonacci() 10 11 sequence := []int{ 12 fibonacci(), 13 fibonacci(), 14 fibonacci(), 15 fibonacci(), 16 fibonacci(), 17 fibonacci(), 18 } 19 20 assert.EqualValues(t, sequence, []int{1, 1, 2, 3, 5, 8}) 21 } 22 23 func TestFibonacciNext(t *testing.T) { 24 assert.Equal(t, 1, FibonacciNext(0)) 25 assert.Equal(t, 2, FibonacciNext(1)) 26 assert.Equal(t, 5, FibonacciNext(3)) 27 assert.Equal(t, 5, FibonacciNext(4)) 28 assert.Equal(t, 8, FibonacciNext(5)) 29 assert.Equal(t, 13, FibonacciNext(8)) 30 }