Home | History | Annotate | Download | only in collect
      1 /*
      2  * Copyright (C) 2009 The Guava Authors
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.google.common.collect;
     18 
     19 import com.google.common.annotations.GwtCompatible;
     20 import com.google.common.annotations.GwtIncompatible;
     21 import com.google.common.testing.EqualsTester;
     22 
     23 /**
     24  * Tests {@link EmptyImmutableTable}
     25  *
     26  * @author Gregory Kick
     27  */
     28 @GwtCompatible(emulated = true)
     29 public class EmptyImmutableTableTest extends AbstractImmutableTableTest {
     30   private static final ImmutableTable<Character, Integer, String> INSTANCE = ImmutableTable.of();
     31 
     32   @Override Iterable<ImmutableTable<Character, Integer, String>> getTestInstances() {
     33     return ImmutableSet.of(INSTANCE);
     34   }
     35 
     36   public void testHashCode() {
     37     assertEquals(0, INSTANCE.hashCode());
     38   }
     39 
     40   public void testEqualsObject() {
     41     Table<Character, Integer, String> nonEmptyTable = HashBasedTable.create();
     42     nonEmptyTable.put('A', 1, "blah");
     43 
     44     new EqualsTester()
     45         .addEqualityGroup(INSTANCE, HashBasedTable.create(), TreeBasedTable.create())
     46         .addEqualityGroup(nonEmptyTable)
     47         .testEquals();
     48   }
     49 
     50   @GwtIncompatible("ArrayTable")
     51   public void testEqualsObjectNullValues() {
     52     new EqualsTester()
     53         .addEqualityGroup(INSTANCE)
     54         .addEqualityGroup(ArrayTable.create(ImmutableSet.of('A'), ImmutableSet.of(1)))
     55         .testEquals();
     56   }
     57 
     58   public void testToString() {
     59     assertEquals("{}", INSTANCE.toString());
     60   }
     61 
     62   public void testSize() {
     63     assertEquals(0, INSTANCE.size());
     64   }
     65 
     66   public void testGet() {
     67     assertNull(INSTANCE.get('a', 1));
     68   }
     69 
     70   public void testIsEmpty() {
     71     assertTrue(INSTANCE.isEmpty());
     72   }
     73 
     74   public void testCellSet() {
     75     assertEquals(ImmutableSet.of(), INSTANCE.cellSet());
     76   }
     77 
     78   public void testColumn() {
     79     assertEquals(ImmutableMap.of(), INSTANCE.column(1));
     80   }
     81 
     82   public void testColumnKeySet() {
     83     assertEquals(ImmutableSet.of(), INSTANCE.columnKeySet());
     84   }
     85 
     86   public void testColumnMap() {
     87     assertEquals(ImmutableMap.of(), INSTANCE.columnMap());
     88   }
     89 
     90   public void testContains() {
     91     assertFalse(INSTANCE.contains('a', 1));
     92   }
     93 
     94   public void testContainsColumn() {
     95     assertFalse(INSTANCE.containsColumn(1));
     96   }
     97 
     98   public void testContainsRow() {
     99     assertFalse(INSTANCE.containsRow('a'));
    100   }
    101 
    102   public void testContainsValue() {
    103     assertFalse(INSTANCE.containsValue("blah"));
    104   }
    105 
    106   public void testRow() {
    107     assertEquals(ImmutableMap.of(), INSTANCE.row('a'));
    108   }
    109 
    110   public void testRowKeySet() {
    111     assertEquals(ImmutableSet.of(), INSTANCE.rowKeySet());
    112   }
    113 
    114   public void testRowMap() {
    115     assertEquals(ImmutableMap.of(), INSTANCE.rowMap());
    116   }
    117 
    118   public void testValues() {
    119     assertTrue(INSTANCE.values().isEmpty());
    120   }
    121 }
    122