Skip to content

Commit 34baef8

Browse files
committed
reimplement and fix unit tests in the largest series product feature
Signed-off-by: xinri <[email protected]>
1 parent 2a74ff4 commit 34baef8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

exercises/practice/largest-series-product/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"Smarticles101",
2323
"sonapraneeth-a",
2424
"sshine",
25+
"Xinri",
2526
"Zaldrick"
2627
],
2728
"files": {

exercises/practice/largest-series-product/.meta/src/reference/java/LargestSeriesProductCalculator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ final class LargestSeriesProductCalculator {
99

1010
long calculateLargestProductForSeriesLength(final int seriesLength) throws IllegalArgumentException {
1111
if (seriesLength < 0) {
12-
throw new IllegalArgumentException("Series length must be non-negative.");
12+
throw new IllegalArgumentException("Series length must not be negative.");
1313
} else if (seriesLength == 0) {
1414
return 1;
1515
} else if (seriesLength > stringToSearch.length()) {
1616
throw new IllegalArgumentException(
17-
"Series length must be less than or equal to the length of the string to search.");
17+
"Series length must not exceed the length of the string to search.");
1818
} else {
1919
long result = 0;
2020

exercises/practice/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,18 @@ public void testSeriesLengthLongerThanLengthOfStringToTestIsRejected() {
124124

125125
assertThatExceptionOfType(IllegalArgumentException.class)
126126
.isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(4))
127-
.withMessage("Series length must be less than or equal to the length of the string to search.");
127+
.withMessage("Series length must not exceed the length of the string to search.");
128128
}
129129

130130
@Disabled("Remove to run test")
131131
@Test
132-
@DisplayName("reports 1 for empty string and empty product (0 span)")
133-
public void testEmptyStringToSearchAndSeriesOfNonZeroLengthIsRejected() {
132+
@DisplayName("rejects empty string and nonzero span")
133+
public void testEmptyStringAndNonZeroSpanIsRejected() {
134134
LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
135135

136136
assertThatExceptionOfType(IllegalArgumentException.class)
137137
.isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(1))
138-
.withMessage("Series length must be less than or equal to the length of the string to search.");
138+
.withMessage("Series length must not exceed the length of the string to search.");
139139
}
140140

141141
@Disabled("Remove to run test")
@@ -155,7 +155,7 @@ public void testNegativeSeriesLengthIsRejected() {
155155

156156
assertThatExceptionOfType(IllegalArgumentException.class)
157157
.isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(-1))
158-
.withMessage("Series length must be non-negative.");
158+
.withMessage("Series length must not be negative.");
159159
}
160160

161161
@Disabled("Remove to run test")

0 commit comments

Comments
 (0)