예제 #1
0
 @Test(expectedExceptions = NullPointerException.class)
 public void nullEntryDisallowedN() {
   Map.Entry<Integer, String>[] entries = genEntries(MAX_ENTRIES);
   entries[5] = null;
   @SuppressWarnings("unused")
   Map<Integer, String> map = Maps2.ofEntries(entries);
 }
예제 #2
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void dupKeysDisallowedN() {
   Map.Entry<Integer, String>[] entries = genEntries(MAX_ENTRIES);
   entries[MAX_ENTRIES - 1] = Maps2.entry(0, "xxx");
   @SuppressWarnings("unused")
   Map<Integer, String> map = Maps2.ofEntries(entries);
 }
예제 #3
0
 // compile-time test of wildcards
 @Test
 public void entryWildcardTests() {
   Map.Entry<Integer, Double> e1 = Maps2.entry(1, 2.0);
   Map.Entry<Float, Long> e2 = Maps2.entry(3.0f, 4L);
   @SuppressWarnings("unchecked")
   Map<Number, Number> map = Maps2.ofEntries(e1, e2);
   assertEquals(map.size(), 2);
 }
예제 #4
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Test(expectedExceptions = NullPointerException.class)
 public void nullValueDisallowedN() {
   Map.Entry<Integer, String>[] entries = genEntries(MAX_ENTRIES);
   entries[0] = new AbstractMap.SimpleImmutableEntry(0, null);
   @SuppressWarnings("unused")
   Map<Integer, String> map = Maps2.ofEntries(entries);
 }
예제 #5
0
 @DataProvider(name = "nonempty")
 public Iterator<Object[]> nonempty() {
   return Arrays.asList(
           a(Maps2.of(0, "a"), genMap(1)),
           a(Maps2.of(0, "a", 1, "b"), genMap(2)),
           a(Maps2.of(0, "a", 1, "b", 2, "c"), genMap(3)),
           a(Maps2.of(0, "a", 1, "b", 2, "c", 3, "d"), genMap(4)),
           a(Maps2.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e"), genMap(5)),
           a(Maps2.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"), genMap(6)),
           a(Maps2.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g"), genMap(7)),
           a(Maps2.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h"), genMap(8)),
           a(
               Maps2.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i"),
               genMap(9)),
           a(
               Maps2.of(
                   0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"),
               genMap(10)),
           a(Maps2.ofEntries(genEntries(MAX_ENTRIES)), genMap(MAX_ENTRIES)))
       .iterator();
 }
예제 #6
0
 @Test(expectedExceptions = NullPointerException.class)
 public void nullArrayDisallowed() {
   Maps2.ofEntries((Map.Entry<Object, Object>[]) null);
 }