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 30, 2023
1 parent d8c0def commit fbe44e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import kotlin.jvm.JvmName
* @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.value
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.value(expected: CharSequenceOrNumberOrChar): Expect<T> =
values(expected)
Expand Down Expand Up @@ -90,6 +91,9 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.values(
*
* @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.valueIgnoringCaseWithChecker
*
*/
@JvmName("valueIgnoringCase")
fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.value(
Expand Down Expand Up @@ -148,6 +152,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.values(
*
* @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.valueIgnoringCase
*
*/
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.value(
expected: CharSequenceOrNumberOrChar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ 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")
}

fails {
expect("AAABBBb").toContain.ignoringCase.exactly(3).value("b")
}

fails {
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 fbe44e3

Please sign in to comment.