Skip to content

Commit

Permalink
Merge pull request #1527 from mattrjacobs/reduce-fails-on-backpressure
Browse files Browse the repository at this point in the history
Failing unit test for reduce, showing it does not implement backpressure correctly
  • Loading branch information
benjchristensen committed Jul 29, 2014
2 parents 27a56dc + 46290b8 commit d403f69
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package rx.internal.operators;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -114,4 +115,24 @@ public Integer call(Integer t1) {
verify(observer, times(1)).onError(any(TestException.class));
}

@Test
public void testBackpressureWithNoInitialValue() throws InterruptedException {
Observable<Integer> source = Observable.from(1, 2, 3, 4, 5, 6);
Observable<Integer> reduced = source.reduce(sum);

Integer r = reduced.toBlocking().first();
assertEquals(21, r.intValue());
}

@Test
public void testBackpressureWithInitialValue() throws InterruptedException {
Observable<Integer> source = Observable.from(1, 2, 3, 4, 5, 6);
Observable<Integer> reduced = source.reduce(0, sum);

Integer r = reduced.toBlocking().first();
assertEquals(21, r.intValue());
}



}

0 comments on commit d403f69

Please sign in to comment.