Skip to content

Commit

Permalink
Merge pull request #1810 from hubtanaka/hubtanaka/samples/Iterable-to…
Browse files Browse the repository at this point in the history
…Contain-values

add samples for Iterable.toContain....values
  • Loading branch information
robstoll authored Aug 14, 2024
2 parents 64b6fce + 91a99ad commit 1910d70
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ fun <E, T: IterableLike> CheckerStep<E, T, InAnyOrderSearchBehaviour>.value(expe
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInAnyOrderCreatorSamples.values
*/
fun <E, T: IterableLike> CheckerStep<E, T, InAnyOrderSearchBehaviour>.values(
expected: E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ fun <E, T : IterableLike> EntryPointStep<E, T, InAnyOrderOnlySearchBehaviour>.va
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInAnyOrderOnlyCreatorSamples.values
*/
fun <E, T : IterableLike> EntryPointStep<E, T, InAnyOrderOnlySearchBehaviour>.values(
expected: E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ fun <E, T : IterableLike> EntryPointStep<E, T, InOrderOnlySearchBehaviour>.value
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.IterableLikeToContainInOrderOnlyCreatorSamples.values
*/
fun <E, T : IterableLike> EntryPointStep<E, T, InOrderOnlySearchBehaviour>.values(
expected: E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ class IterableLikeToContainInAnyOrderCreatorSamples {
}
}

@Test
fun values(){
expect(listOf("A","B")).toContain.inAnyOrder.exactly(1).values("B", "A")
expect(listOf("A","B","A","B")).toContain.inAnyOrder.atLeast(2).values("B", "A")
expect(listOf("A","B","B")).toContain.inAnyOrder.atMost(2).values("B", "A")

fails {
expect(listOf("A","B")).toContain.inAnyOrder.exactly(2).values("B", "A")
expect(listOf("A","B","A","B")).toContain.inAnyOrder.atLeast(3).values("B", "A")
expect(listOf("A","B","B","B")).toContain.inAnyOrder.atMost(2).values("B", "A")
}
}

@Test
fun elementsOf(){
expect(listOf("A","B")).toContain.inAnyOrder.exactly(1).elementsOf(listOf("A","B"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ class IterableLikeToContainInAnyOrderOnlyCreatorSamples {
}
}

@Test
fun values(){
expect(listOf("A","B","C")).toContain.inAnyOrder.only.values(
"C", "B", "A"
)

fails { // because not all elements found
expect(listOf("A","B","C")).toContain.inAnyOrder.only.values(
"B","A"
)
}

fails { // because more elements expected than found
expect(listOf("A","B","C")).toContain.inAnyOrder.only.values(
"D","C","B","A"
)
}
}

@Test
fun elementsOf(){
expect(listOf("A","B","C")).toContain.inAnyOrder.only.elementsOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ class IterableLikeToContainInOrderOnlyCreatorSamples {
}
}

@Test
fun values(){
expect(listOf("A","B","C")).toContain.inOrder.only.values(
"A","B","C"
)

fails { // although same elements but not in same order
expect(listOf("A","B","C")).toContain.inOrder.only.values(
"A","C","B"
)
}

fails { // because not all elements found
expect(listOf("A","B","C")).toContain.inOrder.only.values(
"A","B"
)
}

fails { // because more elements expected than found
expect(listOf("A","B","C")).toContain.inOrder.only.values(
"A","B","C","D"
)
}
}

@Test
fun elementsOf(){
expect(listOf("A","B","C")).toContain.inOrder.only.elementsOf(
Expand Down

0 comments on commit 1910d70

Please sign in to comment.