Skip to content

Commit

Permalink
refactor: migrate NotEmptySetTest to kotlin-test (#3230)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Serrano <trupill@gmail.com>
  • Loading branch information
milgner and serras authored Oct 26, 2023
1 parent f384c5d commit 67f9c0f
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,45 @@ package arrow.core

import arrow.core.test.nonEmptySet
import io.kotest.assertions.withClue
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.nulls.shouldNotBeNull
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.next
import io.kotest.property.checkAll
import kotlin.test.Test
import kotlinx.coroutines.test.runTest

class NonEmptySetTest : StringSpec({
class NonEmptySetTest {

"iterable.toNonEmptySetOrNull should round trip" {
@Test fun iterableToNonEmptySetOrNullShouldRoundTrip() = runTest {
checkAll(Arb.nonEmptySet(Arb.int())) { nonEmptySet ->
nonEmptySet.toNonEmptySetOrNull().shouldNotBeNull() shouldBe nonEmptySet
}
}

"iterable.toNonEmptySetOrNone should round trip" {
@Test fun iterableToNonEmptySetOrNoneShouldRoundTrip() = runTest {
checkAll(Arb.nonEmptySet(Arb.int())) { nonEmptySet ->
nonEmptySet.toNonEmptySetOrNone() shouldBe nonEmptySet.some()
}
}

"emptyList.toNonEmptySetOrNull should be null" {
@Test fun emptyListToNonEmptySetOrNullShouldBeNull() = runTest {
listOf<Int>().toNonEmptySetOrNull() shouldBe null
}

"emptyList.toNonEmptySetOrNone should be none" {
@Test fun emptyListToNonEmptySetOrNoneShouldBeNone() = runTest {
listOf<Int>().toNonEmptySetOrNone() shouldBe none()
}

"adding an element already present doesn't change the set" {
@Test fun addingAnElementAlreadyPresentDoesNotChangeTheSet() = runTest {
val element = Arb.int().next()
val initialSet: NonEmptySet<Int> = nonEmptySetOf(element) + Arb.nonEmptySet(Arb.int()).next()
initialSet.plus(element) shouldBe initialSet
}

"NonEmptySet equals Set" {
@Test fun nonEmptySetEqualsSet() = runTest {
checkAll(
Arb.nonEmptySet(Arb.int())
) { nes ->
Expand All @@ -51,7 +52,7 @@ class NonEmptySetTest : StringSpec({
}
}

"NonEmptySet equals NonEmptySet" {
@Test fun nonEmptySetEqualsNonEmptySet() = runTest {
checkAll(
Arb.nonEmptySet(Arb.int())
) { nes ->
Expand All @@ -62,5 +63,5 @@ class NonEmptySetTest : StringSpec({
}
}
}
})
}

0 comments on commit 67f9c0f

Please sign in to comment.