add junit for add, remove, setCount and entrySet in the UnmodifiableMultiSetTest (#95)

This commit is contained in:
dota17 2019-10-30 21:04:26 +08:00 committed by Gary Gregory
parent a6b35a4970
commit 5db17ee055
1 changed files with 34 additions and 0 deletions

View File

@ -92,6 +92,40 @@ public class UnmodifiableMultiSetTest<E> extends AbstractMultiSetTest<E> {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testAdd() {
final MultiSet<E> multiset = makeFullCollection();
final MultiSet<E> unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset);
try {
unmodifiableMultiSet.add( (E)"One",1);
fail();
} catch (final UnsupportedOperationException ex) {}
}
public void testRemove() {
final MultiSet<E> multiset = makeFullCollection();
final MultiSet<E> unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset);
try {
unmodifiableMultiSet.remove( (E)"One",1);
fail();
} catch (final UnsupportedOperationException ex) {}
}
public void testSetCount() {
final MultiSet<E> multiset = makeFullCollection();
final MultiSet<E> unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset);
try {
unmodifiableMultiSet.setCount( (E)"One",2);
fail();
} catch (final UnsupportedOperationException ex) {}
}
public void testEntrySet() {
final MultiSet<E> multiset = makeFullCollection();
final MultiSet<E> unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset);
assertSame( unmodifiableMultiSet.entrySet().size(),multiset.entrySet().size());
}
//-----------------------------------------------------------------------
@Override @Override
public String getCompatibilityVersion() { public String getCompatibilityVersion() {
return "4.1"; return "4.1";