Skip to content

Added my code of#9

Open
IgorJanGit wants to merge 3 commits intomainfrom
IgorJanottiCodeReview
Open

Added my code of#9
IgorJanGit wants to merge 3 commits intomainfrom
IgorJanottiCodeReview

Conversation

@IgorJanGit
Copy link

StringManipulation.Java and
StringManipulationtest

StringManipulation.Java and
StringManipulationtest
@sarafarag sarafarag requested a review from Trev10 June 15, 2023 18:45
Copy link

@Trev10 Trev10 left a comment

Choose a reason for hiding this comment

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

Hey Igor you did a very good job overall I don't really see any big issues other than just some minor changed needed please make sure you check my comments and feel free to let me know if you need any clarifications.

fail("Not yet implemented");
manipulatedstring.setString("");
int length = manipulatedstring.count();
assertEquals(1, length);
Copy link

Choose a reason for hiding this comment

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

I think this should be 0 since the string is empty I will leave a suggestion on your count() in the StringManuoulation to fix this problem.

Copy link
Author

Choose a reason for hiding this comment

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

4c58815 fixed together with the first one

@Override
public int count() {
return 0;
String string = getString();
Copy link

Choose a reason for hiding this comment

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

To make sure that if there's an empty sting it will return a 0 you can add a if statement to it so that if the string is empty it will return 0 (using methods like isEmpty())

Copy link
Author

Choose a reason for hiding this comment

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

4c58815 here git commit i did to fix the issue


assertThrows(
IndexOutOfBoundsException.class, () -> {
manipulatedstring.removeNthCharacter(100, true);
Copy link

Choose a reason for hiding this comment

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

I don't think it matters if the maintainSpaceing is true or false in this situations since 100 is way larger than the string length so I'll say you can possibly make it another test because in testRemoveNthCharacter3 you already tested the same thing

Copy link
Author

Choose a reason for hiding this comment

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

I prefer to treat code like black box and test incase that true or false can result in difference case of exceptions


assertThrows(
IllegalArgumentException.class, () -> {
manipulatedstring.removeNthCharacter(0, true);
Copy link

Choose a reason for hiding this comment

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

This case is the same since n cannot be 0 then it should always throw the exception so I think you can change it to another test. Just so you have an idea you can maybe test when n is 1 since I didn't see you put that in a test.

Copy link
Author

Choose a reason for hiding this comment

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

c35af55 added tests to cover this as test 9 and 10

Copy link

@Trev10 Trev10 left a comment

Choose a reason for hiding this comment

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

Hey Igor I just finished looking at all changed and it's fine that you want to keep the maintain spacing true and false thing which is understandable and I see you fixed the minor issue so I think you are all set good job.

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