robfletcher / strikt

An assertion library for Kotlin
https://strikt.io/
Apache License 2.0
558 stars 61 forks source link

Add assertion for a non-continuous sequence in an Iterable #271

Open Jasz opened 2 years ago

Jasz commented 2 years ago

This is a request for a new assertion which checks whether the subject Iterable contains the given elements in order provided, possibly with other items between them. AssertJ has that feature: containsSubsequence(ELEMENT... sequence), though I'm not a fan of that name. I'd call it either containsNonContinuousSequence or containsInOrder (as opposed to just contains, which doesn't verify the order and containsExactly, which checks the order, but doesn't allow other items).

This was already raised in #156 but the closing PR resolved only half of that feature request. Additionally, that PR implemented containsSequence on Lists, but I think it'd make more sense to implement that more broadly on Iterables.

I could try implementing this if that's okay.