diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ch/epfl/xblast/ListsTest.java | 40 |
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 @@ | |||
1 | package ch.epfl.xblast; | 1 | package ch.epfl.xblast; |
2 | 2 | ||
3 | import java.util.List; | ||
4 | import java.util.Arrays; | ||
5 | import static org.junit.Assert.*; | ||
6 | import org.junit.Test; | 3 | import org.junit.Test; |
7 | 4 | ||
5 | import java.util.ArrayList; | ||
6 | import java.util.Arrays; | ||
7 | import java.util.List; | ||
8 | import java.util.stream.Collectors; | ||
9 | import java.util.stream.IntStream; | ||
10 | |||
11 | import 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 | */ |
12 | public class ListsTest { | 17 | public 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 | } |