| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import org.junit.Ignore;
- import org.junit.Test;
-
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.List;
-
- import static org.junit.Assert.assertEquals;
-
- public class ListOpsTest {
-
- @Test
- public void testAppendingEmptyLists() {
- assertEquals(
- Collections.emptyList(),
- ListOps.append(Collections.emptyList(), Collections.emptyList()));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testAppendingNonEmptyListOnEmptyList() {
- assertEquals(
- Arrays.asList('1', '2', '3', '4'),
- ListOps.append(Collections.emptyList(), Arrays.asList('1', '2', '3', '4')));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testAppendingNonEmptyListOnNonEmptyList() {
- assertEquals(
- Arrays.asList("1", "2", "2", "3", "4", "5"),
- ListOps.append(Arrays.asList("1", "2"), Arrays.asList("2", "3", "4", "5")));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testConcatOnEmptyListOfLists() {
- assertEquals(
- Collections.emptyList(),
- ListOps.concat(Collections.emptyList()));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testConcatOnNonEmptyListOfLists() {
- List<List<Character>> listOfLists = Arrays.asList(
- Arrays.asList('1', '2'),
- Collections.singletonList('3'),
- Collections.emptyList(),
- Arrays.asList('4', '5', '6'));
-
- assertEquals(
- Arrays.asList('1', '2', '3', '4', '5', '6'),
- ListOps.concat(listOfLists));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFilteringEmptyList() {
- assertEquals(
- Collections.emptyList(),
- ListOps.filter(Collections.<Integer>emptyList(), integer -> integer % 2 == 1));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFilteringNonEmptyList() {
- assertEquals(
- Arrays.asList(1, 3, 5),
- ListOps.filter(Arrays.asList(1, 2, 3, 5), integer -> integer % 2 == 1));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testSizeOfEmptyList() {
- assertEquals(0, ListOps.size(Collections.emptyList()));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testSizeOfNonEmptyList() {
- assertEquals(4, ListOps.size(Arrays.asList("one", "two", "three", "four")));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testTransformingEmptyList() {
- assertEquals(
- Collections.emptyList(),
- ListOps.map(Collections.<Integer>emptyList(), integer -> integer + 1 ));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testTransformingNonEmptyList() {
- assertEquals(
- Arrays.asList(2, 4, 6, 8),
- ListOps.map(Arrays.asList(1, 3, 5, 7), integer -> integer + 1 ));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldLeftOnEmptyList() {
- assertEquals(
- new Double(2.0), // Boxing required for method overload disambiguation.
- ListOps.foldLeft(
- Collections.<Double>emptyList(),
- 2.0,
- (x, y) -> x * y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldLeftWithDirectionIndependentOperationOnNonEmptyList() {
- assertEquals(
- new Integer(15), // Boxing required for method overload disambiguation.
- ListOps.foldLeft(
- Arrays.asList(1, 2, 3, 4),
- 5,
- (x, y) -> x + y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldLeftWithDirectionDependentOperationOnNonEmptyList() {
- assertEquals(
- new Integer(0), // Boxing required for method overload disambiguation.
- ListOps.foldLeft(
- Arrays.asList(2, 5),
- 5,
- (x, y) -> x / y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldRightOnEmptyList() {
- assertEquals(
- new Double(2.0), // Boxing required for method overload disambiguation.
- ListOps.foldRight(
- Collections.<Double>emptyList(),
- 2.0,
- (x, y) -> x * y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldRightWithDirectionIndependentOperationOnNonEmptyList() {
- assertEquals(
- new Integer(15), // Boxing required for method overload disambiguation.
- ListOps.foldRight(
- Arrays.asList(1, 2, 3, 4),
- 5,
- (x, y) -> x + y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testFoldRightWithDirectionDependentOperationOnNonEmptyList() {
- assertEquals(
- new Integer(2), // Boxing required for method overload disambiguation.
- ListOps.foldRight(
- Arrays.asList(2, 5),
- 5,
- (x, y) -> x / y));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testReversingEmptyList() {
- assertEquals(
- Collections.emptyList(),
- ListOps.reverse(Collections.emptyList()));
- }
-
- @Ignore("Remove to run test")
- @Test
- public void testReversingNonEmptyList() {
- assertEquals(
- Arrays.asList('7', '5', '3', '1'),
- ListOps.reverse(Arrays.asList('1', '3', '5', '7')));
- }
-
- }
|