Skip to content

Commit

Permalink
Use section end logic when checking assertNoFurtherElements
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Aug 5, 2024
1 parent c6c4fe2 commit 9d78529
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ fun <T: Iterable<E>, E> Builder<T>.containsWithOrderingConstraints(
}

val assertNoFurtherElements = builder.expectsNoFurtherElements ||
// Check if the last section has a `last` constraint
allSections.last().elementsWithConstraints.any { it.constraints.any { it == OrderingConstraint.Last } }
// Check if the last section explicitly defines the end element
allSections.last().endDefinedBy is SectionAssertionSpec.EndDefinition.DeclaredElement<*>
if (assertNoFurtherElements) {
assert("contains no further elements", expected = emptyList<E>()) {
if (elementsConsumed == it.count()) {
Expand Down

0 comments on commit 9d78529

Please sign in to comment.