Skip to content

update#35

Open
kemeng001 wants to merge 1 commit intoSWE-CS410:mainfrom
kemeng001:main
Open

update#35
kemeng001 wants to merge 1 commit intoSWE-CS410:mainfrom
kemeng001:main

Conversation

@kemeng001
Copy link

update

private String s;

@Override
public void setString(String s) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code checks for null or empty string in the count() and getSubStrings() methods, which is good. However, it doesn't handle null or empty string input in the setString() method. You might want to add a check for that.

if (start < 0 || end > words.length || start > end) {
return new String[0];
}
return Arrays.copyOfRange(words, start, end+1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getSubStrings() method splits the string into words using \s+ as the delimiter. It then returns a substring array based on the provided start and end indices. However, the end index is exclusive in Arrays.copyOfRange(), so you could use end instead of end+1 when copying the range

public void tearDown() {
manipulatedstring = null;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add comments before each test case to explain what each one is verifying.

int length = manipulatedstring.count();
assertEquals(1, length);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add some tests to handle if the string is empty or if after removing you end up with an empty string

manipulatedstring.setString("123");
assertEquals("12", manipulatedstring.removeNthCharacter(3, false));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You handle the testSubString cases really well but you may want to add exception handling for if the indices are out of bound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants