value

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

Delegates to values.

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

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.

Parameters

expected

The value which is expected to be contained within the input of the search.

Throws

Samples

// `value` is a final step in the CharSequence.toContain expectation-building process and can be used with
// various checkers (see CharSequenceToContainCheckerSamples)

expect("ABC").toContain.exactly(1).value("A")
expect("ABBBC").toContain.atLeast(2).value("B")

fails {
    expect("AAAAAA").toContain.atMost(3).value("A")
}

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

Delegates to values(expected).

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

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.

Parameters

expected

The value which is expected to be contained within the input of the search.

Throws

Samples

// `value` is a final step in the CharSequence.toContain expectation-building process and can be used with
// various checkers (see CharSequenceToContainCheckerSamples)

expect("ABC").toContain.ignoringCase.exactly(1).value("A")
expect("AAABBC").toContain.ignoringCase.atMost(3).value("b")
expect("aBBBCD").toContain.ignoringCase.atLeast(1).value("A")

fails {
    expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).value("A")
}
fails {
    expect("AAABBBb").toContain.ignoringCase.exactly(3).value("b")
}
fails {
    expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).value("D")
}

Finishes the specification of the sophisticated to contain expectation where the expected value shall be searched (ignoring case), using a non-disjoint search where it needs to be contained at least once.

Delegates to atLeast(1).value(expected).

Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.

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.

Parameters

expected

The value which is expected to be contained within the input of the search.

Throws

Samples

expect("ABC").toContain.ignoringCase.value("a")
expect("AbbbC").toContain.ignoringCase.value("B")

fails {
    expect("AAAAAA").toContain.ignoringCase.value("B")
}

Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain the expected value.

Delegates to values.

Return

an Expect for the subject of this expectation.

Since

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

Parameters

expected

The value which is expected to be contained within this IterableLike.


Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only the expected value.

Delegates to values.

Return

an Expect for the subject of this expectation.

Since

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

Parameters

expected

The value which is expected to be contained within the subject (an IterableLike).


Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only the expected value.

Delegates to values.

Return

an Expect for the subject of this expectation.

Since

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

Parameters

expected

The value which is expected to be contained within the subject (an IterableLike).


fun <K, V, T : Map.Entry<K, V>> Expect<T>.value(assertionCreator: Expect<V>.() -> Unit): Expect<T>(source)

Expects that the property Map.Entry.value of 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.

Samples

val entry = mapOf(1 to "a").entries.first()

expect(entry).value { // subject inside this expectation-group is of type String (actually "a")
    toEqual("a")
} // subject here is back to type Map.Entry<Int, String>

fails {
    expect(entry).value { // subject inside this expectation-group is of type String (actually "a")
        toEqual("b")      // fails
        toStartWith("z")  // still evaluated even though `toEqual` already fails,
        //                   use `.value.` if you want a fail fast behaviour
    }
}

val <V, T : Map.Entry<*, V>> Expect<T>.value: Expect<V>(source)

Creates an Expect for the property Map.Entry.value of the subject of this expectation, so that further fluent calls are assertions about it.

Return

The newly created Expect for the extracted feature.

Samples

val entry = mapOf(1 to "a").entries.first()

expect(entry)
    .value  // subject here is of type String (actually "a")
    .toEqual("a")

fails {
    expect(entry)
        .value            // subject here is of type String (actually "a")
        .toEqual("b")     // fails
        .toStartWith("z") // not evaluated/reported because `toEqual` already fails
    //                       use `.value { ... }` if you want that all assertions are evaluated
}