Skip to content

Commit

Permalink
feat(pairwise): tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Jul 6, 2022
1 parent 6f29088 commit 93efe74
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/commonTest/kotlin/com/hoc081098/flowext/PairwiseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.take

Expand Down Expand Up @@ -67,6 +68,23 @@ class PairwiseTest : BaseStepTest() {
)
}

@Test
fun testPairwiseNullable() = runTest {
// 0 - null - 2 - null

range(0, 4)
.map { it.takeIf { it % 2 == 0 } }
.pairwise()
.test(
listOf(
Event.Value(0 to null),
Event.Value(null to 2),
Event.Value(2 to null),
Event.Complete
)
)
}

@Test
fun testPairwiseEmpty() = runTest {
emptyFlow<Int>()
Expand Down

0 comments on commit 93efe74

Please sign in to comment.