forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSieveOfEratosthenes.test.js
More file actions
29 lines (23 loc) · 848 Bytes
/
SieveOfEratosthenes.test.js
File metadata and controls
29 lines (23 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { sieveOfEratosthenes } from '../SieveOfEratosthenes'
describe('sieveOfEratosthenes', () => {
test('returns an empty array for max < 2', () => {
expect(sieveOfEratosthenes(1)).toEqual([])
})
test('returns [2] for max = 2', () => {
expect(sieveOfEratosthenes(2)).toEqual([2])
})
test('returns [2, 3] for max = 3', () => {
expect(sieveOfEratosthenes(3)).toEqual([2, 3])
})
test('returns [2, 3, 5, 7] for max = 10', () => {
expect(sieveOfEratosthenes(10)).toEqual([2, 3, 5, 7])
})
test('returns [2, 3, 5, 7, 11, 13, 17, 19] for max = 20', () => {
expect(sieveOfEratosthenes(20)).toEqual([2, 3, 5, 7, 11, 13, 17, 19])
})
test('returns [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] for max = 30', () => {
expect(sieveOfEratosthenes(30)).toEqual([
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
])
})
})