use of com.google.common.collect.testing.DerivedComparable in project guava by google.
the class MultisetsTest method testNewTreeMultisetDerived.
/* See MultisetsImmutableEntryTest for immutableEntry() tests. */
public void testNewTreeMultisetDerived() {
TreeMultiset<DerivedComparable> set = TreeMultiset.create();
assertTrue(set.isEmpty());
set.add(new DerivedComparable("foo"), 2);
set.add(new DerivedComparable("bar"), 3);
assertThat(set).containsExactly(new DerivedComparable("bar"), new DerivedComparable("bar"), new DerivedComparable("bar"), new DerivedComparable("foo"), new DerivedComparable("foo")).inOrder();
}
use of com.google.common.collect.testing.DerivedComparable in project guava by google.
the class TreeMultimapNaturalTest method testTreeMultimapDerived.
// SerializableTester
@GwtIncompatible
public void testTreeMultimapDerived() {
TreeMultimap<DerivedComparable, DerivedComparable> multimap = TreeMultimap.create();
assertEquals(ImmutableMultimap.of(), multimap);
multimap.put(new DerivedComparable("foo"), new DerivedComparable("f"));
multimap.put(new DerivedComparable("foo"), new DerivedComparable("o"));
multimap.put(new DerivedComparable("foo"), new DerivedComparable("o"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("b"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("a"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("r"));
assertThat(multimap.keySet()).containsExactly(new DerivedComparable("bar"), new DerivedComparable("foo")).inOrder();
assertThat(multimap.values()).containsExactly(new DerivedComparable("a"), new DerivedComparable("b"), new DerivedComparable("r"), new DerivedComparable("f"), new DerivedComparable("o")).inOrder();
assertEquals(Ordering.natural(), multimap.keyComparator());
assertEquals(Ordering.natural(), multimap.valueComparator());
SerializableTester.reserializeAndAssert(multimap);
}
use of com.google.common.collect.testing.DerivedComparable in project guava by hceylan.
the class MultisetsTest method testNewTreeMultisetDerived.
public void testNewTreeMultisetDerived() {
TreeMultiset<DerivedComparable> set = TreeMultiset.create();
assertTrue(set.isEmpty());
set.add(new DerivedComparable("foo"), 2);
set.add(new DerivedComparable("bar"), 3);
ASSERT.that(set).hasContentsInOrder(new DerivedComparable("bar"), new DerivedComparable("bar"), new DerivedComparable("bar"), new DerivedComparable("foo"), new DerivedComparable("foo"));
}
use of com.google.common.collect.testing.DerivedComparable in project guava by hceylan.
the class TreeMultimapNaturalTest method testTreeMultimapDerived.
@GwtIncompatible("SerializableTester")
public void testTreeMultimapDerived() {
TreeMultimap<DerivedComparable, DerivedComparable> multimap = TreeMultimap.create();
assertEquals(ImmutableMultimap.of(), multimap);
multimap.put(new DerivedComparable("foo"), new DerivedComparable("f"));
multimap.put(new DerivedComparable("foo"), new DerivedComparable("o"));
multimap.put(new DerivedComparable("foo"), new DerivedComparable("o"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("b"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("a"));
multimap.put(new DerivedComparable("bar"), new DerivedComparable("r"));
ASSERT.that(multimap.keySet()).hasContentsInOrder(new DerivedComparable("bar"), new DerivedComparable("foo"));
ASSERT.that(multimap.values()).hasContentsInOrder(new DerivedComparable("a"), new DerivedComparable("b"), new DerivedComparable("r"), new DerivedComparable("f"), new DerivedComparable("o"));
assertEquals(Ordering.natural(), multimap.keyComparator());
assertEquals(Ordering.natural(), multimap.valueComparator());
SerializableTester.reserializeAndAssert(multimap);
}
Aggregations