Francesco Vasco | 66d18c0 | 2017-08-04 18:10:09 +0200 | [diff] [blame^] | 1 | package kotlinx.coroutines.experimental.channels8 |
| 2 | |
| 3 | import kotlinx.coroutines.experimental.TestBase |
| 4 | import kotlinx.coroutines.experimental.channels.asReceiveChannel |
| 5 | import kotlinx.coroutines.experimental.channels.toList |
| 6 | import kotlinx.coroutines.experimental.runBlocking |
| 7 | import org.junit.Assert.assertEquals |
| 8 | import org.junit.Test |
| 9 | import java.util.stream.Collectors |
| 10 | |
| 11 | class 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 | } |