Added StringManipulation.java and StringManipulationTest.java files#3
Added StringManipulation.java and StringManipulationTest.java files#3
Conversation
EllisLempriere
left a comment
There was a problem hiding this comment.
Travis passing
Solid test cases with good coverage
Clean readable code implementation
| assertEquals(expected, actual); | ||
| } | ||
|
|
||
| // Throw IllegalArgumentException if the given index is less than or equal to 0 |
There was a problem hiding this comment.
Looks like this comment is swapped with the comment on line 95, would recommend swapping for less confusion
There was a problem hiding this comment.
Ups, thanks for pointing that out! Copying and pasting can be risky :)
| assertEquals(0, length); | ||
| } | ||
|
|
||
| // Test when string is null |
There was a problem hiding this comment.
I like that you added comments describing a bit about the test. Try looking into the @DisplayName annotation for an addition nice way to format test details
There was a problem hiding this comment.
Oh, that's really cool. I'll use that
| manipulatedstring.restoreString(indices);}); | ||
| } | ||
|
|
||
| // Test when each character is the same in the string |
There was a problem hiding this comment.
This is an interesting test case, I wonder in what ways it would break/why it would be needed
There was a problem hiding this comment.
Yes, it is an interesting test case. I am not sure how you would break this case too. I run out of ideas and made up a case lol. Maybe it could be useful when implementation takes shortcuts or makes assumptions if the characters are the same. This test case ensures that the code does not make invalid assumptions.
| assertEquals(4, length); | ||
| } | ||
|
|
||
| // Test when string has multiple punctuations. |
There was a problem hiding this comment.
Testing against the punctuation is a good idea. I can see how this could easily break some implementations of the method
There was a problem hiding this comment.
You are right. If the test case was "This isn't my string !" and they put a space before the exclamation point it will break the test case because my method counts punctuations as a word too. My method implementation is way too simple to catch that. I think it would be better if I refactor that method and make it ignore punctuation.
…hat it considers punctuation and numerical values. Added 2 new test cases to test the newly added part.
No description provided.