@@ -27,7 +27,7 @@ public final class Range implements Iterable<Integer> {
27
27
private final int step ;
28
28
29
29
public static Range createWithCount (int start , int count ) {
30
- return create (start , start * ( count + 1 ) );
30
+ return create (start , start + count );
31
31
}
32
32
33
33
public static Range create (int start , int end ) {
@@ -94,6 +94,21 @@ public void testRangeWithCount() {
94
94
assertEquals (Arrays .asList (1 , 2 , 3 , 4 , 5 ), toList (Range .createWithCount (1 , 5 )));
95
95
}
96
96
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
+
97
112
98
113
private static <T > List <T > toList (Iterable <T > iterable ) {
99
114
List <T > result = new ArrayList <T >();
0 commit comments