Repository navigation
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework. Keep it up.
| // Scenario: No Occurrences | ||
| // Given the input string `str`, | ||
| // And a character `char` that does not exist within `str`. | ||
| // When the function is called with these inputs, | ||
| // Then it should return 0, indicating that no occurrences of `char` were found. | ||
|
|
||
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "z"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); | ||
|
|
||
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "7"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
These two test case are similar. However, there is a special str which also gives 0. Can you think of it? If so, please add it as well. Thank you.
| test("should append 'th' for numbers ending with 4, except those ending with 0", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(144)).toEqual("144th"); | ||
| expect(getOrdinalNumber(40)).toEqual("40th"); | ||
| }); |
There was a problem hiding this comment.
There should be more test cases related to lines 4-6 of your program. Please add them into this test suite. Thank you.
There was a problem hiding this comment.
Your test cases are correct. Just for you to think a little bit more, besides const str = "hello", what special string should also be added to each of the test cases?
There was a problem hiding this comment.
Changing "hello" into other strings are testing the same thing, but it is good that you have added the empty string as the final test case. Just in the future, it would be better to consider testing the empty string for count is 3, 1, 0, -1 respectively and see whether they all returns 0 (which is not correct) or still throws error for the negative count (which is correct). Since your program code is correct, I would let you pass this time. If you would like to learn more about test cases design process, please book a mentored coding session with a volunteer. Thank you.
|
Congratulation, you have completed this PR successfully. |
Task code
CYF-1060
Changelist
29/10 - "added more test cases to the files as advised by the reviewer"
Updated files in question