Skip to content

Commit cd8ba7b

Browse files
add comprehensive tests for isProperFraction function to cover various cases
1 parent 5d4a5d7 commit cd8ba7b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,33 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
66
// TODO: Write tests to cover all cases.
77
// What combinations of numerators and denominators should you test?
88

9+
910
test("Basic proper fraction", () => {
1011
// Example: 1/2 is a proper fraction
1112
assert.equal(isProperFraction(1, 2), true);
13+
assert.equal(isProperFraction(3, 4), true);
14+
});
15+
16+
test("Improper fraction where numerator is larger than denominator", () => {
17+
assert.equal(isProperFraction(5, 2), false);
18+
assert.equal(isProperFraction(4, 3), false);
19+
});
20+
21+
test("Equal numerator and denominator (equals 1)", () => {
22+
assert.equal(isProperFraction(3, 3), false);
1223
});
24+
25+
test("Denominator is zero", () => {
26+
assert.equal(isProperFraction(1, 0), false);
27+
assert.equal(isProperFraction(0, 0), false);
28+
});
29+
30+
test("Zero numerator with non-zero denominator", () => {
31+
assert.equal(isProperFraction(0, 5), true);
32+
});
33+
34+
test("Negative numbers", () => {
35+
assert.equal(isProperFraction(-1, 2), true);
36+
assert.equal(isProperFraction(1, -2), true);
37+
assert.equal(isProperFraction(-3, -2), false);
38+
});

0 commit comments

Comments
 (0)