infix fun <T : CharSequence> Expect<T>.contains(o: o): CharSequenceContains.Builder<T, NoOpSearchBehaviour>
Creates a CharSequenceContains.Builder based on this Expect which allows to define
a sophisticated contains
assertion.
o
- The filler object o; use O in case you are in an Expect context due to a Kotlin bug
(see type alias for more information)
Return
The newly created builder.
infix fun <T : CharSequence> Expect<T>.contains(not: not): NotCheckerOption<T, NotSearchBehaviour>
Creates a CharSequenceContains.Builder based on this Expect which allows to define
more sophisticated contains not
assertion.
Return
The newly created builder.
infix fun <T : CharSequence> Expect<T>.contains(expected: Any): Expect<T>
Expects that the subject of the assertion (a CharSequence) contains the expected's toString representation.
It is a shortcut for contains o 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).
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 assertion container to support a fluent API.
infix fun <T : CharSequence> Expect<T>.contains(values: Values<Any>): Expect<T>
Expects that the subject of the assertion (a CharSequence) contains the toString representation of the given values using a non disjoint search.
It is a shortcut for contains o atLeast 1 the Values(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
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:
contains o exactly 2 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 assertion container to support a fluent API.
infix fun <T : CharSequence> Expect<T>.contains(pattern: Regex): Expect<T>
Expects that the subject of the assertion (a CharSequence) contains a sequence which matches the given regular expression pattern.
It is a shortcut for contains o atLeast 1 regex pattern
.
pattern
- The pattern which is expected to have a match against the input of the search.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
This assertion container to support a fluent API.
infix fun <T : CharSequence> Expect<T>.contains(patterns: All<Regex>): Expect<T>
Expects that the subject of the assertion (a CharSequence) contains a sequence which matches the given regular expression patterns, using a non disjoint search.
It is a shortcut for contains o atLeast 1 regex All(pattern, *otherPatterns)
.
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:
contains o exactly 2 regex "a(b)?"
instead of:
contains o 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
This assertion container to support a fluent API.
infix fun <K, V, T : Map<out K, V>> Expect<T>.contains(keyValuePair: Pair<K, V>): Expect<T>
Expects that the subject of the assertion (a Map) 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
An Expect for the current subject of the assertion.
infix fun <K, V, T : Map<out K, V>> Expect<T>.contains(keyValuePairs: Pairs<K, V>): Expect<T>
Expects the subject of the assertion (a Map) contains for each entry in keyValuePairs, a key as defined by that entry's Pair.first with a corresponding value as defined by entry's Pair.second.
Notice, that it does not search for unique matches. Meaning, if the map is mapOf('a' to 1)
and one of the Pair
in keyValuePairs is defined as 'a' to 1
and another one 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
An Expect for the current subject of the assertion.
inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.contains(keyValue: KeyValue<K, V>): Expect<T>
Expects that the subject of the assertion (a Map) contains a key as defined by keyValue's KeyValue.key
with a corresponding value which either holds all assertions keyValue's
KeyValue.valueAssertionCreatorOrNull creates 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
An Expect for the current subject of the assertion.
inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.contains(keyValues: All<KeyValue<K, V>>): Expect<T>
Expects that the subject of the assertion (a Map) contains for each KeyValue in keyValues,
a key as defined by KeyValue.key with a corresponding value which either holds all
assertions KeyValue's KeyValue.valueAssertionCreatorOrNull creates 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 KeyValue in
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
An Expect for the current subject of the assertion.