rocketraman
11/30/2020, 7:20 PMexactly
, atMost
, and atLeast
, but all of these take an additional predicate. Is the preferred approach to do this?
expectThat(it).get { count() }.isEqualTo(3)
Is there any particular reason that there isn't a count matcher directly on list?robfletcher
11/30/2020, 7:21 PMexpectThat(it).hasSize(3)
should work for yourocketraman
11/30/2020, 7:52 PMIterable
, not a List
. No hasSize
matcher seems to be available.robfletcher
11/30/2020, 7:59 PMIterable
doesn’t define a size
property. That’s added on Collection
. It wouldn’t make sense for all iterables (they can be unbounded, for example). For your case expectThat(it.toList()).hasSize(3)
is probably the way to go.hasSize
for Assertion.Builder<Iterable<*>>
but like I say it would not necessarily even make sense for every iterablerocketraman
11/30/2020, 8:09 PMcount
function on Iterable
. Normally unbounded iterables are represented as a Sequence
.robfletcher
11/30/2020, 8:14 PMhasSize
up to work on Iterable I guessrocketraman
11/30/2020, 8:16 PMrobfletcher
11/30/2020, 8:16 PMcount()
function so you could do expectThat(it).count().isEqualTo(3)
rocketraman
11/30/2020, 8:17 PMhasSize
exist? Couldn't it work the same way?robfletcher
11/30/2020, 8:20 PMCollection
doescount()
delegates to if called on a Collection
rocketraman
11/30/2020, 8:21 PMrobfletcher
11/30/2020, 8:21 PMfun Builder<out Iterable<*>>.count(): Builder<Int> =
get(Iterable<*>::count)
rocketraman
12/02/2020, 7:09 AM