Skip to content

Commit bcfa8e6

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

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
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/src/test/java/LargestSeriesProductCalculatorTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,29 @@ 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)

0 commit comments

Comments
 (0)