Skip to content

Commit 46290b8

Browse files
committed
Added another unit test to OperatorReduce/backpressure
1 parent 98778aa commit 46290b8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,24 @@ public Integer call(Integer t1) {
115115
verify(observer, times(1)).onError(any(TestException.class));
116116
}
117117

118-
@Test(timeout = 13000)
119-
public void testBackpressure() throws InterruptedException {
118+
@Test
119+
public void testBackpressureWithNoInitialValue() throws InterruptedException {
120120
Observable<Integer> source = Observable.from(1, 2, 3, 4, 5, 6);
121-
Observable<Integer> reduced = source.reduce(new Func2<Integer, Integer, Integer>() {
122-
@Override
123-
public Integer call(Integer i1, Integer i2) {
124-
return i1 + i2;
125-
}
126-
});
121+
Observable<Integer> reduced = source.reduce(sum);
122+
123+
Integer r = reduced.toBlocking().first();
124+
assertEquals(21, r.intValue());
125+
}
126+
127+
@Test
128+
public void testBackpressureWithInitialValue() throws InterruptedException {
129+
Observable<Integer> source = Observable.from(1, 2, 3, 4, 5, 6);
130+
Observable<Integer> reduced = source.reduce(0, sum);
127131

128132
Integer r = reduced.toBlocking().first();
129133
assertEquals(21, r.intValue());
130134
}
131135

136+
137+
132138
}

0 commit comments

Comments
 (0)