Skip to content

Commit f7f47de

Browse files
Merge pull request #165 from mairbek/range-fix
Fixed bug in ranges
2 parents bf52f3d + d624e96 commit f7f47de

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

rxjava-core/src/main/java/rx/util/Range.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class Range implements Iterable<Integer> {
2727
private final int step;
2828

2929
public static Range createWithCount(int start, int count) {
30-
return create(start, start * (count + 1));
30+
return create(start, start + count);
3131
}
3232

3333
public static Range create(int start, int end) {
@@ -94,6 +94,21 @@ public void testRangeWithCount() {
9494
assertEquals(Arrays.asList(1, 2, 3, 4, 5), toList(Range.createWithCount(1, 5)));
9595
}
9696

97+
@Test
98+
public void testRangeWithCount2() {
99+
assertEquals(Arrays.asList(2, 3, 4, 5), toList(Range.createWithCount(2, 4)));
100+
}
101+
102+
@Test
103+
public void testRangeWithCount3() {
104+
assertEquals(Arrays.asList(0, 1, 2, 3), toList(Range.createWithCount(0, 4)));
105+
}
106+
107+
@Test
108+
public void testRangeWithCount4() {
109+
assertEquals(Arrays.asList(10, 11, 12, 13, 14), toList(Range.createWithCount(10, 5)));
110+
}
111+
97112

98113
private static <T> List<T> toList(Iterable<T> iterable) {
99114
List<T> result = new ArrayList<T>();

0 commit comments

Comments
 (0)