Skip to content

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

Open
ElCapitanHaddock wants to merge 2 commits intomainfrom
Judy_Yang_CodeReview
Open

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

Conversation

@ElCapitanHaddock
Copy link

Title

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

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();

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) {

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;

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

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); });
}

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));
}

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
Copy link
Author

ElCapitanHaddock commented Jun 14, 2023

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