Skip to content

Commit 772b252

Browse files
committed
reimplement and fix unit tests in the largest series product feature
1 parent 2a74ff4 commit 772b252

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"Smarticles101",
2323
"sonapraneeth-a",
2424
"sshine",
25-
"Zaldrick"
25+
"Zaldrick",
26+
"Xinri"
2627
],
2728
"files": {
2829
"solution": [

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,35 @@ public void testSeriesLengthLongerThanLengthOfStringToTestIsRejected() {
130130
@Disabled("Remove to run test")
131131
@Test
132132
@DisplayName("reports 1 for empty string and empty product (0 span)")
133-
public void testEmptyStringToSearchAndSeriesOfNonZeroLengthIsRejected() {
133+
public void testEmptyStringToSearchAndEmptyProduct() {
134+
LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
135+
136+
long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
137+
138+
assertThat(actualProduct).isEqualTo(1);
139+
}
140+
141+
@Disabled("Remove to run test")
142+
@Test
143+
@DisplayName("reports 1 for nonempty string and empty product (0 span)")
144+
public void testNonEmptyStringToSearchAndEmptyProduct() {
145+
LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123");
146+
147+
long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
148+
149+
assertThat(actualProduct).isEqualTo(1);
150+
}
151+
152+
@Disabled("Remove to run test")
153+
@Test
154+
@DisplayName("rejects empty string and nonzero span")
155+
public void testEmptyStringAndNonZeroSpanIsRejected() {
134156
LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
135157

136158
assertThatExceptionOfType(IllegalArgumentException.class)
137159
.isThrownBy(() -> calculator.calculateLargestProductForSeriesLength(1))
138160
.withMessage("Series length must be less than or equal to the length of the string to search.");
161+
139162
}
140163

141164
@Disabled("Remove to run test")

0 commit comments

Comments
 (0)