Skip to content

Commit

Permalink
Add test to verify correct backpressure behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
twz123 committed Dec 9, 2016
1 parent 16bcf20 commit 2071573
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/java/rx/observables/StringObservableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ public void testSplitOnStreamThatThrowsExceptionImmediately() {
}
}

@Test
public void testSplitWithBackpressure() {
Observable<String> underTest = StringObservable.split(Observable.just("a", "b", "c", ":", "d"), ":");

// request just the first event
TestSubscriber<String> subscriber = TestSubscriber.create(1);
underTest.subscribe(subscriber);
subscriber.assertNoTerminalEvent(); // we expect one more event
subscriber.assertNoErrors();
subscriber.assertValue("abc");

// request the next (and last) event
subscriber.requestMore(1);
subscriber.assertTerminalEvent();
subscriber.assertNoErrors();
subscriber.assertValues("abc", "d");
}

public void testSplit(String str, String regex, int limit, String... parts) {
testSplit(str, regex, 0, Observable.just(str), parts);
for (int i = 0; i < str.length(); i++) {
Expand Down

0 comments on commit 2071573

Please sign in to comment.