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(defaultTranslationOf: DefaultTranslationsOf): AssertionPlant<T>
Makes the assertion that the Assert.subject contains DefaultTranslationsOf.expected's getDefault representation and the getDefault representations of the DefaultTranslationsOf.otherExpected (if given), using a non disjoint search.
It is a shortcut for to contain atLeast 1 the DefaultTranslationsOf(...)
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 the
default translation of DefaultTranslationsOf.expected is defined as 'a'
and one default translation of the
DefaultTranslationsOf.otherExpected is defined as 'a'
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 defaultTranslationOf IS
instead of:
to contain atLeast 1 the DefaultTranslationOf(IS, IS)
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
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.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)?')
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
An Expect for the current subject of the assertion.
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, T : Iterable<E>> Assert<T>.contains(objects: Objects<E>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains the expected objects.
It is a shortcut for to contain inAny order atLeast 1 the Objects(...)
Notice, that it does not search for unique matches. Meaning, if the iterable is setOf('a', 'b')
and Objects.expected is
defined as 'a'
and one Objects.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 Objects('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(assertionCreator: Assert<E>.() -> Unit): AssertionPlant<T>
Makes the assertion that the Assert.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 { ... }
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, Assert<E>.() -> Unit>): AssertionPlant<T>
Makes the assertion that the Assert.subject contains an entry holding the assertions created by the Entries.assertionCreator and an additional entry for each Entries.otherAssertionCreators (if given) where it does not matter in which order the entries appear.
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.