Skip to content

Updated files, pull request contains my implementation and test cases#15

Open
ElCapitanHaddock wants to merge 2 commits into
mainfrom
Judy_Yang_CodeReview
Open

Updated files, pull request contains my implementation and test cases#15
ElCapitanHaddock wants to merge 2 commits into
mainfrom
Judy_Yang_CodeReview

Conversation

@ElCapitanHaddock

Copy link
Copy Markdown

Title

@sarafarag
sarafarag requested a review from SilverSynch June 14, 2023 18:58
@SilverSynch

Copy link
Copy Markdown

Overall, you did not implement all the listed exceptions in at least two methods and padded your test counts with repeats of trivial success examples.

@Override
public String[] getSubStrings(int startWord, int endWord){
String[] words = value.trim().split("\\s+");
if (value.trim() == "" || endWord < startWord || startWord > words.length) throw new IllegalArgumentException();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Exceptions should come with messages relevant to what occurred. This is apparent in multiple places.

}

@Override
public String removeNthCharacter(int n, boolean maintainSpacing) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This method throws no exceptions at all!

@Override
public int count() {
if (value.trim() == "") return 0;
return value.trim().split("\\s+").length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The result of value.trim().split() is re-used several times in the code, but is calculated every time. It should be cached and regenerated whenever the string is changed.

}

@Test
//tests swapping only one pair

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test is a trivial version of another test.

int [] array;
array=new int[]{2,1,-3};
assertThrows(ArrayIndexOutOfBoundsException.class, () -> { manipulatedstring.restoreString(array); });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is no test for the throwing of IllegalArgumentException when the provided array does not match the length of the string.

manipulatedstring.setString("aaa");
assertEquals(" ", manipulatedstring.removeNthCharacter(1, true));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are NO tests for the exceptions for this method.

@ElCapitanHaddock

ElCapitanHaddock commented Jun 14, 2023

Copy link
Copy Markdown
Author

TY for the code review, I appreciate the brutal honesty!

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