mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00

* remove intarr test * Remove main file oops * FIXES: #1666 , remove references to SieveOfEratosthenesIntArray * Finally fix the requirements, passes vitest * Updated Documentation in README.md * FIXES: #1666 and conform to alg comment standards --------- Co-authored-by: SpiderMath <SpiderMath@users.noreply.github.com>
30 lines
848 B
JavaScript
30 lines
848 B
JavaScript
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
|
|
])
|
|
})
|
|
})
|