Skip to content

Commit

Permalink
Add samples for CharSequence.toContain...elementsOf #1522
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos-Tsiougranas committed Aug 29, 2023
1 parent 248c3fd commit afee3f6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.regex(
* [expectedIterableLike] does not have elements (is empty).
*
* @since 0.13.0
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOf
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.elementsOf(
expectedIterableLike: IterableLike
Expand All @@ -385,6 +388,8 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.elementsOf(
* @throws IllegalArgumentException in case [expectedIterableLike] is not an [Iterable], [Sequence] or one of the [Array] types or the given
* [expectedIterableLike] does not have elements (is empty).
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOfIgnoringCaseWithChecker
*
* @since 0.13.0
*/
@JvmName("elementsOfIgnoringCase")
Expand Down Expand Up @@ -413,6 +418,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.elementsOf(
* [expectedIterableLike] does not have elements (is empty).
*
* @since 0.13.0
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOfIgnoreCase
*
*/
@JvmName("elementsOfIgnoringCase")
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.elementsOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,37 @@ class CharSequenceToContainCreatorSamples {
expect("AAAAAABBBB").toContain.atLeast(3).matchFor(Regex("A"), Regex("B"), Regex("C"))
}
}


@Test
fun elementsOf() {
expect("ABC").toContain.exactly(1).elementsOf(listOf("A", "B", "C"))
expect("AAABC").toContain.atMost(3).elementsOf(listOf("A", "B", "C"))
expect("ABBBCD").toContain.atLeast(1).elementsOf(listOf("A", "B", "C", "D"))
fails {
expect("AAAAAABBBB").toContain.atMost(3).elementsOf(listOf("A", "B"))
expect("AAABBBB").toContain.exactly(3).elementsOf(listOf("A", "B"))
expect("AAAAAABBBB").toContain.atLeast(3).elementsOf(listOf("A", "B", "C"))
}
}

@Test
fun elementsOfIgnoreCase() {
expect("AbC").toContain.ignoringCase.elementsOf(listOf("A", "B", "c"))
fails {
expect("aabaabbb").toContain.ignoringCase.elementsOf(listOf("A", "B", "C"))
}
}

@Test
fun elementsOfIgnoringCaseWithChecker() {
expect("ABc").toContain.ignoringCase.exactly(1).elementsOf(listOf("A", "b", "C"))
expect("AaaBC").toContain.ignoringCase.atMost(3).elementsOf(listOf("A", "B", "c"))
expect("ABBBcD").toContain.ignoringCase.atLeast(1).elementsOf(listOf("a", "b", "C", "d"))
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).elementsOf(listOf("a", "b"))
expect("AAABBBB").toContain.ignoringCase.exactly(3).elementsOf(listOf("A", "b"))
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).elementsOf(listOf("a", "b", "C"))
}
}
}

0 comments on commit afee3f6

Please sign in to comment.