Skip to content

style: improve test names of GetEuclidGCD #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions Maths/test/GetEuclidGCD.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
Loading