Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleEqualsTest.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.single;
15
16 import java.util.List;
17
18 import org.junit.Test;
19
20 import io.reactivex.rxjava3.core.*;
21 import io.reactivex.rxjava3.exceptions.TestException;
22 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
23 import io.reactivex.rxjava3.testsupport.TestHelper;
24
25 public class SingleEqualsTest extends RxJavaTest {
26
27 @Test
28 public void bothSucceedEqual() {
29 Single.sequenceEqual(Single.just(1), Single.just(1))
30 .test()
31 .assertResult(true);
32 }
33
34 @Test
35 public void bothSucceedNotEqual() {
36 Single.sequenceEqual(Single.just(1), Single.just(2))
37 .test()
38 .assertResult(false);
39 }
40
41 @Test
42 public void firstSucceedOtherError() {
43 Single.sequenceEqual(Single.just(1), Single.error(new TestException()))
44 .test()
45 .assertFailure(TestException.class);
46 }
47
48 @Test
49 public void firstErrorOtherSucceed() {
50 Single.sequenceEqual(Single.error(new TestException()), Single.just(1))
51 .test()
52 .assertFailure(TestException.class);
53 }
54
55 @Test
56 public void bothError() {
57 List<Throwable> errors = TestHelper.trackPluginErrors();
58 try {
59 Single.sequenceEqual(Single.error(new TestException("One")), Single.error(new TestException("Two")))
60 .to(TestHelper.<Boolean>testConsumer())
61 .assertFailureAndMessage(TestException.class, "One");
62
63 TestHelper.assertUndeliverable(errors, 0, TestException.class, "Two");
64 } finally {
65 RxJavaPlugins.reset();
66 }
67 }
68 }