-
-
Notifications
You must be signed in to change notification settings - Fork 336
Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6f5bc6a
0de9751
b4dc07e
9b97ed0
7a64436
221bb71
f99a296
a1aff3b
f10a8d4
98734bf
71445dc
362f624
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,27 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
|
|
||
| // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. | ||
|
|
||
| // Special case: numerator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
| // Special case: denominator is zero | ||
| test("should return false when denominator is zero", () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| // Case: numerator is zero | ||
| test("should return true when numerator is zero and denominator is positive", () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| }); | ||
|
|
||
| // Proper fractions | ||
| test("should return true when abs(numerator) < abs(denominator)", () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also apply this notation to improper fractions.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! I updated the improper fraction test description to use the same abs notation and added a negative numerator/denominator case. |
||
| expect(isProperFraction(1, 2)).toBe(true); | ||
| expect(isProperFraction(-1, 2)).toBe(true); | ||
| expect(isProperFraction(1, -2)).toBe(true); | ||
| expect(isProperFraction(-1, -2)).toBe(true); | ||
| }); | ||
|
|
||
| // Improper fractions | ||
| test("should return false when abs(numerator) >= abs(denominator)", () => { | ||
| expect(isProperFraction(2, 2)).toBe(false); | ||
| expect(isProperFraction(3, 2)).toBe(false); | ||
| expect(isProperFraction(-3, 2)).toBe(false); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.