Skip to content

Commit a545f76

Browse files
authored
merge: Add test case of SquareRoot function (TheAlgorithms#926)
1 parent 0924f1c commit a545f76

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Maths/test/SquareRoot.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { sqrt } from '../SquareRoot'
2+
3+
test('Check SquareRoot of 4 is 2', () => {
4+
const res = sqrt(4, 10)
5+
expect(res).toBeCloseTo(2)
6+
})
7+
8+
test('Check SquareRoot of 2 is 1.4142135', () => {
9+
const res = sqrt(2, 10)
10+
expect(res).toBeCloseTo(1.4142135)
11+
})
12+
13+
test('Check SquareRoot of 3.2 is 1.788854381999832', () => {
14+
const res = sqrt(3.2, 10)
15+
expect(res).toBeCloseTo(1.788854381999832)
16+
})
17+
18+
test('Check SquareRoot of 1 is 1', () => {
19+
const res = sqrt(1, 10)
20+
expect(res).toBe(1)
21+
})
22+
23+
test('Check SquareRoot of 144 is 12', () => {
24+
const res = sqrt(144, 10)
25+
expect(res).toBeCloseTo(12)
26+
})
27+
28+
test('Check SquareRoot of 0 is 0', () => {
29+
const res = sqrt(0, 10)
30+
expect(res).toBeCloseTo(0)
31+
})
32+
33+
test('Check SquareRoot of 1000 is 31.62277', () => {
34+
const res = sqrt(1000, 10)
35+
expect(res).toBeCloseTo(31.62277)
36+
})

0 commit comments

Comments
 (0)