Skip to content

Commit 48b8dae

Browse files
author
russom
committed
Write cases for testing proper and improper fractions.
1 parent f12c635 commit 48b8dae

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,58 @@ test("Basic proper fraction", () => {
1010
// Example: 1/2 is a proper fraction
1111
assert.equal(isProperFraction(1, 2), true);
1212
});
13+
14+
// Proper fraction
15+
test("Decimal proper fraction", () => {
16+
assert.equal(isProperFraction(0.5, 1.5), true);
17+
});
18+
19+
test("0 numerator proper fraction", () => {
20+
assert.equal(isProperFraction(0, 5), true);
21+
});
22+
23+
test("Negative numerator proper fraction", () => {
24+
assert.equal(isProperFraction(-9, 1), true);
25+
});
26+
27+
test("Both negatives proper fraction", () => {
28+
assert.equal(isProperFraction(-7, -3), true);
29+
});
30+
31+
test("Large number proper fraction", () => {
32+
assert.equal(isProperFraction(999, 1000), true);
33+
});
34+
35+
test("Very small denominator proper fraction", () => {
36+
assert.equal(isProperFraction(1, 1000000), true);
37+
});
38+
39+
// Improper fractions
40+
41+
test("Decimal improper fraction", () => {
42+
assert.equal(isProperFraction(1.2, 1.1), false);
43+
});
44+
45+
test("Numerator larger improper fraction", () => {
46+
assert.equal(isProperFraction(5, 3), false);
47+
});
48+
49+
test("Both equal improper fraction", () => {
50+
assert.equal(isProperFraction(4, 4), false);
51+
});
52+
53+
test("0 denominator improper fraction", () => {
54+
assert.equal(isProperFraction(7, 0), false);
55+
});
56+
57+
test("Both 0 improper fraction", () => {
58+
assert.equal(isProperFraction(0, 0), false);
59+
});
60+
61+
test("Both equal negatives improper fraction", () => {
62+
assert.equal(isProperFraction(-4, -4), false);
63+
});
64+
65+
test("Negative denominator improper fraction", () => {
66+
assert.equal(isProperFraction(2, -9), false);
67+
});

0 commit comments

Comments
 (0)