Skip to content

Commit c11856b

Browse files
authored
Added tests for FibonacciGenerator
1 parent 787fd75 commit c11856b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Maths/test/Fibonacci.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
FibonacciDpWithoutRecursion,
33
FibonacciRecursiveDP,
44
FibonacciIterative,
5+
FibonacciGenerator,
56
FibonacciRecursive,
67
FibonacciMatrixExpo
78
} from '../Fibonacci'
@@ -16,6 +17,26 @@ describe('Fibonacci', () => {
1617
)
1718
})
1819

20+
it('should return number for FibonacciGenerator', () => {
21+
const positive = FibonacciGenerator()
22+
expect(positive.next().value).toBe(0)
23+
expect(positive.next().value).toBe(1)
24+
expect(positive.next().value).toBe(1)
25+
expect(positive.next().value).toBe(2)
26+
expect(positive.next().value).toBe(3)
27+
expect(positive.next().value).toBe(5)
28+
expect(positive.next().value).toBe(8)
29+
30+
const negative = FibonacciGenerator(true)
31+
expect(negative.next().value).toBe(0)
32+
expect(negative.next().value).toBe(1)
33+
expect(negative.next().value).toBe(-1)
34+
expect(negative.next().value).toBe(2)
35+
expect(negative.next().value).toBe(-3)
36+
expect(negative.next().value).toBe(5)
37+
expect(negative.next().value).toBe(-8)
38+
})
39+
1940
it('should return an array of numbers for FibonacciRecursive', () => {
2041
expect(FibonacciRecursive(6)).toEqual(
2142
expect.arrayContaining([0, 1, 1, 2, 3, 5, 8])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy