blob: 2bbc4a1da35026014c8ad098fb2eacccfcf4c98b [file] [log] [blame]
Vsevolod Tolstopyatov96191342018-04-20 18:13:33 +03001/*
2 * Copyright 2016-2017 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package kotlinx.coroutines.experimental.channels
18
19import kotlin.test.*
20
21
22class BroadcastChannelFactoryTest {
23
24 @Test
25 fun testRendezvousChannelNotSupported() {
26 assertFailsWith<IllegalArgumentException> { BroadcastChannel<Int>(0) }
27 }
28
29 @Test
30 fun testLinkedListChannelNotSupported() {
31 assertFailsWith<IllegalArgumentException> { BroadcastChannel<Int>(Channel.UNLIMITED) }
32 }
33
34 @Test
35 fun testConflatedBroadcastChannel() {
36 assertTrue { BroadcastChannel<Int>(Channel.CONFLATED) is ConflatedBroadcastChannel }
37 }
38
39 @Test
40 fun testArrayBroadcastChannel() {
41 assertTrue { BroadcastChannel<Int>(1) is ArrayBroadcastChannel }
42 assertTrue { BroadcastChannel<Int>(10) is ArrayBroadcastChannel }
43 }
44
45 @Test
46 fun testInvalidCapacityNotSupported() {
47 assertFailsWith<IllegalArgumentException> { BroadcastChannel<Int>(-2) }
48 }
49}