Skip to content

Commit

Permalink
Merge pull request #1559 from Nikos-Tsiougranas/#1544-add-samples-ite…
Browse files Browse the repository at this point in the history
…rable-toContain-exactly

Add samples for Iterable.toContain.exactly
  • Loading branch information
robstoll authored Sep 30, 2023
2 parents 288b3fe + a621e4d commit a993f48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ fun <E, T: IterableLike, S : InAnyOrderSearchBehaviour> AtLeastCheckerStep<E, T,
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainCheckerSamples.exactly
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*/
fun <E, T: IterableLike, S : InAnyOrderSearchBehaviour> IterableLikeContains.EntryPointStep<E, T, S>.exactly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class IterableLikeToContainCheckerSamples {
@Test
fun exactly() {
expect(listOf("A", "B", "A")).toContain.inAnyOrder.exactly(2).entry {
toEqual("A")
}

expect(listOf(1, 2, 3)).toContain.inAnyOrder.exactly(2).entry {
toBeGreaterThan(1)
}

fails {
expect(listOf("A", "B", "A", "C")).toContain.inAnyOrder.exactly(2).entry {
toEqual("B")
}
}

fails {
expect(listOf(1, 2, 3)).toContain.inAnyOrder.exactly(2).entry {
toBeLessThanOrEqualTo(1)
}
}
}
}

0 comments on commit a993f48

Please sign in to comment.