aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-02-29 17:25:37 +0100
committerPacien TRAN-GIRARD2016-02-29 17:25:37 +0100
commit7c19be7f34b932d696d839a092f05617400589f6 (patch)
tree0b4f89ef40794b75c302fa808cd364176efc0fdf /test
parentee00d0bfbfa5ea253559038c27a23da33c528d0e (diff)
downloadxblast-7c19be7f34b932d696d839a092f05617400589f6.tar.gz
Rewrite list mirroring function and add test
Diffstat (limited to 'test')
-rw-r--r--test/ch/epfl/xblast/ListsTest.java40
1 files changed, 28 insertions, 12 deletions
diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java
index 42b317f..0a2f5f9 100644
--- a/test/ch/epfl/xblast/ListsTest.java
+++ b/test/ch/epfl/xblast/ListsTest.java
@@ -1,26 +1,42 @@
1package ch.epfl.xblast; 1package ch.epfl.xblast;
2 2
3import java.util.List;
4import java.util.Arrays;
5import static org.junit.Assert.*;
6import org.junit.Test; 3import org.junit.Test;
7 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
8/** 13/**
9* @author Pacien TRAN-GIRARD (261948) 14 * @author Pacien TRAN-GIRARD (261948)
10* @author Timothée FLOURE (257420) 15 * @author Timothée FLOURE (257420)
11*/ 16 */
12public class ListsTest { 17public class ListsTest {
13 @Test(expected=IllegalArgumentException.class) 18
19 @Test(expected = IllegalArgumentException.class)
14 public void isEmptyListThrowingException() { 20 public void isEmptyListThrowingException() {
15 List<Integer> sampleList = Arrays.asList(); 21 List<Integer> emptyList = new ArrayList<>();
16 Lists.<Integer>mirrored(sampleList); 22 Lists.mirrored(emptyList);
17 } 23 }
18 24
19 @Test 25 @Test
20 public void isListMirrored() { 26 public void isListMirrored() {
21 List<Integer> sampleList = Arrays.asList(1,2,3,4,5); 27 List<Integer> sampleList = Arrays.asList(1, 2, 3, 4, 5);
22 List<Integer> expected = Arrays.asList(1,2,3,4,5,4,3,2,1); 28 List<Integer> expected = Arrays.asList(1, 2, 3, 4, 5, 4, 3, 2, 1);
29
30 assertEquals(expected, Lists.mirrored(sampleList));
31 }
23 32
24 assertEquals(expected, Lists.<Integer>mirrored(sampleList)); 33 @Test
34 public void mirrorElementsAreEqual() {
35 List<Integer> sampleList = IntStream.range(0, 10).boxed().collect(Collectors.toList());
36 List<Integer> mirrored = Lists.mirrored(sampleList);
37
38 for (int i = 0; i < mirrored.size() / 2; ++i)
39 assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i));
25 } 40 }
41
26} 42}