min

infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(o: o): Expect<E>(source)

Creates an Expect for the result of calling min() 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.12.0

Parameters

o

The filler object o.

Samples

val iterable = sequenceOf(1, -2, 3).asIterable()

expect(iterable) min o toEqual -2 // subject is -2

expect(iterable) min o toBeLessThan 0 toBeGreaterThan -10 // subject is -2 and passes all expectations

fails {
    expect(iterable) min o toBeLessThan -5 toBeGreaterThan -10 // subject is -2 and fails the first expectation,
}

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

Expects that the result of calling min() 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.12.0

Samples

val iterable = sequenceOf(1, -2, 3).asIterable()

expect(iterable) min {
    it toBeLessThan 0 toBeGreaterThanOrEqualTo -2 // subject is -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) min { // subject within this expectation-group is of type Int (actually -2)
        it toBeLessThan -2 // fails
        it toEqual -10 // still evaluated, even though  `toBeLessThan` already fails,
        //                use `it toBeLessThan -2 toEqual -10 ` if you want a fail fast behaviour
    } // subject here is back type Iterable
}