elementsOf

Finishes the specification of the sophisticated to contain expectation where all elements of the expectedIterableLike shall be searched, using a non-disjoint search.

Delegates to the values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) (see the for more information).

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

By non-disjoint is meant that "aa" in "aaaa" is found three times and not only two times.

Return

an Expect for the subject of this expectation.

Since

0.13.0

Parameters

expectedIterableLike

The IterableLike whose elements are expected to be contained within the input of the search.

Throws

in case expectedIterableLike is not an Iterable, Sequence or one of the Array types or the given expectedIterableLike does not have elements (is empty).


@JvmName(name = "elementsOfIgnoringCase")
infix fun <T : CharSequence> CharSequenceContains.CheckerStep<T, IgnoringCaseSearchBehaviour>.elementsOf(expectedIterableLike: IterableLike): Expect<T>(source)
@JvmName(name = "elementsOfIgnoringCase")
infix fun <T : CharSequence> CharSequenceContains.EntryPointStep<T, IgnoringCaseSearchBehaviour>.elementsOf(expectedIterableLike: IterableLike): Expect<T>(source)

Finishes the specification of the sophisticated to contain expectation where all elements of the expectedIterableLike shall be searched (ignoring case), using a non-disjoint search.

Delegates to the values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) (see the for more information).

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

By non-disjoint is meant that "aa" in "aaaa" is found three times and not only two times.

Return

an Expect for the subject of this expectation.

Since

0.13.0

Parameters

expectedIterableLike

The IterableLike whose elements are expected to be contained within the input of the search.

Throws

in case expectedIterableLike is not an Iterable, Sequence or one of the Array types or the given expectedIterableLike does not have elements (is empty).


fun <T : IterableLike> elementsOf(iterableLike: T, reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit): WithInOrderOnlyReportingOptions<T>(source)

Helper function to create a WithInOrderOnlyReportingOptions wrapping an IterableLike based on the given iterableLike and the given reportOptionsInOrderOnly-configuration-lambda.

Since

0.18.0

Parameters

iterableLike

The IterableLike whose elements this function is referring to.

reportOptionsInOrderOnly

The lambda configuring the InOrderOnlyReportingOptions.

Samples

expect(listOf(1, 2, 2, 4)) toContainExactlyElementsOf listOf(1, 2, 2, 4)

fails {
    expect(listOf(2, 3, 4)) toContainExactlyElementsOf listOf(2, 3, 4, 1)
}

fails {
    expect(listOf(1, 2, 2, 4)) toContainExactlyElementsOf listOf(1, 2, 4)
}

fails {
    // alternative form where you can specify a lambda configuring the InOrderOnlyReportingOptions.
    expect(listOf(1, 2, 2, 4)) toContainExactly elementsOf(
        listOf(1, 2, 4),
        reportOptionsInOrderOnly = { // allows configuring reporting, e.g.
            showOnlyFailing() // would not show the successful first and second `1, 2`
            showOnlyFailingIfMoreExpectedElementsThan(10)
        }
    )
}

fun <T : IterableLike> elementsOf(iterableLike: T, reportOptionsInAnyOrderOnly: InAnyOrderOnlyReportingOptions.() -> Unit): WithInAnyOrderOnlyReportingOptions<T>(source)

Helper function to create a WithInAnyOrderOnlyReportingOptions wrapping an IterableLike based on the given iterableLike and the given reportOptionsInAnyOrderOnly-configuration-lambda.

Since

0.18.0

Parameters

iterableLike

The IterableLike whose elements this function is referring to.

reportOptionsInAnyOrderOnly

The lambda configuring the InAnyOrderOnlyReportingOptions.


Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain all elements of the expectedIterableLike where it does not matter in which order they appear.

Delegates to values which also means that it does not search for unique matches (see values for more information).

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed (this can be changed via IterableLikeToIterableTransformer). This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.13.0

Parameters

expectedIterableLike

The IterableLike whose elements are expected to be contained within this IterableLike.

Throws

in case expectedIterableLike is not an Iterable, Sequence or one of the Array types or the given expectedIterableLike does not have elements (is empty).

Samples

ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInAnyOrderCreatorSamples.elementsOf

Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only and all elements of expectedIterableLike where it does not matter in which order.

Delegates to values.

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed (this can be changed via IterableLikeToIterableTransformer). This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.14.0 -- API existed for Iterable since 0.13.0 but not for IterableLike.

Parameters

expectedIterableLike

The IterableLike whose elements are expected to be contained within this IterableLike

Throws

in case expectedIterableLike is not an Iterable, Sequence or one of the Array types or the given expectedIterableLike does not have elements (is empty).

Samples

ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInAnyOrderOnlyCreatorSamples.elementsOf

Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only and all elements of expectedIterableLike in the specified order.

Delegates to values.

Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed (this can be changed via IterableLikeToIterableTransformer). This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.

Return

an Expect for the subject of this expectation.

Since

0.14.0 -- API existed for Iterable since 0.13.0 but not for IterableLike.

Parameters

expectedIterableLike

The IterableLike whose elements are expected to be contained within this IterableLike.

Throws

in case expectedIterableLike is not an Iterable, Sequence or one of the Array types or the given expectedIterableLike does not have elements (is empty).

Samples

ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInOrderOnlyCreatorSamples.elementsOf