Is it just me or is there no matcher that verifies...
# kotest
j
Is it just me or is there no matcher that verifies that a collection is sorted descending?
Copy code
shouldBeMonotonicallyDecreasing
seems to do the work:
Copy code
listOf(10, 9, 8, 8, 6).shouldBeMonotonicallyDecreasing()
Didn't find it in documentation though, or perhaps I am blind? 😛
l
Monotonically is 1 by 1 tho
j
No, there is a strictlyDecreasing for that purpose. 🤷
l
list.shouldBeSortedBy { transform }
I'd use this guy
Or go
list.reverse().shouldBeSorted()
I see space for a
list.shouldBeSortedDesc()
if you want to open a ticket for that
j
list.reverse() is what I'd choose in the absence of a desc variant. 🙂
but the monotonicallyDecreasing worked too but not sure whether it is supported (since lacking in documentation).
I can open a question on the github page. 👍
k
Remember there's
list.asReversed()
which iterates in reverse order without actually creating a reversed list.
👍 2