public void testToString() { Multiset<String> ms = TreeMultiset.create(); ms.add("a", 3); ms.add("c", 1); ms.add("b", 2); assertEquals("[a x 3, b x 2, c]", ms.toString()); }
public void testCreateWithComparator() { Multiset<String> multiset = TreeMultiset.create(Collections.reverseOrder()); multiset.add("foo", 2); multiset.add("bar"); assertEquals(3, multiset.size()); assertEquals(2, multiset.count("foo")); assertEquals("[foo x 2, bar]", multiset.toString()); }
public void testCreateFromIterable() { Multiset<String> multiset = TreeMultiset.create(Arrays.asList("foo", "bar", "foo")); assertEquals(3, multiset.size()); assertEquals(2, multiset.count("foo")); assertEquals("[bar, foo x 2]", multiset.toString()); }