package strikt.assertions
Fields
Name | Description |
---|---|
val length: Builder<Int>
|
Maps an assertion on a CharSequence to an assertion on its length. |
val start: Builder<E>
|
Maps an assertion on the ClosedRange to an assertion on its ClosedRange.start. |
val endInclusive: Builder<E>
|
Maps an assertion on the ClosedRange to an assertion on its ClosedRange.endInclusive. |
val size: Builder<Int>
|
Maps an assertion on a collection to an assertion on its size. |
val name: Builder<String>
|
Maps an assertion on an enum to an assertion on its name. |
val ordinal: Builder<Int>
|
Maps an assertion on an enum to an assertion on its ordinal. |
val message: Builder<String?>
|
Maps an assertion on a Throwable to an assertion on its
Throwable.message.
This mapping also asserts that the message is not |
val cause: DescribeableBuilder<Throwable?>
|
Maps an assertion on a Throwable to an assertion on its Throwable.cause. |
val first: Builder<A>
|
Maps an assertion on a Pair to an assertion on its Pair.first property. |
val first: Builder<A>
|
Maps an assertion on a Triple to an assertion on its Triple.first property. |
val second: Builder<B>
|
Maps an assertion on a Pair to an assertion on its Pair.second property. |
val second: Builder<B>
|
Maps an assertion on a Triple to an assertion on its Triple.second property. |
val third: Builder<C>
|
Maps an assertion on a Triple to an assertion on its Triple.third property. |
Methods
isNull
fun <T> Builder<T?>.isNull(): Builder<Nothing>
Receiver
Name | Description |
---|---|
Builder<T?>
|
ReturnValue
Name | Description |
---|---|
Builder<Nothing>
|
isNotNull
fun <T> Builder<T?>.isNotNull(): Builder<T>
Asserts that the subject is not null
.
Receiver
Name | Description |
---|---|
Builder<T?>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
an assertion for a non- |
withNotNull
fun <T> Builder<T?>.withNotNull(block: Builder<T>.()->Unit): Builder<T>
A convenient shorthand for isNotNull followed by Builder.and.
Receiver
Name | Description |
---|---|
Builder<T?>
|
Parameters
Name | Description |
---|---|
block: Builder<T>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isA
fun <T> Builder<*>.isA(): Builder<T>
Asserts that the subject is an instance of T.
Receiver
Name | Description |
---|---|
Builder<*>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
an assertion for T. |
isEqualTo
infix fun <T> Builder<T>.isEqualTo(expected: T?): Builder<T>
Asserts that the subject is equal to expected according to the standard
Kotlin ==
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T?
|
the expected value. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isEqualTo
fun Builder<Double>.isEqualTo(expected: Double, tolerance: Double): Builder<Double>
Asserts that the subject is within tolerance of expected.
Receiver
Name | Description |
---|---|
Builder<Double>
|
Parameters
Name | Description |
---|---|
expected: Double
|
|
tolerance: Double
|
ReturnValue
Name | Description |
---|---|
Builder<Double>
|
isEqualTo
fun Builder<Float>.isEqualTo(expected: Float, tolerance: Double): Builder<Float>
Asserts that the subject is within tolerance of expected.
Receiver
Name | Description |
---|---|
Builder<Float>
|
Parameters
Name | Description |
---|---|
expected: Float
|
|
tolerance: Double
|
ReturnValue
Name | Description |
---|---|
Builder<Float>
|
isNotEqualTo
infix fun <T> Builder<T>.isNotEqualTo(expected: T?): Builder<T>
Asserts that the subject is not equal to expected according to the standard
Kotlin ==
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T?
|
the expected value. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isSameInstanceAs
infix fun <T> Builder<T>.isSameInstanceAs(expected: Any?): Builder<T>
Asserts that the subject is the same instance as expected according to the standard
Kotlin ===
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Any?
|
the expected instance. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isNotSameInstanceAs
infix fun <T> Builder<T>.isNotSameInstanceAs(expected: Any?): Builder<T>
Asserts that the subject is not the same instance as expected according to the standard
Kotlin ===
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Any?
|
the expected instance. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isContainedIn
infix fun <T> Builder<T>.isContainedIn(expected: Iterable<T>): Builder<T>
Asserts that the subject is contained in expected according to the standard Kotlin in
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Iterable<T>
|
the expected iterable. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contentEquals
infix fun <T> Builder<Array<T>>.contentEquals(other: Array<T>): Builder<Array<T>>
Asserts that the subject's content is equal to that of other according to Array.contentEquals.
Receiver
Name | Description |
---|---|
Builder<Array<T>>
|
Parameters
Name | Description |
---|---|
other: Array<T>
|
ReturnValue
Name | Description |
---|---|
Builder<Array<T>>
|
contentEquals
infix fun Builder<BooleanArray>.contentEquals(other: BooleanArray): Builder<BooleanArray>
Asserts that the subject's content is equal to that of other according to BooleanArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<BooleanArray>
|
Parameters
Name | Description |
---|---|
other: BooleanArray
|
ReturnValue
Name | Description |
---|---|
Builder<BooleanArray>
|
contentEquals
infix fun Builder<ByteArray>.contentEquals(other: ByteArray): Builder<ByteArray>
Asserts that the subject's content is equal to that of other according to ByteArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<ByteArray>
|
Parameters
Name | Description |
---|---|
other: ByteArray
|
ReturnValue
Name | Description |
---|---|
Builder<ByteArray>
|
contentEquals
infix fun Builder<ShortArray>.contentEquals(other: ShortArray): Builder<ShortArray>
Asserts that the subject's content is equal to that of other according to ShortArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<ShortArray>
|
Parameters
Name | Description |
---|---|
other: ShortArray
|
ReturnValue
Name | Description |
---|---|
Builder<ShortArray>
|
contentEquals
infix fun Builder<IntArray>.contentEquals(other: IntArray): Builder<IntArray>
Asserts that the subject's content is equal to that of other according to IntArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<IntArray>
|
Parameters
Name | Description |
---|---|
other: IntArray
|
ReturnValue
Name | Description |
---|---|
Builder<IntArray>
|
contentEquals
infix fun Builder<LongArray>.contentEquals(other: LongArray): Builder<LongArray>
Asserts that the subject's content is equal to that of other according to LongArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<LongArray>
|
Parameters
Name | Description |
---|---|
other: LongArray
|
ReturnValue
Name | Description |
---|---|
Builder<LongArray>
|
contentEquals
infix fun Builder<FloatArray>.contentEquals(other: FloatArray): Builder<FloatArray>
Asserts that the subject's content is equal to that of other according to FloatArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<FloatArray>
|
Parameters
Name | Description |
---|---|
other: FloatArray
|
ReturnValue
Name | Description |
---|---|
Builder<FloatArray>
|
contentEquals
infix fun Builder<DoubleArray>.contentEquals(other: DoubleArray): Builder<DoubleArray>
Asserts that the subject's content is equal to that of other according to DoubleArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<DoubleArray>
|
Parameters
Name | Description |
---|---|
other: DoubleArray
|
ReturnValue
Name | Description |
---|---|
Builder<DoubleArray>
|
contentEquals
infix fun Builder<CharArray>.contentEquals(other: CharArray): Builder<CharArray>
Asserts that the subject's content is equal to that of other according to CharArray.contentEquals.
Receiver
Name | Description |
---|---|
Builder<CharArray>
|
Parameters
Name | Description |
---|---|
other: CharArray
|
ReturnValue
Name | Description |
---|---|
Builder<CharArray>
|
isEmpty
fun <T> Builder<Array<T>>.isEmpty(): Builder<Array<T>>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<Array<T>>
|
ReturnValue
Name | Description |
---|---|
Builder<Array<T>>
|
isEmpty
fun Builder<BooleanArray>.isEmpty(): Builder<BooleanArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<BooleanArray>
|
ReturnValue
Name | Description |
---|---|
Builder<BooleanArray>
|
isEmpty
fun Builder<ByteArray>.isEmpty(): Builder<ByteArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<ByteArray>
|
ReturnValue
Name | Description |
---|---|
Builder<ByteArray>
|
isEmpty
fun Builder<ShortArray>.isEmpty(): Builder<ShortArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<ShortArray>
|
ReturnValue
Name | Description |
---|---|
Builder<ShortArray>
|
isEmpty
fun Builder<IntArray>.isEmpty(): Builder<IntArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<IntArray>
|
ReturnValue
Name | Description |
---|---|
Builder<IntArray>
|
isEmpty
fun Builder<LongArray>.isEmpty(): Builder<LongArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<LongArray>
|
ReturnValue
Name | Description |
---|---|
Builder<LongArray>
|
isEmpty
fun Builder<FloatArray>.isEmpty(): Builder<FloatArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<FloatArray>
|
ReturnValue
Name | Description |
---|---|
Builder<FloatArray>
|
isEmpty
fun Builder<DoubleArray>.isEmpty(): Builder<DoubleArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<DoubleArray>
|
ReturnValue
Name | Description |
---|---|
Builder<DoubleArray>
|
isEmpty
fun Builder<CharArray>.isEmpty(): Builder<CharArray>
Asserts that the subject's content is empty.
Receiver
Name | Description |
---|---|
Builder<CharArray>
|
ReturnValue
Name | Description |
---|---|
Builder<CharArray>
|
isEmpty
fun <T : CharSequence> Builder<T>.isEmpty(): Builder<T>
Asserts that the subject is the empty string.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
toList
fun <T> Builder<Array<T>>.toList(): Builder<List<T>>
Maps an array to a list to make it possible to use the iterable matchers
Receiver
Name | Description |
---|---|
Builder<Array<T>>
|
ReturnValue
Name | Description |
---|---|
Builder<List<T>>
|
isTrue
fun <T : Boolean?> Builder<T>.isTrue(): Builder<T>
Asserts that the subject is not null and is the boolean value true
.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isFalse
fun <T : Boolean?> Builder<T>.isFalse(): Builder<T>
Asserts that the subject is not null and is the boolean value false
.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
hasLength
infix fun <T : CharSequence> Builder<T>.hasLength(expected: Int): Builder<T>
Asserts that the subject has a CharSequence.length of exactly expected.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Int
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isLowerCase
fun <T : CharSequence> Builder<T>.isLowerCase(): Builder<T>
Asserts that the subject is composed of all lower-case characters.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isUpperCase
fun <T : CharSequence> Builder<T>.isUpperCase(): Builder<T>
Asserts that the subject is composed of all upper-case characters.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
startsWith
infix fun <T : CharSequence> Builder<T>.startsWith(expected: Char): Builder<T>
Asserts that the subject starts with the expected character.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Char
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
startsWith
infix fun <T : CharSequence> Builder<T>.startsWith(expected: CharSequence): Builder<T>
Asserts that the subject starts with the expected string.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: CharSequence
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
endsWith
infix fun <T : CharSequence> Builder<T>.endsWith(expected: Char): Builder<T>
Asserts that the subject ends with the expected character.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Char
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
endsWith
infix fun <T : CharSequence> Builder<T>.endsWith(expected: CharSequence): Builder<T>
Asserts that the subject ends with the expected string.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: CharSequence
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
matches
infix fun <T : CharSequence> Builder<T>.matches(expected: Regex): Builder<T>
Asserts that the subject is a full match for the expected regular expression.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Regex
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
matchesIgnoringCase
infix fun <T : CharSequence> Builder<T>.matchesIgnoringCase(expected: Regex): Builder<T>
Asserts that the subject is a full match for the expected regular expression regardless of case.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Regex
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contains
infix fun <T : CharSequence> Builder<T>.contains(expected: Regex): Builder<T>
Asserts that the subject contains a match for the expected regular expression.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Regex
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contains
infix fun <T : CharSequence> Builder<T>.contains(expected: CharSequence): Builder<T>
Asserts that the subject contains the expected substring.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: CharSequence
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contains
infix fun <T : ClosedRange<E>, E> Builder<T>.contains(element: E): Builder<T>
Asserts that the subject range contains the provided element.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
element: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contains
fun <T : Iterable<E>, E> Builder<T>.contains(vararg elements: E): Builder<T>
Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg elements: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
contains
infix fun <T : Iterable<E>, E> Builder<T>.contains(elements: Collection<E>): Builder<T>
Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
elements: Collection<E>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsIgnoringCase
infix fun <T : CharSequence> Builder<T>.containsIgnoringCase(expected: Regex): Builder<T>
Asserts that the subject contains a match for the expected regular expression regardless of case.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Regex
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsIgnoringCase
infix fun <T : CharSequence> Builder<T>.containsIgnoringCase(expected: CharSequence): Builder<T>
Asserts that the subject contains the expected substring regardless of case.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: CharSequence
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isNullOrEmpty
fun <T : CharSequence?> Builder<T>.isNullOrEmpty(): Builder<T>
Asserts that the subject is null
or the empty string.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isNullOrBlank
fun <T : CharSequence?> Builder<T>.isNullOrBlank(): Builder<T>
Asserts that the subject is null
, empty, or contains only whitespace
characters.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isBlank
fun <T : CharSequence> Builder<T>.isBlank(): Builder<T>
Asserts that the subject is empty, or contains only whitespace characters.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isNotEmpty
fun <T : CharSequence> Builder<T>.isNotEmpty(): Builder<T>
Asserts that the subject is not the empty string (contains at least one character).
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isNotBlank
fun <T : CharSequence> Builder<T>.isNotBlank(): Builder<T>
Asserts that the subject is not blank (contains at least one non-whitespace character).
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
trim
fun <T : CharSequence> Builder<T>.trim(): Builder<CharSequence>
Trims the subject CharSequence
.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<CharSequence>
|
trim
fun Builder<String>.trim(): Builder<String>
Trims the subject string.
Receiver
Name | Description |
---|---|
Builder<String>
|
ReturnValue
Name | Description |
---|---|
Builder<String>
|
hasSize
infix fun <T : Collection<E>, E> Builder<T>.hasSize(expected: Int): Builder<T>
Asserts that the subject has a Collection.size of exactly expected.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: Int
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isGreaterThan
infix fun <T : Comparable<T>> Builder<T>.isGreaterThan(expected: T): Builder<T>
Asserts that the subject compares greater than expected according to
Kotlin's standard >
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isLessThan
infix fun <T : Comparable<T>> Builder<T>.isLessThan(expected: T): Builder<T>
Asserts that the subject compares less than expected according to Kotlin's
standard <
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isGreaterThanOrEqualTo
infix fun <T : Comparable<T>> Builder<T>.isGreaterThanOrEqualTo(expected: T): Builder<T>
Asserts that the subject compares greater than or equal to expected
according to Kotlin's standard >=
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isLessThanOrEqualTo
infix fun <T : Comparable<T>> Builder<T>.isLessThanOrEqualTo(expected: T): Builder<T>
Asserts that the subject compares less than or equal to expected according
to Kotlin's standard <=
operator.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: T
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isIn
infix fun <T : Comparable<T>> Builder<T>.isIn(expected: ClosedRange<T>): Builder<T>
Asserts that the subject is in the expected range.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
expected: ClosedRange<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isOneOf
fun <T : Enum<T>> Builder<T>.isOneOf(vararg values: T): Builder<T>
Asserts that the subject is one of values.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg values: T
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
count
fun Builder<Iterable<*>>.count(): Builder<Int>
Maps this assertion to an assertion over the count of elements in the subject.
Receiver
Name | Description |
---|---|
Builder<Iterable<*>>
|
ReturnValue
Name | Description |
---|---|
Builder<Int>
|
count
fun <T : Iterable<E>, E> Builder<T>.count(description: String, predicate: (E)->Boolean): Builder<Int>
Maps this assertion to an assertion over the count of elements matching predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
description: String
|
|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
Builder<Int>
|
map
infix fun <T : Iterable<E>, E, R> Builder<T>.map(function: (E)->R): Builder<Iterable<R>>
Applies Iterable.map with function to the subject and returns an assertion builder wrapping the result.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
function: (E)->R
|
ReturnValue
Name | Description |
---|---|
Builder<Iterable<R>>
|
first
fun <T : Iterable<E>, E> Builder<T>.first(): Builder<E>
Maps this assertion to an assertion over the first element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
first
infix fun <T : Iterable<E>, E> Builder<T>.first(predicate: (E)->Boolean): Builder<E>
Maps this assertion to an assertion over the first element in the subject iterable that matches predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
withFirst
fun <T : Iterable<E>, E> Builder<T>.withFirst(block: Builder<E>.()->Unit): Builder<T>
Runs a group of assertions on the first element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
block: Builder<E>.()->Unit
|
a closure that can perform multiple assertions that will all be evaluated regardless of whether preceding ones pass or fail. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
this builder, to facilitate chaining. |
withFirst
fun <T : Iterable<E>, E> Builder<T>.withFirst(predicate: (E)->Boolean, block: Builder<E>.()->Unit): Builder<T>
Runs a group of assertions on the first element in the subject iterable that matches predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: (E)->Boolean
|
|
block: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
elementAt
fun <T : Iterable<E>, E> Builder<T>.elementAt(index: Int): Builder<E>
Maps this assertion to an assertion over the indexed element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
index: Int
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
withElementAt
fun <T : Iterable<E>, E> Builder<T>.withElementAt(index: Int, block: Builder<E>.()->Unit): Builder<T>
Runs a group of assertions on the element at index in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
index: Int
|
|
block: Builder<E>.()->Unit
|
a closure that can perform multiple assertions that will all be evaluated regardless of whether preceding ones pass or fail. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
this builder, to facilitate chaining. |
single
fun <T : Collection<E>, E> Builder<T>.single(): Builder<E>
Maps this assertion to an assertion over the single element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
last
fun <T : Iterable<E>, E> Builder<T>.last(): Builder<E>
Maps this assertion to an assertion over the last element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
withLast
fun <T : Iterable<E>, E> Builder<T>.withLast(block: Builder<E>.()->Unit): Builder<T>
Runs a group of assertions on the last element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
block: Builder<E>.()->Unit
|
a closure that can perform multiple assertions that will all be evaluated regardless of whether preceding ones pass or fail. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
this builder, to facilitate chaining. |
flatMap
infix fun <T : Iterable<E>, E, R> Builder<T>.flatMap(transform: (E)->Iterable<R>): Builder<List<R>>
Maps this assertion to an assertion over a flattened list of the results of transform for each element in the subject iterable.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
transform: (E)->Iterable<R>
|
ReturnValue
Name | Description |
---|---|
Builder<List<R>>
|
filter
infix fun <T : Iterable<E>, E> Builder<T>.filter(predicate: (E)->Boolean): Builder<List<E>>
Maps this assertion to an assertion over a list of all elements of the subject that match predicate
.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
Builder<List<E>>
|
filterNot
infix fun <T : Iterable<E>, E> Builder<T>.filterNot(predicate: (E)->Boolean): Builder<List<E>>
Maps this assertion to an assertion over a list of all elements of the subject that do not match predicate
.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: (E)->Boolean
|
ReturnValue
Name | Description |
---|---|
Builder<List<E>>
|
filterIsInstance
fun <R> Builder<Iterable<*>>.filterIsInstance(): Builder<List<R>>
Maps this assertion to an assertion over a list of all elements of the subject that are instances of R
.
Receiver
Name | Description |
---|---|
Builder<Iterable<*>>
|
ReturnValue
Name | Description |
---|---|
Builder<List<R>>
|
all
infix fun <T : Iterable<E>, E> Builder<T>.all(predicate: Builder<E>.()->Unit): Builder<T>
Asserts that all elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
allIndexed
infix fun <T : Iterable<E>, E> Builder<T>.allIndexed(predicate: Builder<E>.(Int)->Unit): Builder<T>
Asserts that all elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.(Int)->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
any
infix fun <T : Iterable<E>, E> Builder<T>.any(predicate: Builder<E>.()->Unit): Builder<T>
Asserts that at least one element of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
anyIndexed
infix fun <T : Iterable<E>, E> Builder<T>.anyIndexed(predicate: Builder<E>.(Int)->Unit): Builder<T>
Asserts that at least one element of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.(Int)->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
none
infix fun <T : Iterable<E>, E> Builder<T>.none(predicate: Builder<E>.()->Unit): Builder<T>
Asserts that no elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
noneIndexed
infix fun <T : Iterable<E>, E> Builder<T>.noneIndexed(predicate: Builder<E>.(Int)->Unit): Builder<T>
Asserts that no elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.(Int)->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
one
infix fun <T : Iterable<E>, E> Builder<T>.one(predicate: Builder<E>.()->Unit): Builder<T>
Asserts that exactly one element of the subject passes the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
atLeast
fun <T : Iterable<E>, E> Builder<T>.atLeast(count: Int, predicate: Builder<E>.()->Unit): Builder<T>
Asserts that at least count elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
count: Int
|
|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
atMost
fun <T : Iterable<E>, E> Builder<T>.atMost(count: Int, predicate: Builder<E>.()->Unit): Builder<T>
Asserts that at most count elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
count: Int
|
|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
exactly
fun <T : Iterable<E>, E> Builder<T>.exactly(count: Int, predicate: Builder<E>.()->Unit): Builder<T>
Asserts that exactly count elements of the subject pass the assertions in predicate.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
count: Int
|
|
predicate: Builder<E>.()->Unit
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
doesNotContain
fun <T : Iterable<E>, E> Builder<T>.doesNotContain(vararg elements: E): Builder<T>
Asserts that none of elements are present in the subject.
If elements is empty the assertion always fails. If the subject is empty the assertion always passe.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg elements: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
doesNotContain
infix fun <T : Iterable<E>, E> Builder<T>.doesNotContain(elements: Collection<E>): Builder<T>
Asserts that none of elements are present in the subject.
If elements is empty the assertion always fails. If the subject is empty the assertion always passe.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
elements: Collection<E>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsExactly
fun <T : Iterable<E>, E> Builder<T>.containsExactly(vararg elements: E): Builder<T>
Asserts that all elements and no others are present in the subject in the specified order.
If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg elements: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsExactly
infix fun <T : Iterable<E>, E> Builder<T>.containsExactly(elements: Collection<E>): Builder<T>
Asserts that all elements and no others are present in the subject in the specified order.
If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
elements: Collection<E>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsExactlyInAnyOrder
fun <T : Iterable<E>, E> Builder<T>.containsExactlyInAnyOrder(vararg elements: E): Builder<T>
Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg elements: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsExactlyInAnyOrder
infix fun <T : Iterable<E>, E> Builder<T>.containsExactlyInAnyOrder(elements: Collection<E>): Builder<T>
Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
elements: Collection<E>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isSorted
infix fun <T : Iterable<E>, E> Builder<T>.isSorted(comparator: Comparator
Asserts that the subject iterable is sorted according to the Comparator. Empty iterables are considered sorted.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
comparator: Comparator
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isSorted
fun <T : Iterable<E>, E : Comparable<E>> Builder<T>.isSorted(): Builder<T>
Asserts that the subject iterable is sorted according to the natural order of its elements. Empty iterables are considered sorted.
Receiver
Name | Description |
---|---|
Builder<T>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
get
operator fun <T : List<E>, E> Builder<T>.get(i: Int): Builder<E>
Maps this assertion to an assertion on the element at index i in the subject list.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
i: Int
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
get
operator fun <T : List<E>, E> Builder<T>.get(range: IntRange): Builder<List<E>>
Maps this assertion to an assertion on the elements at the sub-list represented by range in the subject list.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
range: IntRange
|
ReturnValue
Name | Description |
---|---|
Builder<List<E>>
|
get
operator fun <T : Map<K, V>, K, V> Builder<T>.get(key: K): Builder<V?>
Maps this assertion to an assertion on the value indexed by key in the subject list.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
ReturnValue
Name | Description |
---|---|
Builder<V?>
|
An assertion on the value indexed by key or |
containsSequence
fun <T : List<E>, E> Builder<T>.containsSequence(vararg elements: E): Builder<T>
Asserts that all elements are present in the subject in exactly the same order
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg elements: E
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsSequence
fun <T : List<E>, E> Builder<T>.containsSequence(elements: List<E>): Builder<T>
Asserts that all elements are present in the subject in exactly the same order
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
elements: List<E>
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
getValue
infix fun <T : Map<K, V>, K, V> Builder<T>.getValue(key: K): Builder<V>
Asserts that key exists in the subject map and then maps this assertion to an assertion on the associated value.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
ReturnValue
Name | Description |
---|---|
Builder<V>
|
An assertion on the value indexed by key. |
withValue
fun <T : Map<K, V>, K, V> Builder<T>.withValue(key: K, block: Builder<V>.()->Unit): Builder<T>
Runs a group of assertions on the value in the subject map tht corresponds to key.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
|
block: Builder<V>.()->Unit
|
a closure that can perform multiple assertions that will all be evaluated regardless of whether preceding ones pass or fail. |
ReturnValue
Name | Description |
---|---|
Builder<T>
|
this builder, to facilitate chaining. |
containsKey
infix fun <T : Map<K, V>, K, V> Builder<T>.containsKey(key: K): Builder<T>
Asserts that the subject map contains an entry indexed by key. Depending on
the map implementation the value associated with key may be null
. This
assertion just tests for the existence of the key.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
doesNotContainKey
infix fun <T : Map<K, V>, K, V> Builder<T>.doesNotContainKey(key: K): Builder<T>
Asserts that the subject map does not contain an entry indexed by key. Depending on
the map implementation the value associated with key may be null
. This
assertion just tests for the nonexistence of the key.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
containsKeys
fun <T : Map<K, V>, K, V> Builder<T>.containsKeys(vararg keys: K): Builder<T>
Asserts that the subject map contains entries for all keys.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg keys: K
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
doesNotContainKeys
fun <T : Map<K, V>, K, V> Builder<T>.doesNotContainKeys(vararg keys: K): Builder<T>
Asserts that the subject map doesn't contain entries for all keys.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
vararg keys: K
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
hasEntry
fun <T : Map<K, V>, K, V> Builder<T>.hasEntry(key: K, value: V): Builder<T>
Asserts that the subject map contains an entry indexed by key with a value equal to value.
Receiver
Name | Description |
---|---|
Builder<T>
|
Parameters
Name | Description |
---|---|
key: K
|
|
value: V
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
isFailure
fun <R> Builder<Result
Asserts that the result of an action did throw an exception and maps to
an assertion on the exception. The assertion fails if the subject's
Result.isFailure returns false
.
Receiver
Name | Description |
---|---|
Builder<Result
|
ReturnValue
Name | Description |
---|---|
Builder<Throwable>
|
isSuccess
fun <R> Builder<Result
Asserts that the result of an action did not throw any exception and maps to
an assertion on the result value. The assertion fails if the subject's
Result.isSuccess returns false
.
Receiver
Name | Description |
---|---|
Builder<Result
|
ReturnValue
Name | Description |
---|---|
Builder<R>
|
succeeded
fun <T> Builder<Result
Asserts that the subject is a successful result and maps this assertion to an assertion over the result value.
Receiver
Name | Description |
---|---|
Builder<Result
|
ReturnValue
Name | Description |
---|---|
Builder<T>
|
failed
fun <T> Builder<Result
Asserts that the subject is a failed result and maps this assertion to an assertion over the exception that was thrown
Receiver
Name | Description |
---|---|
Builder<Result
|
ReturnValue
Name | Description |
---|---|
Builder<Throwable>
|
failedWith
fun <E : Throwable> Builder<Result<*><
Asserts that the subject is a isFailure result that threw an exception assignable to E and maps this assertion to an assertion over that exception.
Receiver
Name | Description |
---|---|
Builder<Result<*><
|
ReturnValue
Name | Description |
---|---|
Builder<E>
|
doesNotThrow
fun <R : Any> Builder<Result
Deprecated form of isSuccess()
.
Receiver
Name | Description |
---|---|
Builder<Result
|
ReturnValue
Name | Description |
---|---|
Builder<R>
|
isEqualToIgnoringCase
infix fun Builder<String>.isEqualToIgnoringCase(expected: String): Builder<String>
Asserts that the subject is equal to the expected value regardless of case.
Receiver
Name | Description |
---|---|
Builder<String>
|
Parameters
Name | Description |
---|---|
expected: String
|
ReturnValue
Name | Description |
---|---|
Builder<String>
|
Asserts that the subject is
null
.