toBeIn

fun <T> Expect<T>.toBeIn(expected: IterableLike): Expect<T>(source)

Expects that the subject of this expectation is in expected.

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

1.3.0

Throws

in case the iterable is empty.

Samples

expect(1).toBeIn(setOf(1, 2, 3, 4))

fails {
    expect(99).toBeIn(setOf(1, 2, 3, 4))
}

Expects that the subject of this expectation is within the expected range.

Return

an Expect for the subject of this expectation.

Since

1.3.0

Samples

expect(3).toBeIn(1..5)

fails {
    expect(0).toBeIn(1..5)
}

Expects that the subject of this expectation is within the expected range.

Return

an Expect for the subject of this expectation.

Since

1.3.0

Samples

expect(100L).toBeIn(50L..200L)

fails {
    expect(0L).toBeIn(50L..200L)
}

Expects that the subject of this expectation is within the expected range.

Return

an Expect for the subject of this expectation.

Since

1.3.0

Samples

expect('c').toBeIn('a'..'f')

fails {
    expect('A').toBeIn('a'..'f')
}