-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathArrayRangesTest.java
41 lines (31 loc) · 1.02 KB
/
ArrayRangesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package by.andd3dfx.common;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class ArrayRangesTest {
private ArrayRanges ranges;
@Before
public void setup() {
ranges = new ArrayRanges();
}
@Test
public void compactWhenOneNumber() {
assertThat(ranges.compact(new int[]{1})).isEqualTo("1");
}
@Test
public void compactWhenNoIntervals() {
assertThat(ranges.compact(new int[]{1, 4})).isEqualTo("1,4");
}
@Test
public void compactForOneInterval() {
assertThat(ranges.compact(new int[]{1, 4, 3, 2})).isEqualTo("1-4");
}
@Test
public void compactForIntervals() {
assertThat(ranges.compact(new int[]{1, 4, 5, 2, 3, 9, 8, 11, 0})).isEqualTo("0-5,8-9,11");
}
@Test
public void compactForIntervalsWithDuplicates() {
assertThat(ranges.compact(new int[]{1, 4, 5, 2, 3, 9, 5, 8, 2, 11, 0})).isEqualTo("0-5,8-9,11");
}
}