Birmingham | 26-ITP-May | Tobias Amaechina | Sprint 3 | Coursework sprint 3 practice tdd#1501
Open
Tobias-Amaechina wants to merge 17 commits into
Open
Conversation
…in 1 excpet 11 and everything else to end in th
cjyuan
reviewed
Jul 17, 2026
| // Case 6: All other numbers | ||
| // When the number does not fall into any of the above categories, | ||
| // Then the function should return a string by appending "th" to the number. | ||
| test("should append 'th' for all other numbers", () => { |
Contributor
There was a problem hiding this comment.
When a test fails with the message "... all other numbers", it may be unclear what "other numbers" actually refers to.
Could you revise the test description to make it more informative?
Comment on lines
+3
to
+8
| for (let i = 0; i < count; i++) { | ||
| result += str; | ||
| } | ||
| if (count < 0) { | ||
| throw new Error("Count must be a non-negative integer"); | ||
| } |
Contributor
There was a problem hiding this comment.
Why not perform the check before the for-loop?
Comment on lines
+26
to
+31
| test("should return 0 when character is not found", () => { | ||
| const str = "hello"; | ||
| const char = "x"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
Contributor
There was a problem hiding this comment.
Could consider testing a few more samples in this script - higher chance to detect bugs in code.
Also, the original specification did not clearly state whether the character match should be case-sensitive.
Most people would probably assume that it is, but to demonstrate our understanding or clarify the assumption we made,
we could add test cases to convey this. For examples,
- A case to show that the match is case sensitive
- A case to show that the function is expected to work also for non-alphabets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Changelist
I implemented three functions (countChar, getOrdinalNumber, repeatStr) using Test-Driven Development principles. I did wrote comprehensive tests first, then implemented the functions to pass those tests, which aligns with the TDD methodology.