Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCountTest.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.operators.flowable;
15
16 import org.junit.*;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.functions.Function;
20 import io.reactivex.rxjava3.testsupport.TestHelper;
21
22 public class FlowableCountTest extends RxJavaTest {
23 @Test
24 public void simpleFlowable() {
25 Assert.assertEquals(0, Flowable.empty().count().toFlowable().blockingLast().intValue());
26
27 Assert.assertEquals(1, Flowable.just(1).count().toFlowable().blockingLast().intValue());
28
29 Assert.assertEquals(10, Flowable.range(1, 10).count().toFlowable().blockingLast().intValue());
30
31 }
32
33 @Test
34 public void simple() {
35 Assert.assertEquals(0, Flowable.empty().count().blockingGet().intValue());
36
37 Assert.assertEquals(1, Flowable.just(1).count().blockingGet().intValue());
38
39 Assert.assertEquals(10, Flowable.range(1, 10).count().blockingGet().intValue());
40
41 }
42
43 @Test
44 public void dispose() {
45 TestHelper.checkDisposed(Flowable.just(1).count());
46
47 TestHelper.checkDisposed(Flowable.just(1).count().toFlowable());
48 }
49
50 @Test
51 public void doubleOnSubscribe() {
52 TestHelper.checkDoubleOnSubscribeFlowable(new Function<Flowable<Object>, Flowable<Long>>() {
53 @Override
54 public Flowable<Long> apply(Flowable<Object> f) throws Exception {
55 return f.count().toFlowable();
56 }
57 });
58
59 TestHelper.checkDoubleOnSubscribeFlowableToSingle(new Function<Flowable<Object>, SingleSource<Long>>() {
60 @Override
61 public SingleSource<Long> apply(Flowable<Object> f) throws Exception {
62 return f.count();
63 }
64 });
65 }
66
67 }