Strikt.assertions

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 parent: Builder<String?>

Maps this assertion to an assertion on the parent file or null if the subject does not have a parent.

val extension: Builder<String>

Maps this assertion to an assertion on the file extension (not including the dot) or empty string if it not have one.

val nameWithoutExtension: Builder<String>

Maps this assertion to an assertion on the file name without the extension.

val fileName: Builder<Path>

Maps this assertion to an assertion on the path representing the name of the subject.

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 null.

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>

Asserts that the subject is null.

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-null subject.

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>

propertiesAreEqualTo

infix fun <T : Any> Builder<T>.propertiesAreEqualTo(other: T): Builder<T>

Asserts that all properties of the subject match those of other according to either contentEquals in the case of array properties or isEqualTo in other cases.

Properties are identified using Java beans conventions.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: T

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>

startsWith

infix fun <T : Path> Builder<T>.startsWith(other: Path): Builder<T>

Asserts that the subject starts with the provided path.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: Path

the given path

ReturnValue

Name Description
Builder<T>

startsWith

infix fun <T : Path> Builder<T>.startsWith(other: String): Builder<T>

Asserts that the subject starts with the provided path.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: String

the given path string

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>

endsWith

infix fun <T : Path> Builder<T>.endsWith(other: Path): Builder<T>

Asserts that the subject end with the provided path.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: Path

the given path

ReturnValue

Name Description
Builder<T>

endsWith

infix fun <T : Path> Builder<T>.endsWith(other: String): Builder<T>

Asserts that the subject end with the provided path string.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: String

the given path string

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>

isSorted

infix fun <T : Collection<E>, E> Builder<T>.isSorted(comparator: Comparator<E>): Builder<T>

Asserts that the subject collection is sorted according to the Comparator. Empty collections are considered sorted.

Receiver

Name Description
Builder<T>

Parameters

Name Description
comparator: Comparator<E>

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>

toPath

fun <T : File> Builder<T>.toPath(): Builder<Path>

Maps this assertion to an assertion on a path object representing this subject.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<Path>

lines

fun <T : File> Builder<T>.lines(charset: Charset): Builder<List<String>>

Maps this assertion to an assertion on the lines of the subject decoded using the provided charset.

Receiver

Name Description
Builder<T>

Parameters

Name Description
charset: Charset

the charset used to decode the content

ReturnValue

Name Description
Builder<List<String>>

text

fun <T : File> Builder<T>.text(charset: Charset): Builder<String>

Maps this assertion to an assertion on the complete text of the subject decoded using the provided charset.

Receiver

Name Description
Builder<T>

Parameters

Name Description
charset: Charset

the charset used to decode the content

ReturnValue

Name Description
Builder<String>

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>

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>

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>

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>

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>

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>

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 null if no such entry exists in the subject map.

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.

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>

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>

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>

isPresent

fun <T> Builder<Optional<T>>.isPresent(): Builder<T>

Asserts that an Optional contains a value (is not empty) and returns an assertion builder whose subject is the value.

Receiver

Name Description
Builder<Optional<T>>

ReturnValue

Name Description
Builder<T>

isAbsent

fun <T> Builder<Optional<T>>.isAbsent(): Builder<Optional<T>>

Asserts that an Optional does not contain a value.

Receiver

Name Description
Builder<Optional<T>>

ReturnValue

Name Description
Builder<Optional<T>>

toNullable

fun <T> Builder<Optional<T>>.toNullable(): Builder<T?>

Maps an assertion on a Java Optional to a Kotlin nullable type.

Receiver

Name Description
Builder<Optional<T>>

ReturnValue

Name Description
Builder<T?>

isAbsolute

fun <T : Path> Builder<T>.isAbsolute(): Builder<T>

Asserts that the subject is an absolute path.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<T>

resolve

infix fun <T : Path> Builder<T>.resolve(other: Path): Builder<Path>

Maps this assertion to an assertion of this subject resolved with the provided path.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: Path

the path to resolve against this subject's path

ReturnValue

Name Description
Builder<Path>

resolve

infix fun <T : Path> Builder<T>.resolve(other: String): Builder<Path>

Maps this assertion to an assertion of this subject resolved with the provided path.

Receiver

Name Description
Builder<T>

Parameters

Name Description
other: String

the path string to resolve against this subject's path

ReturnValue

Name Description
Builder<Path>

toFile

fun <T : Path> Builder<T>.toFile(): Builder<File>

Maps this assertion to an assertion on the file object representing this subject.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<File>

exists

fun <T : Path> Builder<T>.exists(vararg options: LinkOption): Builder<T>

Asserts that the subject exists, handling symbolic links according to the provided options

Receiver

Name Description
Builder<T>

Parameters

Name Description
vararg options: LinkOption

the options indicating how symbolic links are handled

ReturnValue

Name Description
Builder<T>

isDirectory

fun <T : Path> Builder<T>.isDirectory(vararg options: LinkOption): Builder<T>

Asserts that the subject is a directory, handling symbolic links according to the provided options.

Receiver

Name Description
Builder<T>

Parameters

Name Description
vararg options: LinkOption

the options indicating how symbolic links are handled

ReturnValue

Name Description
Builder<T>

isExecutable

fun <T : Path> Builder<T>.isExecutable(): Builder<T>

Asserts that the subject is executable link.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<T>

isReadable

fun <T : Path> Builder<T>.isReadable(): Builder<T>

Asserts that the subject is readable.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<T>

isRegularFile

fun <T : Path> Builder<T>.isRegularFile(vararg options: LinkOption): Builder<T>

Asserts that the subject is a regular file, handling symbolic links according to the provided options.

Receiver

Name Description
Builder<T>

Parameters

Name Description
vararg options: LinkOption

the options indicating how symbolic links are handled

ReturnValue

Name Description
Builder<T>

isSymbolicLink

fun <T : Path> Builder<T>.isSymbolicLink(): Builder<T>

Asserts that the subject is a symbolic link.

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<T>

allBytes

fun <T : Path> Builder<T>.allBytes(): Builder<ByteArray>

Maps this assertion to an assertion over all bytes of this subject path .

Receiver

Name Description
Builder<T>

ReturnValue

Name Description
Builder<ByteArray>

allLines

fun <T : Path> Builder<T>.allLines(charset: Charset): Builder<List<String>>

Maps this assertion to an assertion over all lines of this subject path decoded using the provided charset.

Receiver

Name Description
Builder<T>

Parameters

Name Description
charset: Charset

the charset to use in decoding

ReturnValue

Name Description
Builder<List<String>>

succeeded

fun <T> Builder<Try<T>>.succeeded(): Builder<T>

Asserts that the subject is a successful result and maps this assertion to an assertion over the result value.

Receiver

Name Description
Builder<Try<T>>

ReturnValue

Name Description
Builder<T>

failed

fun <T> Builder<Try<T>>.failed(): Builder<Throwable>

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<Try<T>>

ReturnValue

Name Description
Builder<Throwable>

failedWith

fun <E : Throwable> Builder<Try<*>>.failedWith(): Builder<E>

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<Try<*>>

ReturnValue

Name Description
Builder<E>

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>

doesNotThrow

fun <R : Any> Builder<Result<R>>.doesNotThrow(): Builder<R>

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.isFailure returns true.

Receiver

Name Description
Builder<Result<R>>

ReturnValue

Name Description
Builder<R>