style: improve test names of GetEuclidGCD' (#1646)

This commit is contained in:
Piotr Idzik
2024-03-28 12:12:40 +01:00
committed by GitHub
parent bd34e9fa61
commit 702840b4c8

View File

@ -1,25 +1,22 @@
import { GetEuclidGCD, GetEuclidGCDRecursive } from '../GetEuclidGCD'
describe.each([GetEuclidGCD, GetEuclidGCDRecursive])(
'%# GetEuclidGCD',
(gcdFunction) => {
it.each([
[5, 20, 5],
[109, 902, 1],
[290, 780, 10],
[104, 156, 52],
[0, 100, 100],
[-5, 50, 5],
[0, 0, 0],
[1, 1234567, 1]
])('returns correct result for %i and %j', (inputA, inputB, expected) => {
expect(gcdFunction(inputA, inputB)).toBe(expected)
expect(gcdFunction(inputB, inputA)).toBe(expected)
})
describe.each([GetEuclidGCD, GetEuclidGCDRecursive])('%o', (gcdFunction) => {
it.each([
[5, 20, 5],
[109, 902, 1],
[290, 780, 10],
[104, 156, 52],
[0, 100, 100],
[-5, 50, 5],
[0, 0, 0],
[1, 1234567, 1]
])('returns correct result for %i and %j', (inputA, inputB, expected) => {
expect(gcdFunction(inputA, inputB)).toBe(expected)
expect(gcdFunction(inputB, inputA)).toBe(expected)
})
it('should throw when any of the inputs is not a number', () => {
expect(() => gcdFunction('1', 2)).toThrowError()
expect(() => gcdFunction(1, '2')).toThrowError()
})
}
)
it('should throw when any of the inputs is not a number', () => {
expect(() => gcdFunction('1', 2)).toThrowError()
expect(() => gcdFunction(1, '2')).toThrowError()
})
})