Skip to content

Commit 7dcc6d3

Browse files
committed
Fix: Use toBeCloseTo for floating point sum test
1 parent fb96503 commit 7dcc6d3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Sprint-1/implement/sum.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ test("given an array with negative numbers, returns the correct sum", () => {
3737
// Then it should return the correct total sum
3838
test("given an array with decimal numbers, returns the correct sum", () => {
3939
expect(sum([1.5, 2.5, 3.0])).toEqual(7);
40+
// toBeCloseTo is used for floating point calculations to avoid precision issues
41+
expect(sum([1.2, 0.6, 0.005])).toBeCloseTo(1.805);
4042
});
4143

4244
// Given an array containing non-number values

0 commit comments

Comments
 (0)