Ignore:
Timestamp:
2020-02-23T00:29:53+01:00 (4 years ago)
Author:
simon04
Message:

see #18749 - Use efficient/unmodifiable collections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r15864 r15909  
    55import static org.junit.Assert.assertFalse;
    66import static org.junit.Assert.assertNull;
     7import static org.junit.Assert.assertSame;
    78import static org.junit.Assert.assertTrue;
    89
     
    1011import java.io.File;
    1112import java.io.IOException;
     13import java.util.ArrayList;
    1214import java.util.Arrays;
    1315import java.util.Collections;
     16import java.util.LinkedList;
    1417import java.util.List;
    1518import java.util.Locale;
     
    557560        assertTrue(Utils.hasExtension(new File("JOSM.txt"), "jpg", "txt"));
    558561    }
     562
     563    /**
     564     * Test of {@link Utils#toUnmodifiableList}
     565     */
     566    @Test
     567    public void testToUnmodifiableList() {
     568        assertSame(Collections.emptyList(), Utils.toUnmodifiableList(null));
     569        assertSame(Collections.emptyList(), Utils.toUnmodifiableList(Collections.emptyList()));
     570        assertSame(Collections.emptyList(), Utils.toUnmodifiableList(new ArrayList<>()));
     571        assertEquals(Collections.singletonList("foo"), Utils.toUnmodifiableList(new ArrayList<>(Collections.singletonList("foo"))));
     572        assertEquals(Arrays.asList("foo", "bar", "baz"), Utils.toUnmodifiableList(Arrays.asList("foo", "bar", "baz")));
     573        assertEquals(Arrays.asList("foo", "bar", "baz"), Utils.toUnmodifiableList(new ArrayList<>(Arrays.asList("foo", "bar", "baz"))));
     574        assertEquals(Arrays.asList("foo", "bar", "baz"), Utils.toUnmodifiableList(new LinkedList<>(Arrays.asList("foo", "bar", "baz"))));
     575    }
    559576}
Note: See TracChangeset for help on using the changeset viewer.