mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
algorithm: logarithmic square root (#1259)
* algorithm: add SquareRootLogarithmic algo and a test for it * fix: fix spelling errors * refactor: rename a variable "e" --> "edge"
This commit is contained in:
13
Maths/test/SquareRootLogarithmic.test.js
Normal file
13
Maths/test/SquareRootLogarithmic.test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { squareRootLogarithmic } from '../SquareRootLogarithmic'
|
||||
|
||||
describe('SquareRootLogarithmic', () => {
|
||||
test('Finding the square root of a positive integer', () => {
|
||||
expect(squareRootLogarithmic(4)).toEqual(2)
|
||||
expect(squareRootLogarithmic(16)).toEqual(4)
|
||||
expect(squareRootLogarithmic(8)).toEqual(2)
|
||||
})
|
||||
test('Throwing an exception', () => {
|
||||
expect(() => squareRootLogarithmic('not a number')).toThrow()
|
||||
expect(() => squareRootLogarithmic(true)).toThrow()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user