Skip to content

Update my implementation#5

Open
Trev10 wants to merge 5 commits intomainfrom
Treviour_Lee_CodeReview
Open

Update my implementation#5
Trev10 wants to merge 5 commits intomainfrom
Treviour_Lee_CodeReview

Conversation

@Trev10
Copy link

@Trev10 Trev10 commented Jun 15, 2023

No description provided.

@sarafarag sarafarag requested a review from carector June 15, 2023 18:07
@carector
Copy link

carector commented Jun 15, 2023

Test cases pass but do not meet jacoco line coverage case (see lines 1194 and 1201 of Travis CI build). The phrases "this" and "string" come up a lot in your tests - I think changing some tests to use more varied strings should help it pass the jacoco check. Looks great otherwise!

Copy link

@carector carector left a comment

Choose a reason for hiding this comment

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

Your implementation and most of your tests are fine, but I don't think we're supposed to modify the lines covered ratio in pom.xml. I left a comment on the pom file explaining it further.

I think if you change one or two tests to check that exceptions are thrown properly then your code should pass for the original 0.9 minimum lines covered ratio.

@Test
public void testGeSubStrings2() {
fail("Not yet implemented");
manipulatedstring.setString("This is another string");

Choose a reason for hiding this comment

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

Change input string to a more unique statement (specifically "this" and "string")
Consider updating subsequent tests as well

Copy link
Author

Choose a reason for hiding this comment

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

since I'm gonna change it I made it so that it's also checking on the throw exception for this

}

String theString = getString();
StringBuilder sb = new StringBuilder(theString);

Choose a reason for hiding this comment

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

Good idea using a StringBuilder! I hadn't thought of that in my implementation.

Copy link
Author

Choose a reason for hiding this comment

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

But I forgot to add a exception when n is larger than the length of string lol

return null;
}
public String restoreString(int[] indices){
if(indices == null || this.pString == null) {

Choose a reason for hiding this comment

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

May also want to check for string and indices[] with length zero as a precaution

@Test
public void testRemoveNthCharacter5() {
fail("Not yet implemented");
manipulatedstring.setString("This message should be unreadable");

Choose a reason for hiding this comment

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

I'd recommend adding a test that checks to see what happens when N is a value larger than the length of the string

Copy link
Author

Choose a reason for hiding this comment

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

yes I did that now

pom.xml Outdated
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
<minimum>0.8</minimum>

Choose a reason for hiding this comment

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

Changing this value isn't a great idea because it tells Travis how much of your code needs to be checked by your unit tests to pass. It looks like your previous commit wasn't building because some of your tests weren't diverse enough to test all parts of your code.

Here's a site that explains it better: https://mkyong.com/maven/maven-jacoco-code-coverage-example/

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for letting me know I'm gonna change that before I push it again

Copy link

@carector carector left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for fixing the unit tests!

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