max
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.12.0
Parameters
o
The filler object o.
Samples
val iterable = sequenceOf(1, 2, 0).asIterable()
expect(iterable) max o toEqual 2 // subject is 2
expect(iterable) max o toBeLessThan 10 toBeGreaterThan 1 // subject is 2 and passes all expectations
fails {
expect(iterable) max o toBeLessThan 2 toBeGreaterThan 0 // subject is 2 and fails the first expectation, the second is not evaluated
}
infix 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.12.0
Samples
val iterable = sequenceOf(1, 2, 0).asIterable()
expect(iterable) max {
it toBeGreaterThan 0 toBeGreaterThanOrEqualTo 2 // subject is 2 and passes all expectations
}
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 { // subject within this expectation-group is of type Int (actually 2)
it toBeGreaterThan 10 // fails
it toEqual 2 // still evaluated, even though `toBeGreaterThan` already fails,
// use `it toBeGreaterThan 10 toEqual 2` if you want a fail fast behaviour
} // subject here is back type Iterable
}