Conversation
|
|
||
| @Test | ||
| public void testGeSubStrings1() { | ||
| public void testGetSubStrings1() { |
There was a problem hiding this comment.
You need to add unit tests for all the if statements in getSubstrings() in StringManipulation.java
ex:
if (startWord <= 0 || endWord <= 0 || startWord > endWord) {
throw new IllegalArgumentException("Invalid startWord or endWord values");
}
if (string == null || string.isEmpty()) {
throw new IndexOutOfBoundsException("String is empty");
}
String[] words = string.trim().split("\\s+");
if (endWord > words.length) {
throw new IndexOutOfBoundsException("String has fewer words than endWord");
}
| @@ -55,95 +66,140 @@ public void testRemoveNthCharacter2() { | |||
|
|
|||
| @Test | |||
| public void testRemoveNthCharacter3() { | |||
There was a problem hiding this comment.
The following test cases (testRemoveNthCharacter 3-7) are all variations of the first two test cases. Please revise these test cases so that they're testing for different kinds of input (e.g., n <= 0, string.isEmpty(), etc.)
| @Test | ||
| public void testRestoreString1() | ||
| { | ||
| public void testRestoreString1() { |
There was a problem hiding this comment.
Need more unique test cases for testing restoreString() (e.g., string.length !== array.length, any of the indices in int[] array are negative or greater than or equal to the length of the string).
| } | ||
|
|
||
| public String restoreString(int[] indices) { | ||
| if (string == null || indices == null || string.length() != indices.length) { |
There was a problem hiding this comment.
Java already throws a runtime error if you try to call restoreString() with an uninitialized int array, so I don't think you need the second condition here.
meelybug123
left a comment
There was a problem hiding this comment.
Hey Vanessa, please take a look at the comments above when you get the chance!
No description provided.