Repository navigation
London | 26-ITP-Sept | Fung Nin Lee | Sprint 2 | practice-tdd - #1708
leerogerfn wants to merge 21 commits into
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework, and it would be nice if the following can be improved in future submissions as well:
- Try not to commit
package.jsonandpackage-lock.jsoninto the repository. If you don't know how to choose certain files to stage before commit, feel free to ask a volunteer in Saturday class. - The indentation of
get-ordinal-number.jsis a bit hard to read. Please format the code properly in the future. Thank you.
| 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 count multiple occurrences of a character", () => { | ||
| const str = "bbbbb"; | ||
| const char = "a"; | ||
| 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 see you added the case of counting "q" in str "codeyourfuture". This is just similar to finding "b" in str"aaaaa". I meant anystr` would always give 0 no matter which character is counted? Please let me know here in the reply if you can't think of it. Thank you.
There was a problem hiding this comment.
could you advise the example? Thank you.
There was a problem hiding this comment.
When str is empty (i.e. str = ""), no matter which character to count, it should return 0. This is a valid test case (but some programs might return error which should be fixed). Your program is correct and just add this particular test case. Thank you.
| test("should append 'th' for numbers 11/12/13", () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); |
There was a problem hiding this comment.
how about a larger number like 111?
There was a problem hiding this comment.
111 should be 111th but not 111st. Similar to 112th and 113th. Please fix them, 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.
"goodbye" is not the special string. Please let me know here in the reply if you can't think of it. Thank you.
There was a problem hiding this comment.
could you advise the special string? Thank you.
There was a problem hiding this comment.
The special string is empty string "". When count is greater than or equal to zero, it should return "". When count is a negative number, it should still throw error. Your program is correct, and just add empty string in each of your test suites. Thank you.
|
Thank you for your effort. Please refer to the following new comments and fix them: |
|
Empty string is considered as boundary case and should normally be included when designing tests. Also, please fix the
|
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
written function and tests.
Questions
:)