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.
033public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
034  @MapFeature.Require(SUPPORTS_REMOVE)
035  public void testClearClearsInverse() {
036    BiMap<V, K> inv = getMap().inverse();
037    getMap().clear();
038    assertTrue(getMap().isEmpty());
039    assertTrue(inv.isEmpty());
040  }
041
042  @MapFeature.Require(SUPPORTS_REMOVE)
043  public void testKeySetClearClearsInverse() {
044    BiMap<V, K> inv = getMap().inverse();
045    getMap().keySet().clear();
046    assertTrue(getMap().isEmpty());
047    assertTrue(inv.isEmpty());
048  }
049
050  @MapFeature.Require(SUPPORTS_REMOVE)
051  public void testValuesClearClearsInverse() {
052    BiMap<V, K> inv = getMap().inverse();
053    getMap().values().clear();
054    assertTrue(getMap().isEmpty());
055    assertTrue(inv.isEmpty());
056  }
057
058  @MapFeature.Require(SUPPORTS_REMOVE)
059  public void testClearInverseClears() {
060    BiMap<V, K> inv = getMap().inverse();
061    inv.clear();
062    assertTrue(getMap().isEmpty());
063    assertTrue(inv.isEmpty());
064  }
065
066  @MapFeature.Require(SUPPORTS_REMOVE)
067  public void testClearInverseKeySetClears() {
068    BiMap<V, K> inv = getMap().inverse();
069    inv.keySet().clear();
070    assertTrue(getMap().isEmpty());
071    assertTrue(inv.isEmpty());
072  }
073
074  @MapFeature.Require(SUPPORTS_REMOVE)
075  public void testClearInverseValuesClears() {
076    BiMap<V, K> inv = getMap().inverse();
077    inv.values().clear();
078    assertTrue(getMap().isEmpty());
079    assertTrue(inv.isEmpty());
080  }
081}