Skip to content

Commit

Permalink
2.x: improve coverage of some classes (no functional changes) (#5310)
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored Apr 22, 2017
1 parent 30a206d commit bb60e9a
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/test/java/io/reactivex/exceptions/ExceptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,26 @@ public void manualPropagate() {
}
}

@Test
public void errorNotImplementedNull1() {
OnErrorNotImplementedException ex = new OnErrorNotImplementedException(null);

assertTrue("" + ex.getCause(), ex.getCause() instanceof NullPointerException);
}

@Test
public void errorNotImplementedNull2() {
OnErrorNotImplementedException ex = new OnErrorNotImplementedException("Message", null);

assertTrue("" + ex.getCause(), ex.getCause() instanceof NullPointerException);
}

@Test
public void errorNotImplementedWithCause() {
OnErrorNotImplementedException ex = new OnErrorNotImplementedException("Message", new TestException("Forced failure"));

assertTrue("" + ex.getCause(), ex.getCause() instanceof TestException);

assertEquals("" + ex.getCause(), "Forced failure", ex.getCause().getMessage());
}
}
15 changes: 15 additions & 0 deletions src/test/java/io/reactivex/internal/functions/FunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import static org.junit.Assert.*;

import java.lang.reflect.Method;
import java.util.List;

import org.junit.Test;

import io.reactivex.TestHelper;
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.*;
import io.reactivex.internal.functions.Functions.*;
import io.reactivex.internal.util.ExceptionHelper;
import io.reactivex.plugins.RxJavaPlugins;

public class FunctionsTest {
@Test
Expand Down Expand Up @@ -245,4 +248,16 @@ public void emptyConsumerToString() {
assertEquals("EmptyConsumer", Functions.EMPTY_CONSUMER.toString());
}

@Test
public void errorConsumerEmpty() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Functions.ERROR_CONSUMER.accept(new TestException());

TestHelper.assertUndeliverable(errors, 0, TestException.class);
assertEquals(errors.toString(), 1, errors.size());
} finally {
RxJavaPlugins.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import io.reactivex.*;
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.Action;
import io.reactivex.internal.functions.Functions;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.subjects.CompletableSubject;

public class CompletablePeekTest {

Expand All @@ -43,4 +45,9 @@ public void run() throws Exception {
RxJavaPlugins.reset();
}
}

@Test
public void disposed() {
TestHelper.checkDisposed(CompletableSubject.create().doOnComplete(Functions.EMPTY_ACTION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@

import static org.junit.Assert.*;

import java.util.*;

import org.junit.Test;

import io.reactivex.TestHelper;
import io.reactivex.*;


public class SingleInternalHelperTest {

Expand All @@ -43,4 +46,21 @@ public void toObservableEnum() {
assertEquals(1, SingleInternalHelper.ToObservable.values().length);
assertNotNull(SingleInternalHelper.ToObservable.valueOf("INSTANCE"));
}

@Test
public void singleIterableToFlowableIterable() {
Iterable<? extends Flowable<Integer>> it = SingleInternalHelper.iterableToFlowable(
Collections.singletonList(Single.just(1)));

Iterator<? extends Flowable<Integer>> iter = it.iterator();

if (iter.hasNext()) {
iter.next().test().assertResult(1);
if (iter.hasNext()) {
fail("Iterator reports an additional element");
}
} else {
fail("Iterator was empty");
}
}
}
Loading

0 comments on commit bb60e9a

Please sign in to comment.