infix fun <T : CharSequence> Assert<T>.contains(expected: Any): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the toString representation of the given expected using a non disjoint search.
It is a shortcut for to contain atLeast 1 value expected
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.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
IllegalArgumentException
- in case expected is not a CharSequence, Number or Char.
Return
This plant to support a fluent API.
infix fun <T : CharSequence> Assert<T>.contains(values: Values<Any>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the given values representation using a non disjoint search.
It is a shortcut for to contain atLeast 1 the Values(...)
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 Values.expected
is defined as 'a'
and one Values.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 contains
to create a more sophisticated contains
assertion where you can use options such as atLeast, atMost and exactly to control the number of occurrences
you expect.
Meaning you might want to use:
to contain exactly 2 the value 'a'
instead of:
contains Values('a', 'a')
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
IllegalArgumentException
- in case one of the values is not a CharSequence, Number or Char.
Return
This plant to support a fluent API.
infix fun <T : CharSequence> Assert<T>.contains(patterns: RegexPatterns): AssertionPlant<T>
Makes the assertion that the Assert.subject contains a sequence which matches the given patterns using a non disjoint search.
It is a shortcut for to contain atLeast 1 the RegexPatterns(...)
.
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 'ab'
and
RegexPatterns.expected is defined as 'a(b)?'
and one of the RegexPatterns.otherExpected is defined as
'a(b)?'
as well, then both match, even though they match the same sequence in the input of the search.
Use an option such as atLeast, atMost and exactly to control the number of occurrences you expect.
Meaning you might want to use:
to contain exactly 2 the regex 'a(b)?'
instead of:
to contain atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')
patterns
- The patterns which are expected to have a match against the input of the search.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
The AssertionPlant for which the assertion was built to support a fluent API.
infix fun <E, T : Iterable<E>> Assert<T>.contains(expected: E): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the expected value.
It is a shortcut for to contain inAny order atLeast 1 value expected
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <E, T : Iterable<E>> Assert<T>.contains(values: Values<E>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the expected values.
It is a shortcut for to contain inAny order atLeast 1 the Values(...)
Notice, that it does not search for unique matches. Meaning, if the iterable is setOf('a', 'b')
and
values.expected is defined as 'a'
and
one values.otherExpected is defined as 'a'
as well, then both match,
even though they match the same entry. Use an option such as atLeast, atMost and exactly to control the
number of occurrences you expect.
Meaning you might want to use:
to contain inAny order exactly 2 value 'a'
instead of:
contains Values('a', 'a')
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <E : Any, T : Iterable<E?>> Assert<T>.contains(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 to contain inAny order atLeast 1 entry assertionCreatorOrNull
assertionCreatorOrNull
- The identification lambda which creates the assertions which the entry we are looking
for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
or not. In case it is defined as null
, then an entry is identified if it is null
as well.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <E : Any, T : Iterable<E?>> Assert<T>.contains(entries: Entries<E>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains an entry holding the
assertions created by entries.assertionCreatorOrNull or an entry
which is null
in case entries.assertionCreatorOrNull
is defined as null
-- likewise an entry (can be the same) is searched for each of the
entries.otherAssertionCreatorsOrNulls.
It is a shortcut for to contain inAny order atLeast 1 the Entries(...)
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <K, V, T : Map<out K, V>> Assert<T>.contains(keyValuePair: Pair<K, V>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains a key as defined by keyValuePair's Pair.first with a corresponding value as defined by keyValuePair's Pair.second.
Delegates to contains Pairs(keyValuePair)
.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <K, V, T : Map<out K, V>> Assert<T>.contains(keyValuePairs: Pairs<K, V>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains for each entry in keyValuePairs, a key as defined by entry's Pair.first with a corresponding value as defined by entry's Pair.second.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <K, V : Any, T : Map<out K, V?>> Assert<T>.contains(keyValue: 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
.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This plant to support a fluent API.
infix fun <K, V : Any, T : Map<out K, V?>> Assert<T>.contains(keyValues: All<KeyValue<K, V>>): AssertionPlant<T>
Makes the assertion that for each of the KeyValue in keyValues, 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
.
Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1)
and one of the
keyValues is defined as Key('a') { isGreaterThan(0) }
and another one 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.
infix fun <E, T : Iterable<E>> Assert<T>.contains(nullableValue: NullableValue<E>): AssertionPlant<T>
infix fun <E, T : Iterable<E>> Assert<T>.contains(nullableValues: NullableValues<E>): AssertionPlant<T>
infix fun <E : Any, T : Iterable<E?>> Assert<T>.contains(nullableEntry: NullableEntry<E>): AssertionPlant<T>
infix fun <E : Any, T : Iterable<E?>> Assert<T>.contains(nullableEntries: NullableEntries<E>): AssertionPlant<T>