Repository navigation
London | 26-ITP-Sep | Mahir Shah | Sprint 2 | Practice TDD - #1696
MahirShah300 wants to merge 13 commits into
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
The code generally looks good to me. Keep it up.
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(5); | ||
| }); | ||
|
|
||
| test("should count multiple occurrences of a character when mixed with other characters", () => { | ||
| const str = "ababa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(3); | ||
| }); | ||
|
|
||
| test("should count multiple occurrences of a character at the beginning and end of a string", () => { | ||
| const str = "abbba"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(2); | ||
| }); |
There was a problem hiding this comment.
The 3 cases are all testing str which both starts and ends with the char. Would the program still work correctly if char just exists in the middle part of str?
There was a problem hiding this comment.
I added a test for char in the middle of str
| test("Should count 0 occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "b"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
There is a special str that would give 0 anyway. Please add that test case as well. Thank you.
There was a problem hiding this comment.
I added a test for an empty string
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.
I added tests for empty strings
|
Congratulation, you have completed the PR successfully. |
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Wrote tests and implemented functions