Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: improve coverage of some classes (no functional changes) #5310

Merged
merged 1 commit into from
Apr 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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