| 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.fuseable; |
| 15 |
|
| 16 |
import static org.junit.Assert.*; |
| 17 |
import org.junit.Test; |
| 18 |
|
| 19 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 20 |
|
| 21 |
public class CancellableQueueFuseableTest { |
| 22 |
|
| 23 |
@Test |
| 24 |
public void offer() { |
| 25 |
TestHelper.assertNoOffer(new CancellableQueueFuseable<>()); |
| 26 |
} |
| 27 |
|
| 28 |
@Test |
| 29 |
public void pollClear() throws Throwable { |
| 30 |
CancellableQueueFuseable<Object> qs = new CancellableQueueFuseable<>(); |
| 31 |
|
| 32 |
assertNull(qs.poll()); |
| 33 |
|
| 34 |
qs.clear(); |
| 35 |
assertNull(qs.poll()); |
| 36 |
} |
| 37 |
|
| 38 |
@Test |
| 39 |
public void cancel() { |
| 40 |
CancellableQueueFuseable<Object> qs = new CancellableQueueFuseable<>(); |
| 41 |
|
| 42 |
assertFalse(qs.isDisposed()); |
| 43 |
|
| 44 |
qs.cancel(); |
| 45 |
|
| 46 |
assertTrue(qs.isDisposed()); |
| 47 |
|
| 48 |
qs.cancel(); |
| 49 |
|
| 50 |
assertTrue(qs.isDisposed()); |
| 51 |
} |
| 52 |
|
| 53 |
@Test |
| 54 |
public void dispose() { |
| 55 |
CancellableQueueFuseable<Object> qs = new CancellableQueueFuseable<>(); |
| 56 |
|
| 57 |
assertFalse(qs.isDisposed()); |
| 58 |
|
| 59 |
qs.dispose(); |
| 60 |
|
| 61 |
assertTrue(qs.isDisposed()); |
| 62 |
|
| 63 |
qs.dispose(); |
| 64 |
|
| 65 |
assertTrue(qs.isDisposed()); |
| 66 |
} |
| 67 |
|
| 68 |
@Test |
| 69 |
public void cancel2() { |
| 70 |
AbstractEmptyQueueFuseable<Object> qs = new AbstractEmptyQueueFuseable<Object>() { }; |
| 71 |
|
| 72 |
assertFalse(qs.isDisposed()); |
| 73 |
|
| 74 |
qs.cancel(); |
| 75 |
} |
| 76 |
|
| 77 |
@Test |
| 78 |
public void dispose2() { |
| 79 |
AbstractEmptyQueueFuseable<Object> qs = new AbstractEmptyQueueFuseable<Object>() { }; |
| 80 |
|
| 81 |
assertFalse(qs.isDisposed()); |
| 82 |
|
| 83 |
qs.dispose(); |
| 84 |
} |
| 85 |
} |