-
-
Notifications
You must be signed in to change notification settings - Fork 337
Sheffield | ITP-Jan-26| Mona_Eltantawy | Sprint 3 | Sprint 3/ implement and testing data #1280
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 6 commits
646d6a5
bc93560
9f2ebc3
8f148b8
e7d0002
bbf99ca
7b922da
7adde95
9d68b4e
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 |
|---|---|---|
|
|
@@ -6,15 +6,54 @@ const getAngleType = require("../implement/1-get-angle-type"); | |
| // including boundary and invalid cases. | ||
|
|
||
| // Case 1: Acute angles | ||
| test(`should return "Acute angle" when (0 < angle < 90)`, () => { | ||
| // Test various acute angles, including boundary cases | ||
| expect(getAngleType(1)).toEqual("Acute angle"); | ||
| expect(getAngleType(45)).toEqual("Acute angle"); | ||
| expect(getAngleType(89)).toEqual("Acute angle"); | ||
| describe("Acute angle", () => { | ||
| test("valid acute angles", () => { | ||
| expect(getAngleType(1)).toBe("Acute angle"); | ||
| expect(getAngleType(45)).toBe("Acute angle"); | ||
| expect(getAngleType(89)).toBe("Acute angle"); | ||
| }); | ||
|
|
||
| test("boundary cases are NOT acute", () => { | ||
| expect(getAngleType(0)).not.toBe("Acute angle"); | ||
| expect(getAngleType(90)).not.toBe("Acute angle"); | ||
| }); | ||
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| describe("Right angle", () => { | ||
| test("should return 'Right angle' when angle is 90", () => { | ||
| expect(getAngleType(90)).toBe("Right angle"); | ||
| }); | ||
| }); | ||
|
|
||
| // Case 3: Obtuse angles | ||
| describe("Obtuse angle", () => { | ||
| test("should return 'Obtuse angle' when (90 < angle < 180)", () => { | ||
| expect(getAngleType(95)).toBe("Obtuse angle"); | ||
| expect(getAngleType(120)).toBe("Obtuse angle"); | ||
| expect(getAngleType(100)).toBe("Obtuse angle"); | ||
| }); | ||
| }); | ||
|
|
||
| // Case 4: Straight angle | ||
| describe("Straight angle", () => { | ||
| test("should return 'Straight angle' when angle is 180", () => { | ||
| expect(getAngleType(180)).toBe("Straight angle"); | ||
| }); | ||
| }); | ||
| // Case 5: Reflex angles | ||
| describe("Reflex angle", () => { | ||
| test("should return 'Reflex angle' when (180 < angle < 360)", () => { | ||
| expect(getAngleType(190)).toBe("Reflex angle"); | ||
| expect(getAngleType(300)).toBe("Reflex angle"); | ||
| expect(getAngleType(200)).toBe("Reflex angle"); | ||
| }); | ||
| }); | ||
| // Case 6: Invalid angles | ||
| describe("Invalid angle", () => { | ||
| test("should return 'Invalid angle' when (angle <= 0 or angle > 360)", () => { | ||
| expect(getAngleType(0)).toBe("Invalid angle"); | ||
| expect(getAngleType(400)).toBe("Invalid angle"); | ||
| expect(getAngleType(-10)).toBe("Invalid angle"); | ||
| }); | ||
| }); | ||
|
Comment on lines
+53
to
+60
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.
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. I added the boundary cases
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 didn't update the test description. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,42 @@ | |
| // We will use the same function, but write tests for it using Jest in this file. | ||
| 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`, () => { | ||
| // denominator is zero | ||
| test("should return false when denominator is zero", () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| // proper fraction (numerator < denominator) | ||
| test("should return true when numerator < denominator", () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| }); | ||
|
|
||
| // improper fraction (numerator > denominator) | ||
| test("should return false when numerator > denominator", () => { | ||
| expect(isProperFraction(5, 3)).toEqual(false); | ||
| }); | ||
|
|
||
| // equal numbers | ||
| test("should return false when numerator === denominator", () => { | ||
| expect(isProperFraction(4, 4)).toEqual(false); | ||
| }); | ||
|
|
||
| // numerator is zero | ||
| test("should return true when numerator is zero and denominator is positive", () => { | ||
| expect(isProperFraction(0, 5)).toEqual(true); | ||
| }); | ||
|
|
||
| // negative numerator | ||
| test("should return false when numerator is negative", () => { | ||
| expect(isProperFraction(-2, 4)).toEqual(false); | ||
| }); | ||
|
|
||
| // negative denominator | ||
| test("should return false when denominator is negative", () => { | ||
| expect(isProperFraction(5, -4)).toEqual(false); | ||
| }); | ||
|
|
||
| // both negative | ||
| test("should return false when both numerator and denominator are negative", () => { | ||
| expect(isProperFraction(-3, -5)).toEqual(false); | ||
| }); | ||
|
Comment on lines
+29
to
+41
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. Can your function pass all these tests? We can use pseudo-code and notations like
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. I fixed the function to pass all the tests |
||
|
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. This file should contain the tests for
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. done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,43 @@ | ||
| // This statement loads the getCardValue function you wrote in the implement directory. | ||
| // This statement loads the isProperFraction function you wrote in the implement directory. | ||
| // We will use the same function, but write tests for it using Jest in this file. | ||
| const getCardValue = require("../implement/3-get-card-value"); | ||
| const isProperFraction = require("../implement/2-is-proper-fraction"); | ||
|
|
||
| // TODO: Write tests in Jest syntax to cover all possible outcomes. | ||
| // denominator is zero | ||
| test("should return false when denominator is zero", () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| // proper fraction (numerator < denominator) | ||
| test("should return true when numerator < denominator", () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| }); | ||
|
|
||
| // improper fraction (numerator > denominator) | ||
| test("should return false when numerator > denominator", () => { | ||
| expect(isProperFraction(5, 3)).toEqual(false); | ||
| }); | ||
|
|
||
| // Case 1: Ace (A) | ||
| test(`Should return 11 when given an ace card`, () => { | ||
| expect(getCardValue("A♠")).toEqual(11); | ||
| // equal numbers | ||
| test("should return false when numerator === denominator", () => { | ||
| expect(isProperFraction(4, 4)).toEqual(false); | ||
| }); | ||
|
|
||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| // Face Cards (J, Q, K) | ||
| // Invalid Cards | ||
| // numerator is zero | ||
| test("should return true when numerator is zero and denominator is positive", () => { | ||
| expect(isProperFraction(0, 5)).toEqual(true); | ||
| }); | ||
|
|
||
| // To learn how to test whether a function throws an error as expected in Jest, | ||
| // please refer to the Jest documentation: | ||
| // https://jestjs.io/docs/expect#tothrowerror | ||
| // negative numerator | ||
| test("should return false when numerator is negative", () => { | ||
| expect(isProperFraction(-2, 4)).toEqual(false); | ||
| }); | ||
|
|
||
| // negative denominator | ||
| test("should return false when denominator is negative", () => { | ||
| expect(isProperFraction(5, -4)).toEqual(false); | ||
| }); | ||
|
|
||
| // both negative | ||
| test("should return false when both numerator and denominator are negative", () => { | ||
| expect(isProperFraction(-3, -5)).toEqual(false); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.