blob: 005bb1670fe8ce5411c54278afec01b7df82edb4 [file] [log] [blame]
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
Francesco Vasco66d18c02017-08-04 18:10:09 +02005package kotlinx.coroutines.experimental.channels8
6
7import kotlinx.coroutines.experimental.TestBase
8import kotlinx.coroutines.experimental.channels.asReceiveChannel
9import kotlinx.coroutines.experimental.channels.toList
10import kotlinx.coroutines.experimental.runBlocking
11import org.junit.Assert.assertEquals
12import org.junit.Test
13import java.util.stream.Collectors
14
15class 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}