Repository navigation
London | 26-Sep-ITP | Frumentius Tesfay | Sprint 2 | Coursework/sprint 3 practice tdd - #1713
Frumentius-Rev wants to merge 10 commits into
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework. Please 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); | ||
| }); |
There was a problem hiding this comment.
This is a special case of str where it is all the char to count. Would it still count correctly if the char just exists in some part of the str?
| test("should return 0 when character does not occur", () => { | ||
| const count = countChar("hello", "z"); | ||
| 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.
| // Case: Handle negative count: | ||
| // Given a target string `str` and a negative integer `count`, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should throw an error, as negative counts are not valid. |
There was a problem hiding this comment.
Please add test case for this requirement as well. Thank you.
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 3; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hellohellohello"); | ||
| }); | ||
|
|
||
| test("should return the original string when count is 1", () => { | ||
| const str = "hello"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hello"); | ||
| }); | ||
|
|
||
| test("should return an empty string when count is 0", () => { | ||
| const str = "hello"; | ||
| const count = 0; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual(""); | ||
| }); |
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?
|
It looks like to me that this PR contains two different courseworks:
Since the Assignment Title in this PR is "Coursework/sprint 3 practice tdd", please remove files in the new commits |
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Implemented countChar and repeat Str with tests.