infix fun <T : CharSequence> Expect<T>.containsRegex(pattern: String): 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>.containsRegex(patterns: RegexPatterns): 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 the RegexPatterns(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.