Skip to content

Commit 51491b9

Browse files
marcphilippsormuras
authored andcommitted
Add test for interlocked recursive structures
1 parent 09fa8e3 commit 51491b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssertIterableEqualsAssertionsTests.java

+11
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
import static org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError;
1717
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
1818
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
19+
import static org.junit.jupiter.api.Assertions.assertThrows;
1920
import static org.junit.jupiter.api.IterableFactory.listOf;
2021
import static org.junit.jupiter.api.IterableFactory.setOf;
2122

2223
import java.nio.file.Path;
24+
import java.util.ArrayList;
2325
import java.util.List;
2426
import java.util.Set;
2527

@@ -449,4 +451,13 @@ void assertIterableEqualsWithListOfPath() {
449451
assertDoesNotThrow(() -> assertIterableEquals(expected, actual));
450452
}
451453

454+
@Test
455+
void assertIterableEqualsThrowsStackOverflowErrorForInterlockedRecursiveStructures() {
456+
var expected = new ArrayList<>();
457+
var actual = new ArrayList<>();
458+
actual.add(expected);
459+
expected.add(actual);
460+
assertThrows(StackOverflowError.class, () -> assertIterableEquals(expected, actual));
461+
}
462+
452463
}

0 commit comments

Comments
 (0)