Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
Francesco Vasco | 66d18c0 | 2017-08-04 18:10:09 +0200 | [diff] [blame] | 5 | package kotlinx.coroutines.experimental.channels8 |
| 6 | |
| 7 | import kotlinx.coroutines.experimental.TestBase |
| 8 | import kotlinx.coroutines.experimental.channels.asReceiveChannel |
| 9 | import kotlinx.coroutines.experimental.channels.toList |
| 10 | import kotlinx.coroutines.experimental.runBlocking |
| 11 | import org.junit.Assert.assertEquals |
| 12 | import org.junit.Test |
| 13 | import java.util.stream.Collectors |
| 14 | |
| 15 | class ChannelsTest : TestBase() { |
| 16 | private val testList = listOf(1, 2, 3) |
| 17 | |
| 18 | @Test |
| 19 | fun testCollect() = runBlocking { |
| 20 | assertEquals(testList, testList.asReceiveChannel().collect(Collectors.toList())) |
| 21 | } |
| 22 | |
| 23 | @Test |
| 24 | fun testStreamAsReceiveChannel() = runBlocking { |
| 25 | assertEquals(testList, testList.stream().asReceiveChannel().toList()) |
| 26 | } |
| 27 | |
| 28 | @Test |
| 29 | fun testReceiveChannelAsStream() { |
| 30 | assertEquals(testList, testList.asReceiveChannel().asStream().collect(Collectors.toList())) |
| 31 | } |
| 32 | } |