Skip to content

Commit

Permalink
Merge pull request ReactiveX#165 from mairbek/range-fix
Browse files Browse the repository at this point in the history
Fixed bug in ranges
  • Loading branch information
benjchristensen committed Mar 1, 2013
2 parents fb913ab + 4812b94 commit 0b6d18a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion rxjava-core/src/main/java/rx/util/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class Range implements Iterable<Integer> {
private final int step;

public static Range createWithCount(int start, int count) {
return create(start, start * (count + 1));
return create(start, start + count);
}

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

@Test
public void testRangeWithCount2() {
assertEquals(Arrays.asList(2, 3, 4, 5), toList(Range.createWithCount(2, 4)));
}

@Test
public void testRangeWithCount3() {
assertEquals(Arrays.asList(0, 1, 2, 3), toList(Range.createWithCount(0, 4)));
}

@Test
public void testRangeWithCount4() {
assertEquals(Arrays.asList(10, 11, 12, 13, 14), toList(Range.createWithCount(10, 5)));
}


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

0 comments on commit 0b6d18a

Please sign in to comment.