-
-
Notifications
You must be signed in to change notification settings - Fork 367
London | 26-ITP-May | Zadri Abdule | Sprint 3 | Implement & rewrite tests #1329
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
19bace2
182860e
e836149
88b62a4
1d87aff
f9a21a9
2fb1964
80bcd7d
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 |
|---|---|---|
|
|
@@ -14,7 +14,37 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { | |
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| test(`should return "Right angle" when angle === 90`, () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| }); | ||
| // Case 3: Obtuse angles | ||
| test(`should return "Obtuse angle" when (90 < angle < 180)`, () => { | ||
| expect(getAngleType(91)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(135)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(179)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Straight angle | ||
| test(`should return "Straight angle" when angle === 180`, () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Reflex angles | ||
| test(`should return "Reflex angle" when (180 < angle < 360)`, () => { | ||
| expect(getAngleType(181)).toEqual("Reflex angle"); | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| expect(getAngleType(359)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
||
| // Case 6: Invalid angles | ||
| test(`should return "Invalid angle" when angle is not greater than 0`, () => { | ||
|
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. Why not simply express "not greater than 0" as In this case, |
||
| expect(getAngleType(-1)).toEqual("Invalid angle"); | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| }); | ||
|
|
||
| test(`should return "Invalid angle" when angle is not less than 360`, () => { | ||
| expect(getAngleType(360)).toEqual("Invalid angle"); | ||
| expect(getAngleType(1000)).toEqual("Invalid angle"); | ||
| expect(getAngleType(9999.999)).toEqual("Invalid angle"); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,36 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
| // Special case: numerator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| expect(isProperFraction(-1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return true when numerator is zero and denominator is non-zero`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| expect(isProperFraction(0, -1)).toEqual(true); | ||
| expect(isProperFraction(0, 100)).toEqual(true); | ||
| expect(isProperFraction(0, -100)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return true when absolute value of numerator is less than absolute value of 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. Note: Using pseudocode and notations like |
||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| expect(isProperFraction(1, -2)).toEqual(true); | ||
| expect(isProperFraction(-1, -2)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return false when absolute value of numerator is greater than or equal to absolute value of denominator`, () => { | ||
| expect(isProperFraction(1, 1)).toEqual(false); | ||
| expect(isProperFraction(2, 1)).toEqual(false); | ||
| expect(isProperFraction(-1, 1)).toEqual(false); | ||
| expect(isProperFraction(1, -1)).toEqual(false); | ||
| expect(isProperFraction(-1, -1)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`floating point values should be compared using absolute values`, () => { | ||
| expect(isProperFraction(0.5, 1)).toEqual(true); | ||
| expect(isProperFraction(1, 0.5)).toEqual(false); | ||
| expect(isProperFraction(-0.5, 1)).toEqual(true); | ||
| expect(isProperFraction(0.5, -1)).toEqual(true); | ||
| expect(isProperFraction(-0.5, -1)).toEqual(true); | ||
| }); | ||
|
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.
I could not find this test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of preparing
validRanks? Could using it simplify the solution?