aboutsummaryrefslogtreecommitdiff
path: root/test/ch/epfl/xblast/ListsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/ch/epfl/xblast/ListsTest.java')
-rw-r--r--test/ch/epfl/xblast/ListsTest.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java
new file mode 100644
index 0000000..b898399
--- /dev/null
+++ b/test/ch/epfl/xblast/ListsTest.java
@@ -0,0 +1,51 @@
1package ch.epfl.xblast;
2
3import org.junit.Test;
4
5import java.util.ArrayList;
6import java.util.Arrays;
7import java.util.List;
8import java.util.stream.Collectors;
9import java.util.stream.IntStream;
10
11import static org.junit.Assert.assertEquals;
12
13/**
14 * @author Pacien TRAN-GIRARD (261948)
15 * @author Timothée FLOURE (257420)
16 */
17public class ListsTest {
18
19 @Test(expected = IllegalArgumentException.class)
20 public void isEmptyListThrowingException() {
21 List<Integer> emptyList = new ArrayList<>();
22 Lists.mirrored(emptyList);
23 }
24
25 @Test
26 public void isListMirrored() {
27 List<Integer> sampleList = Arrays.asList(1, 2, 3, 4, 5);
28 List<Integer> expected = Arrays.asList(1, 2, 3, 4, 5, 4, 3, 2, 1);
29
30 assertEquals(expected, Lists.mirrored(sampleList));
31 }
32
33 @Test
34 public void mirroredListSizeIsCorrect() {
35 int sampleSize = 10;
36 List<Integer> sampleList = IntStream.range(0, sampleSize).boxed().collect(Collectors.toList());
37 List<Integer> mirrored = Lists.mirrored(sampleList);
38
39 assertEquals(sampleSize * 2 - 1, mirrored.size());
40 }
41
42 @Test
43 public void mirrorElementsAreEqual() {
44 List<Integer> sampleList = IntStream.range(0, 10).boxed().collect(Collectors.toList());
45 List<Integer> mirrored = Lists.mirrored(sampleList);
46
47 for (int i = 0; i < mirrored.size() / 2; ++i)
48 assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i));
49 }
50
51}