max

fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(): Expect<E>(source)

Creates an Expect for the result of calling max() on the subject of this expectation, so that further fluent calls are assertions about it.

Return

The newly created Expect for the extracted feature.

Since

0.9.0

Samples

val iterable = sequenceOf(1, 2, 0).asIterable()

expect(iterable).max().toEqual(2) // subject is 2

expect(iterable).max()
    .toBeLessThan(10) // subject is 2
    .toBeGreaterThan(1) // subject is still 2

fails {
    expect(iterable).max() // subject is 2
        .toBeLessThan(2) // fails
        .toEqual(1) // skipped because previous expectation failed
}

fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(assertionCreator: Expect<E>.() -> Unit): Expect<T>(source)

Expects that the result of calling max() on the subject of this expectation holds all assertions the given assertionCreator creates for it and returns an Expect for the current subject of this expectation.

Return

an Expect for the subject of this expectation.

Since

0.9.0

Samples

val iterable = sequenceOf(1, 2, 0).asIterable()

expect(iterable).max {
    toBeGreaterThan(0) // subject is 2
    toBeGreaterThanOrEqualTo(2) // subject is still 2
}

fails {
    // all expectations are evaluated inside an expectation-group block; for more details:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(iterable).max {
        toBeGreaterThan(10) // fails
        toEqual(2) // still evaluated, even though  `toBeGreaterThan` already fails,
        //                      use `.max.` if you want a fail fast behaviour
    } // subject here is back type Iterable
}