doc / ch.tutteli.atrium.api.cc.infix.en_GB / contains

contains

infix fun <T : CharSequence> Assert<T>.contains(expected: Any): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.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.

Exceptions

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> (source)

Makes the assertion that AssertionPlant.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')

Exceptions

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> (source)

Makes the assertion that AssertionPlant.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.pattern is defined as 'a(b)?' and one of the RegexPatterns.otherPatterns 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)?')

Parameters

patterns - The patterns which are expected to have a match against the input of the search.

Exceptions

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 : Any, T : Iterable<E>> Assert<T>.contains(expected: E): <ERROR CLASS> (source)

Makes the assertion that AssertionPlant.subject contains the expected value.

It is a shortcut for to contain inAny order atLeast 1 value expected

Exceptions

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(expected: NullableValue<E>): <ERROR CLASS> (source)

Makes the assertion that AssertionPlant.subject (which has a nullable entry type) contains the expected nullable value.

It is a shortcut for to contain inAny order atLeast 1 nullableValue expected

Exceptions

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(values: Values<E>): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.subject (which has a nullable entry type) 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')

Exceptions

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(nullableValues: NullableValues<E>): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.subject contains the expected nullableValues.

It is a shortcut for to contain inAny order atLeast 1 the NullableValues(...)

Notice, that it does not search for unique matches. Meaning, if the iterable is setOf('a', 'b') and nullableValues.expected is defined as 'a' and one nullableValues.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 nullableValue 'a' instead of: contains NullableValues('a', 'a')

Exceptions

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(assertionCreator: Assert<E>.() -> Unit): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.subject contains an entry holding the assertions created by the assertionCreator where it does not matter in which order the entries appear.

It is a shortcut for to contain inAny order atLeast 1 entry { ... }

Exceptions

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(nullableEntry: NullableEntry<E>): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.subject (which has a nullable entry type) contains an entry holding the assertions created by nullableEntry.assertionCreator or an entry which is null in case nullableEntry is defined as null.

It is a shortcut for to contain inAny order atLeast 1 nullableEntry { ... }

Exceptions

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> (source)

Makes the assertion that AssertionPlant.subject contains an entry holding the assertions created by the entries.assertionCreator -- likewise an entry (can be the same) is searched for each of the entries.otherAssertionCreators.

It is a shortcut for to contain inAny order atLeast 1 the Entries(...)

Exceptions

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(nullableEntries: NullableEntries<E>): AssertionPlant<T> (source)

Makes the assertion that AssertionPlant.subject (which has a nullable entry type) contains an entry holding the assertions created by nullableEntries.assertionCreator or an entry which is null in case nullableEntries.assertionCreator is defined as null -- likewise an entry (can be the same) is searched for each of the nullableEntries.otherAssertionCreators.

It is a shortcut for to contain inAny order atLeast 1 the NullableEntries(...)

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
This plant to support a fluent API.