Skip to content

Commit

Permalink
add some Iterable tests (arrow-kt#2894)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoizo committed Apr 25, 2023
1 parent 2aa81f9 commit d3a72af
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,26 @@ class IterableTest : StringSpec({
}
}

"flatten" {
checkAll(Arb.pair(Arb.list(Arb.int()), Arb.list(Arb.int()))) { (a, b) ->
listOf(a, b).flatten() shouldBe a + b
}
}

"widen(Iterable)" {
checkAll(Arb.list(Arb.string())) { orig: Iterable<String> ->
val result: Iterable<CharSequence> = orig.widen()
result shouldContainExactly orig
}
}

"widen(List)" {
checkAll(Arb.list(Arb.string())) { orig: List<String> ->
val result: List<CharSequence> = orig.widen()
result shouldContainExactly orig
}
}

"unzip is the inverse of zip" {
checkAll(Arb.list(Arb.int())) { xs ->

Expand Down Expand Up @@ -628,4 +648,19 @@ class IterableTest : StringSpec({
}
}
}

"compareTo returns 0 if other has same elements" {
checkAll(Arb.list(Arb.int())) { ints ->
ints.compareTo(ints) shouldBe 0
}
}

"compareTo returns -1 if other have greater element at the same position"{
listOf(1,2,3).compareTo(listOf(1,4,3)) shouldBe -1
}

"compareTo returns 1 if other have smaller element at the same position"{
listOf(1,2,3).compareTo(listOf(1,1,3)) shouldBe 1
}

})

0 comments on commit d3a72af

Please sign in to comment.