One question regarding collections,: In my project...
# atrium
i
One question regarding collections,: In my project, the lists are quite large, is there a way to specify (for in order comparisons) to only show the wrong values so that you don't have to search the front x's through the whole list?
r
Not yet out of the box but please open an issue for it, I'll provide a flag for this
i
Great, will do that, thank you!
👍 1
r
do you deal with `List`s?
i
Yes
r
and do you check against values or do you specify sub-assertions?
based on your last question I guess sub-assertions: You could use the following function in the meantime:
Copy code
fun <E, T : List<E>> Expect<T>.containsInOrderOnly(vararg assertionCreators: Expect<E>.() -> Unit): Expect<T> =
    and {
        assertionCreators.forEachIndexed { index, assertionCreator ->
            get(index, assertionCreator)
        }
    }
remove the
and
in case you want fail-fast behaviour
i
just values in that case
r
from another list?
i
the subject is a list, the arguments of
containsExactly
are varargs
r
assuming you are not dealing with nullable values
Copy code
fun <E: Any, T : List<E>> Expect<T>.containsInOrderOnly(vararg values: E): Expect<T> =
    and {
        values.forEachIndexed { index, value ->
            get(index).toBe(value)
        }
    }
i
Wow, excellent, thanks!
r
no worries, but please still create an issue, it makes more sense that this can be configured somehow instead of a separate function
otherwise you could still use:
Copy code
fun <E> Expect<Sequence<E>>.asList(): Expect<List<E>> = ExpectImpl.changeSubject(this).unreported { it.toList() }
and then the function above. But note that ExpectImpl is not stable yet and most likely changes
i
cool, thanks a lot
r
you're welcome
i
I created the issue on GitHub, as discussed: https://github.com/robstoll/atrium/issues/292