@MapFeature.Require(SUPPORTS_PUT)
 public void testPutNotPresentKeyPropagatesToEntries() {
   Collection<Entry<K, V>> entries = multimap().entries();
   assertFalse(entries.contains(Helpers.mapEntry(sampleKeys().e3, sampleValues().e3)));
   multimap().put(sampleKeys().e3, sampleValues().e3);
   assertThat(entries).has().allOf(Helpers.mapEntry(sampleKeys().e3, sampleValues().e3));
 }
 @CollectionSize.Require(absent = ZERO)
 @MapFeature.Require(SUPPORTS_REMOVE)
 public void testRemovePropagatesToMultimap() {
   assertTrue(multimap().entries().remove(Helpers.mapEntry(sampleKeys().e0, sampleValues().e0)));
   expectMissing(Helpers.mapEntry(sampleKeys().e0, sampleValues().e0));
   assertEquals(getNumElements() - 1, multimap().size());
   assertFalse(multimap().containsEntry(sampleKeys().e0, sampleValues().e0));
 }
예제 #3
0
 @Override
 public SampleElements<Entry<AnEnum, String>> samples() {
   return new SampleElements<Entry<AnEnum, String>>(
       Helpers.mapEntry(AnEnum.A, "January"),
       Helpers.mapEntry(AnEnum.B, "February"),
       Helpers.mapEntry(AnEnum.C, "March"),
       Helpers.mapEntry(AnEnum.D, "April"),
       Helpers.mapEntry(AnEnum.E, "May"));
 }
예제 #4
0
 @Override
 public SampleElements<Entry<Country, Currency>> samples() {
   return new SampleElements<Entry<Country, Currency>>(
       Helpers.mapEntry(Country.CANADA, Currency.DOLLAR),
       Helpers.mapEntry(Country.CHILE, Currency.PESO),
       Helpers.mapEntry(Country.UK, Currency.POUND),
       Helpers.mapEntry(Country.JAPAN, Currency.YEN),
       Helpers.mapEntry(Country.SWITZERLAND, Currency.FRANC));
 }
예제 #5
0
 @Override
 public SampleElements<Map.Entry<String, String>> samples() {
   return new SampleElements<Map.Entry<String, String>>(
       Helpers.mapEntry("one", "January"),
       Helpers.mapEntry("two", "February"),
       Helpers.mapEntry("three", "March"),
       Helpers.mapEntry("four", "April"),
       Helpers.mapEntry("five", "May"));
 }
예제 #6
0
 public static <K, V> SampleElements<Map.Entry<K, V>> mapEntries(
     SampleElements<K> keys, SampleElements<V> values) {
   return new SampleElements<Map.Entry<K, V>>(
       Helpers.mapEntry(keys.e0, values.e0),
       Helpers.mapEntry(keys.e1, values.e1),
       Helpers.mapEntry(keys.e2, values.e2),
       Helpers.mapEntry(keys.e3, values.e3),
       Helpers.mapEntry(keys.e4, values.e4));
 }
 @CollectionSize.Require(absent = ZERO)
 @MapFeature.Require(SUPPORTS_REMOVE)
 public void testRetainAllPropagatesToMultimap() {
   multimap()
       .entries()
       .retainAll(Collections.singleton(Helpers.mapEntry(sampleKeys().e0, sampleValues().e0)));
   assertEquals(
       getSubjectGenerator().create(Helpers.mapEntry(sampleKeys().e0, sampleValues().e0)),
       multimap());
   assertEquals(1, multimap().size());
   assertTrue(multimap().containsEntry(sampleKeys().e0, sampleValues().e0));
 }
 @CollectionSize.Require(absent = ZERO)
 @MapFeature.Require(ALLOWS_NULL_VALUES)
 public void testContainsEntryWithNullValuePresent() {
   initMultimapWithNullValue();
   // TODO(user): Change this back to Truth
   assertTrue(multimap().entries().contains(Helpers.mapEntry(getKeyForNullValue(), (V) null)));
 }
 @CollectionSize.Require(ONE)
 @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
 public void testIteratorRemovePropagatesToMultimap() {
   Iterator<Entry<K, V>> iterator = multimap().entries().iterator();
   assertEquals(Helpers.mapEntry(sampleKeys().e0, sampleValues().e0), iterator.next());
   iterator.remove();
   assertTrue(multimap().isEmpty());
 }
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
  public void testRemoveNullValuePresent() {
    initMultimapWithNullValue();

    assertTrue(multimap().remove(getKeyForNullValue(), null));

    expectMissing(Helpers.mapEntry(getKeyForNullValue(), (V) null));
    assertGet(getKeyForNullValue(), EMPTY);
  }
예제 #11
0
 @CollectionSize.Require(SEVERAL)
 public void testOrderingDoesntAffectEqualsComparisons() {
   SetMultimap<K, V> multimap1 =
       getSubjectGenerator()
           .create(
               Helpers.mapEntry(k0(), v0()),
               Helpers.mapEntry(k0(), v1()),
               Helpers.mapEntry(k0(), v4()));
   SetMultimap<K, V> multimap2 =
       getSubjectGenerator()
           .create(
               Helpers.mapEntry(k0(), v1()),
               Helpers.mapEntry(k0(), v0()),
               Helpers.mapEntry(k0(), v4()));
   new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
 }
 // This one-liner saves us from some ugly casts
 protected Entry<K, V> entry(K key, V value) {
   return Helpers.mapEntry(key, value);
 }
 @MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
 public void testContainsEntryWithNullValueAbsent() {
   assertFalse(multimap().entries().contains(Helpers.mapEntry(sampleKeys().e0, null)));
 }
 @MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
 public void testContainsEntryWithNullKeyAbsent() {
   assertFalse(multimap().entries().contains(Helpers.mapEntry(null, sampleValues().e0)));
 }