enhancement: FindLCM algorithm (#1222)

Co-authored-by: patrickwestervelt <pwestervelt3@gatech.edu>
This commit is contained in:
Psytew
2022-10-23 03:19:19 -04:00
committed by GitHub
parent 63a3394d95
commit 8c27d86afc
2 changed files with 44 additions and 8 deletions

View File

@@ -1,20 +1,39 @@
import { findLcm } from '../FindLcm'
import { findLcm, findLcmWithHcf } from '../FindLcm'
describe('findLcm', () => {
it('should throw a statement for values less than 1', () => {
expect(findLcm(0, 0)).toBe('Please enter values greater than zero.')
expect(() => { findLcm(0, 0) }).toThrow(Error)
})
it('should throw a statement for one value less than 1', () => {
expect(findLcm(1, 0)).toBe('Please enter values greater than zero.')
expect(findLcm(0, 1)).toBe('Please enter values greater than zero.')
expect(() => { findLcm(1, 0) }).toThrow(Error)
expect(() => { findLcm(0, 1) }).toThrow(Error)
})
it('should return an error for values non-integer values', () => {
expect(findLcm(4.564, 7.39)).toBe('Please enter whole numbers.')
expect(() => { findLcm(4.564, 7.39) }).toThrow(Error)
})
it('should return the LCM of two given integers', () => {
expect(findLcm(27, 36)).toBe(108)
})
})
describe('findLcmWithHcf', () => {
it('should throw a statement for values less than 1', () => {
expect(() => { findLcmWithHcf(0, 0) }).toThrow(Error)
})
it('should throw a statement for one value less than 1', () => {
expect(() => { findLcmWithHcf(1, 0) }).toThrow(Error)
expect(() => { findLcmWithHcf(0, 1) }).toThrow(Error)
})
it('should return an error for values non-integer values', () => {
expect(() => { findLcmWithHcf(4.564, 7.39) }).toThrow(Error)
})
it('should return the LCM of two given integers', () => {
expect(findLcmWithHcf(27, 36)).toBe(108)
})
})