diff --git a/apis/fluent/atrium-api-fluent/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceToContainCreators.kt b/apis/fluent/atrium-api-fluent/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceToContainCreators.kt index 317285b995..316a7dfffd 100644 --- a/apis/fluent/atrium-api-fluent/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceToContainCreators.kt +++ b/apis/fluent/atrium-api-fluent/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceToContainCreators.kt @@ -210,6 +210,9 @@ fun EntryPointStep.values( * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regex + * */ fun CheckerStep.regex( pattern: String, @@ -268,6 +271,9 @@ fun CheckerStep.regex( * @return an [Expect] for the subject of `this` expectation. * * @since 1.1.0 + * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.matchFor + * */ fun CheckerStep.matchFor( pattern: Regex, @@ -293,6 +299,9 @@ fun CheckerStep.matchFor( * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regexIgnoringCaseWithChecker + * */ @JvmName("regexIgnoringCase") fun CheckerStep.regex( @@ -322,6 +331,9 @@ fun CheckerStep.regex( * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regexIgnoringCase + * */ fun EntryPointStep.regex( pattern: String, diff --git a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceToContainCreatorSamples.kt b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceToContainCreatorSamples.kt index c1db321280..921566905e 100644 --- a/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceToContainCreatorSamples.kt +++ b/apis/fluent/atrium-api-fluent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceToContainCreatorSamples.kt @@ -91,4 +91,66 @@ class CharSequenceToContainCreatorSamples { expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).values("a", "b", "C") } } + + @Test + fun regex() { + expect("ABC").toContain.exactly(1).regex("A", "B", "C") + expect("AAABC").toContain.atMost(3).regex("A", "B", "C") + expect("ABBBCD").toContain.atLeast(1).regex("A", "B", "C", "D") + fails { + expect("AAAAAABBBB").toContain.atMost(3).regex("A", "B") + } + + fails { + expect("AAABBBB").toContain.exactly(3).regex("A", "B") + } + + fails { + expect("AAAAAABBBB").toContain.atLeast(3).regex("A", "B", "C") + } + } + + @Test + fun regexIgnoringCase() { + expect("AbC").toContain.ignoringCase.regex("A", "B", "c") + fails { + expect("aabaabbb").toContain.ignoringCase.regex("A", "B", "C") + } + } + + @Test + fun regexIgnoringCaseWithChecker() { + expect("ABc").toContain.ignoringCase.exactly(1).regex("A", "b", "C") + expect("AaaBC").toContain.ignoringCase.atMost(3).regex("A", "B", "c") + expect("ABBBcD").toContain.ignoringCase.atLeast(1).regex("a", "b", "C", "d") + fails { + expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).regex("a", "b") + } + + fails { + expect("AAABBBB").toContain.ignoringCase.exactly(3).regex("A", "b") + } + + fails { + expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).regex("a", "b", "C") + } + } + + @Test + fun matchFor() { + expect("ABC").toContain.exactly(1).matchFor(Regex("A"), Regex("B"), Regex("C")) + expect("AAABC").toContain.atMost(3).matchFor(Regex("A"), Regex("B"), Regex("C")) + expect("ABBBCD").toContain.atLeast(1).matchFor(Regex("A"), Regex("B"), Regex("C"), Regex("D")) + fails { + expect("AAAAAABBBB").toContain.atMost(3).matchFor(Regex("A"), Regex("B")) + } + + fails { + expect("AAABBBB").toContain.exactly(3).matchFor(Regex("A"), Regex("B")) + } + + fails { + expect("AAAAAABBBB").toContain.atLeast(3).matchFor(Regex("A"), Regex("B"), Regex("C")) + } + } }