From 741cb9da501b8c6e9e5fa006e5c2c9df0b4616f8 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Mar 2016 11:51:31 +0100 Subject: Add List permutation function and its test --- test/ch/epfl/xblast/ListsTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java index b898399..b18b05e 100644 --- a/test/ch/epfl/xblast/ListsTest.java +++ b/test/ch/epfl/xblast/ListsTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -48,4 +49,18 @@ public class ListsTest { assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i)); } + @Test + public void isListPermuted() { + List sampleList = Arrays.asList(1, 2, 3); + List> expected = new LinkedList<>(); + expected.add(Arrays.asList(1, 2, 3)); + expected.add(Arrays.asList(2, 1, 3)); + expected.add(Arrays.asList(2, 3, 1)); + expected.add(Arrays.asList(1, 3, 2)); + expected.add(Arrays.asList(3, 1, 2)); + expected.add(Arrays.asList(3, 2, 1)); + + assertEquals(expected, Lists.permutations(sampleList)); + } + } -- cgit v1.2.3