mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Adding tests to tribonacci
This commit is contained in:
parent
c18fd28d0f
commit
a9b6118b04
16
src/algorithms/math/tribonacci/__test__/tribonacci.test.js
Normal file
16
src/algorithms/math/tribonacci/__test__/tribonacci.test.js
Normal file
@ -0,0 +1,16 @@
|
||||
import tribonacci from '../tribonacci';
|
||||
|
||||
describe('tribonacci', () => {
|
||||
it('should calculate tribonacci correctly', () => {
|
||||
expect(tribonacci(1)).toEqual([0]);
|
||||
expect(tribonacci(2)).toEqual([0, 0]);
|
||||
expect(tribonacci(3)).toEqual([0, 0, 1]);
|
||||
expect(tribonacci(4)).toEqual([0, 0, 1, 1]);
|
||||
expect(tribonacci(5)).toEqual([0, 0, 1, 1, 2]);
|
||||
expect(tribonacci(6)).toEqual([0, 0, 1, 1, 2, 4]);
|
||||
expect(tribonacci(7)).toEqual([0, 0, 1, 1, 2, 4, 7]);
|
||||
expect(tribonacci(8)).toEqual([0, 0, 1, 1, 2, 4, 7, 13]);
|
||||
expect(tribonacci(9)).toEqual([0, 0, 1, 1, 2, 4, 7, 13, 24]);
|
||||
expect(tribonacci(10)).toEqual([0, 0, 1, 1, 2, 4, 7, 13, 24, 44]);
|
||||
});
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
import tribonacciNth from '../tribonacciNth';
|
||||
|
||||
describe('tribonacciNth', () => {
|
||||
it('should calculate tribonacci correctly', () => {
|
||||
expect(tribonacciNth(1)).toBe(0);
|
||||
expect(tribonacciNth(2)).toBe(1);
|
||||
expect(tribonacciNth(3)).toBe(1);
|
||||
expect(tribonacciNth(4)).toBe(2);
|
||||
expect(tribonacciNth(5)).toBe(4);
|
||||
expect(tribonacciNth(6)).toBe(7);
|
||||
expect(tribonacciNth(7)).toBe(13);
|
||||
expect(tribonacciNth(8)).toBe(24);
|
||||
expect(tribonacciNth(20)).toBe(35890);
|
||||
expect(tribonacciNth(30)).toBe(15902591);
|
||||
expect(tribonacciNth(50)).toBe(3122171529233);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user