mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
solution: Project Euler Problem 28 (#1198)
This commit is contained in:
17
Project-Euler/test/Problem028.test.js
Normal file
17
Project-Euler/test/Problem028.test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { problem28 } from '../Problem028.js'
|
||||
|
||||
describe('checking number spiral diagonals', () => {
|
||||
it('should be invalid input if number is negative', () => {
|
||||
expect(() => problem28(-3)).toThrowError('Dimension must be positive')
|
||||
})
|
||||
it('should be invalid input if number is not odd', () => {
|
||||
expect(() => problem28(4)).toThrowError('Dimension must be odd')
|
||||
})
|
||||
test('if the number is equal to 5 result should be 101', () => {
|
||||
expect(problem28(5)).toBe(101)
|
||||
})
|
||||
// Project Euler Condition Check
|
||||
test('if the number is equal to 1001 result should be 669171001', () => {
|
||||
expect(problem28(1001)).toBe(669171001)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user