infix fun <T : CharSequence> CharSequenceContains.CheckerStep<T, NoOpSearchBehaviour>.matchFor(pattern: Regex): Expect<T>
infix fun <T : CharSequence> CharSequenceContains.CheckerOption<T, NoOpSearchBehaviour>.matchFor(pattern: Regex): Expect<T>
Finishes the specification of the sophisticated contains
assertion where the given Regex
is expected to have a match.
Delegates to matchFor all(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
An Expect for the current subject of the assertion.
Since
0.12.0
infix fun <T : CharSequence> CharSequenceContains.CheckerStep<T, NoOpSearchBehaviour>.matchFor(patterns: All<Regex>): Expect<T>
infix fun <T : CharSequence> CharSequenceContains.CheckerOption<T, NoOpSearchBehaviour>.matchFor(patterns: All<Regex>): Expect<T>
Finishes the specification of the sophisticated contains
assertion where the given Regex
are expected to have a match, using a non disjoint search.
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
All is defined as all(Regex("a(b)?"), Regex("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 all(Regex("a(b)?"), Regex("a(b)?"))
patterns
- The patterns which are expected to have a match against the input of the search --
use the function all(Regex(...), ...)
to create a All.
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
An Expect for the current subject of the assertion.
Since
0.12.0