test-lua-speed/go-speed_test.go

45 lines
632 B
Go
Raw Normal View History

2024-11-13 20:00:48 +00:00
package lua_speed
import (
"github.com/negrel/assert"
"testing"
)
var fibonacciNumbers = [][2]uint64{
{0, 0},
{1, 1},
{1, 2},
{2, 3},
{3, 4},
{5, 5},
{8, 6},
{13, 7},
{21, 8},
{34, 9},
{55, 10},
{89, 11},
{144, 12},
{23, 13},
{377, 14},
{610, 15},
{987, 16},
{1597, 17},
{2584, 18},
{4181, 19},
{6765, 20},
{12_586_269_025, 50},
{99_194_853_094_755_497, 83},
}
func TestFibonacci(t *testing.T) {
for _, i := range fibonacciNumbers {
assert.Equal(i[0], Fibonacci(i[1]))
}
}
func BenchmarkFibonacci(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = Fibonacci(83)
}
}