blob: fdf75a925699da4c91dfe1b8f7f389404fda9af8 [file] [log] [blame]
Francesco Vasco66d18c02017-08-04 18:10:09 +02001package kotlinx.coroutines.experimental.channels8
2
3import kotlinx.coroutines.experimental.TestBase
4import kotlinx.coroutines.experimental.channels.asReceiveChannel
5import kotlinx.coroutines.experimental.channels.toList
6import kotlinx.coroutines.experimental.runBlocking
7import org.junit.Assert.assertEquals
8import org.junit.Test
9import java.util.stream.Collectors
10
11class ChannelsTest : TestBase() {
12 private val testList = listOf(1, 2, 3)
13
14 @Test
15 fun testCollect() = runBlocking {
16 assertEquals(testList, testList.asReceiveChannel().collect(Collectors.toList()))
17 }
18
19 @Test
20 fun testStreamAsReceiveChannel() = runBlocking {
21 assertEquals(testList, testList.stream().asReceiveChannel().toList())
22 }
23
24 @Test
25 fun testReceiveChannelAsStream() {
26 assertEquals(testList, testList.asReceiveChannel().asStream().collect(Collectors.toList()))
27 }
28}