mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
feature: add fast fibonacci algorithm (#1155)
This commit is contained in:
23
Dynamic-Programming/tests/FastFibonacciNumber.test.js
Normal file
23
Dynamic-Programming/tests/FastFibonacciNumber.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { fastFibonacci } from '../FastFibonacciNumber'
|
||||
|
||||
describe('Testing FibonacciNumber', () => {
|
||||
const errorCases = ['0', '12', true]
|
||||
|
||||
test.each(errorCases)('throws an error if %p is invalid', (input) => {
|
||||
expect(() => {
|
||||
fastFibonacci(input)
|
||||
}).toThrow()
|
||||
})
|
||||
|
||||
const testCases = [
|
||||
[0, 0],
|
||||
[1, 1],
|
||||
[10, 55],
|
||||
[25, 75025],
|
||||
[40, 102334155]
|
||||
]
|
||||
|
||||
test.each(testCases)('if input is %i it returns %i', (input, expected) => {
|
||||
expect(fastFibonacci(input)).toBe(expected)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user