-
-
Notifications
You must be signed in to change notification settings - Fork 744
sync the largest-series-product tests and fix / add missing unit tests #3051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync the largest-series-product tests and fix / add missing unit tests #3051
Conversation
772b252 to
33c41e2
Compare
0465015 to
bcfa8e6
Compare
jagdish-15
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also check if there are any other tests that are marked as include = false but still exist in the test file. And please make all the error messages consistent with those in the canonical-data.json file. I’ve suggested changes for one of them, but I believe there are more cases like that, for example the rejects negative span test.
|
|
||
| assertThatExceptionOfType(IllegalArgumentException.class) | ||
| .isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(4)) | ||
| .withMessage("Series length must be less than or equal to the length of the string to search."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .withMessage("span must not exceed string length"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it is indeed what the canonical said but I read that the implementation of the error messages should be made easy to read by the devs. I checked a lot of unit tests and their canonical file, and they have their own way to express what the canonical file raised as an error. So we should not just copy paste the error message but we should create an explicit message that will represent the error message in the canonical file no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the message in the specification is not representing the error message.
I have replace it with "Series length must not exceed the length of the string to search." to match with the function.
By the way, if some mentee works on this exercise, they will have to rework again no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to leave the exception messages as they were. I think your wording is saying the same thing as before, just with different wording.
By the way, if some mentee works on this exercise, they will have to rework again no ?
Yeah, if we change the wording, the students will need to update their solutions. Since the wording is saying the same thing, I don't think there is much benefit with changing the exception message (hence, my preference for leaving the exception message as is).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I didn't see this answer. Thanks for the confirmation. I also prefer to keep the same error message because they are quite explicits
| @Disabled("Remove to run test") | ||
| @Test | ||
| @DisplayName("reports 1 for empty string and empty product (0 span)") | ||
| public void testEmptyStringToSearchAndSeriesOfNonZeroLengthIsRejected() { | ||
| public void testEmptyStringToSearchAndEmptyProduct() { | ||
| LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator(""); | ||
|
|
||
| long actualProduct = calculator.calculateLargestProductForSeriesLength(0); | ||
|
|
||
| assertThat(actualProduct).isEqualTo(1); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @Test | ||
| @DisplayName("reports 1 for nonempty string and empty product (0 span)") | ||
| public void testNonEmptyStringToSearchAndEmptyProduct() { | ||
| LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123"); | ||
|
|
||
| long actualProduct = calculator.calculateLargestProductForSeriesLength(0); | ||
|
|
||
| assertThat(actualProduct).isEqualTo(1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the tests which are marked as include = false in the toml file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done thanks for checking that
903baf0 to
34baef8
Compare
| assertThatExceptionOfType(IllegalArgumentException.class) | ||
| .isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(1)) | ||
| .withMessage("Series length must be less than or equal to the length of the string to search."); | ||
| .withMessage("Series length must not exceed the length of the string to search."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in another comment, let's keep the message as it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I have done a rollback for this
| assertThatExceptionOfType(IllegalArgumentException.class) | ||
| .isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(-1)) | ||
| .withMessage("Series length must be non-negative."); | ||
| .withMessage("Series length must not be negative."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in another comment, let's keep the message as it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I have done a rollback for this
Signed-off-by: xinri <[email protected]>
34baef8 to
989dcfa
Compare
pull request
Sync the largest-series-product. Missing reimplement (re-generated with configlet)
related to #2959
Reviewer Resources:
Track Policies