001/*
002 * Copyright (C) 2012 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.collect.testing.google;
018
019import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
020
021import com.google.common.annotations.GwtCompatible;
022import com.google.common.collect.BiMap;
023import com.google.common.collect.testing.features.MapFeature;
024import org.junit.Ignore;
025
026/**
027 * Tester for {@code BiMap.clear}.
028 *
029 * @author Louis Wasserman
030 */
031@GwtCompatible
032@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
033@SuppressWarnings("JUnit4ClassUsedInJUnit3")
034public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
035  @MapFeature.Require(SUPPORTS_REMOVE)
036  public void testClearClearsInverse() {
037    BiMap<V, K> inv = getMap().inverse();
038    getMap().clear();
039    assertTrue(getMap().isEmpty());
040    assertTrue(inv.isEmpty());
041  }
042
043  @MapFeature.Require(SUPPORTS_REMOVE)
044  public void testKeySetClearClearsInverse() {
045    BiMap<V, K> inv = getMap().inverse();
046    getMap().keySet().clear();
047    assertTrue(getMap().isEmpty());
048    assertTrue(inv.isEmpty());
049  }
050
051  @MapFeature.Require(SUPPORTS_REMOVE)
052  public void testValuesClearClearsInverse() {
053    BiMap<V, K> inv = getMap().inverse();
054    getMap().values().clear();
055    assertTrue(getMap().isEmpty());
056    assertTrue(inv.isEmpty());
057  }
058
059  @MapFeature.Require(SUPPORTS_REMOVE)
060  public void testClearInverseClears() {
061    BiMap<V, K> inv = getMap().inverse();
062    inv.clear();
063    assertTrue(getMap().isEmpty());
064    assertTrue(inv.isEmpty());
065  }
066
067  @MapFeature.Require(SUPPORTS_REMOVE)
068  public void testClearInverseKeySetClears() {
069    BiMap<V, K> inv = getMap().inverse();
070    inv.keySet().clear();
071    assertTrue(getMap().isEmpty());
072    assertTrue(inv.isEmpty());
073  }
074
075  @MapFeature.Require(SUPPORTS_REMOVE)
076  public void testClearInverseValuesClears() {
077    BiMap<V, K> inv = getMap().inverse();
078    inv.values().clear();
079    assertTrue(getMap().isEmpty());
080    assertTrue(inv.isEmpty());
081  }
082}