val <T : CharSequence> Assert<T>.enthaelt: CharSequenceContains.Builder<T, NoOpSearchBehaviour>
Creates a CharSequenceContains.Builder based on this AssertionPlant which allows to define
more sophisticated contains
assertions.
Return
The newly created builder.
fun <T : CharSequence> Assert<T>.enthaelt(expected: Any, vararg otherExpected: Any): AssertionPlant<T>
Makes the assertion that the Assert.subject contains expected's toString representation and the toString representation of the otherExpected (if given), using a non disjoint search.
It is a shortcut for enthaelt.zumindest(1).werte(expected, *otherExpected)
.
Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed (this
function expects 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.
Also notice, that it does not search for unique matches. Meaning, if the input of the search is 'a'
and expected
is defined as 'a'
and one otherExpected is defined as 'a'
as well, then both match, even though they match the
same sequence in the input of the search. Use the property enthaelt
to create a more sophisticated contains
assertion where you can use options such as zumindest, hoechstens and genau to control the number of
occurrences you expect.
Meaning you might want to use:
enthaelt.genau(2).wert('a')
instead of:
enthaelt('a', 'a')
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
IllegalArgumentException
- in case expected or one of the otherExpected is not a
CharSequence, Number or Char.
Return
This plant to support a fluent API.
fun <E, T : Iterable<E>> Assert<T>.enthaelt(expected: E, vararg otherExpected: E): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the expected value and the otherExpected values (if given).
It is a shortcut for enthaelt.inBeliebigerReihenfolge.zumindest(1).werte(expected, *otherExpected)
Notice, that it does not search for unique matches. Meaning, if the iterable is setOf('a', 'b')
and
expected is defined as 'a'
and one of the otherExpected is defined as 'a'
as well, then both
match, even though they match the same entry. Use an option such as zumindest, hoechstens and genau to control
the number of occurrences you expect.
Meaning you might want to use:
enthaelt.inBeliebigerReihenfolge.genau(2).wert('a')
instead of:
enthaelt.werte('a', 'a')
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
fun <E : Any, T : Iterable<E?>> Assert<T>.enthaelt(assertionCreatorOrNull: (Assert<E>.() -> Unit)?): AssertionPlant<T>
Makes the assertion that the Assert.subject contains an entry holding the
assertions created by assertionCreatorOrNull or an entry which is null
in case assertionCreatorOrNull
is defined as null
.
It is a shortcut for enthaelt.inBeliebigerReihenfolge.zumindest(1).eintrag(assertionCreatorOrNull)
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
fun <E : Any, T : Iterable<E?>> Assert<T>.enthaelt(assertionCreatorOrNull: (Assert<E>.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Assert<E>.() -> Unit)?): AssertionPlant<T>
Makes the assertion that the Assert.subject contains an entry holding the
assertions created by assertionCreatorOrNull or an entry which is null
in case assertionCreatorOrNull
is defined as null
-- likewise an entry (can be the same) is searched for each
of the otherAssertionCreatorsOrNulls.
It is a shortcut for enthaelt.inBeliebigerReihenfolge.zumindest(1).eintraege(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
fun <K, V, T : Map<out K, V>> Assert<T>.enthaelt(entry: Pair<K, V>, vararg otherEntries: Pair<K, V>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains a key as defined by entry's Pair.first with a corresponding value as defined by entry's Pair.second -- optionally the same assertions are created for the otherEntries.
Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1)
and entry is
defined as 'a' to 1
and one of the otherEntries is defined as 'a' to 1
as well, then both match,
even though they match the same entry.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
fun <K, V : Any, T : Map<out K, V?>> Assert<T>.enthaelt(keyValue: KeyValue<K, V>, vararg otherKeyValues: KeyValue<K, V>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains a key as defined by keyValue's KeyValue.key
with a corresponding value which either holds all assertions keyValue's
KeyValue.valueAssertionCreatorOrNull might create or needs to be null
in case
KeyValue.valueAssertionCreatorOrNull is defined as null
-- optionally the same assertions are created for the otherKeyValues.
Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1)
and keyValue is
defined as Key('a') { isGreaterThan(0) }
and one of the otherKeyValues is defined as Key('a') { isLessThan(2) }
, then both match, even though they match the same entry.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.