Skip to content

Commit

Permalink
Add samples for CharSequence.toContain...value robstoll#1520
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos-Tsiougranas committed Aug 29, 2023
1 parent fb80582 commit 283c198
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import kotlin.jvm.JvmName
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.value
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.value
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valueIgnoringCase
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valueIgnoringCaseWithChecker
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.value(expected: CharSequenceOrNumberOrChar): Expect<T> =
values(expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ class CharSequenceToContainCreatorSamples {
}
}

@Test
fun valueIgnoringCase() {
expect("ABC").toContain.ignoringCase.value("a")
expect("AbbbC").toContain.ignoringCase.value("B")

fails {
expect("AAAAAA").toContain.ignoringCase.value("B")
}
}

@Test
fun valueIgnoringCaseWithChecker() {
expect("ABC").toContain.ignoringCase.exactly(1).value("A")
expect("AAABBC").toContain.ignoringCase.atMost(3).value("b")
expect("aBBBCD").toContain.ignoringCase.atLeast(1).value("A")
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).value("A")
expect("AAABBBb").toContain.ignoringCase.exactly(3).value("b")
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).value("D")
}
}

@Test
fun values() {
expect("ABC").toContain.exactly(1).values("A", "B", "C")
Expand Down

0 comments on commit 283c198

Please sign in to comment.