forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtendedEuclideanGCD.test.js
More file actions
24 lines (23 loc) · 899 Bytes
/
ExtendedEuclideanGCD.test.js
File metadata and controls
24 lines (23 loc) · 899 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
import { extendedEuclideanGCD } from '../ExtendedEuclideanGCD'
describe('extendedEuclideanGCD', () => {
it('should return valid values in order for positive arguments', () => {
expect(extendedEuclideanGCD(240, 46)).toMatchObject([2, -9, 47])
expect(extendedEuclideanGCD(46, 240)).toMatchObject([2, 47, -9])
})
it('should give error on non-positive arguments', () => {
expect(() => extendedEuclideanGCD(0, 240)).toThrowError(
new TypeError('Must be positive numbers')
)
expect(() => extendedEuclideanGCD(46, -240)).toThrowError(
new TypeError('Must be positive numbers')
)
})
it('should give error on non-numeric arguments', () => {
expect(() => extendedEuclideanGCD('240', 46)).toThrowError(
new TypeError('Not a Number')
)
expect(() => extendedEuclideanGCD([240, 46])).toThrowError(
new TypeError('Not a Number')
)
})
})