1/*
2 * Copyright (C) 2009 Google Inc.
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
17package com.google.common.collect;
18
19import com.google.common.testing.EqualsTester;
20
21/**
22 * Tests {@link EmptyImmutableTable}
23 *
24 * @author gak@google.com (Gregory Kick)
25 */
26public class EmptyImmutableTableTest extends AbstractImmutableTableTest {
27  private static final ImmutableTable<Character, Integer, String> INSTANCE =
28      ImmutableTable.of();
29
30  @Override Iterable<ImmutableTable<Character, Integer, String>>
31      getTestInstances() {
32    return ImmutableSet.of(INSTANCE);
33  }
34
35  public void testHashCode() {
36    assertEquals(0, INSTANCE.hashCode());
37  }
38
39  public void testEqualsObject() {
40    new EqualsTester()
41        .addEqualityGroup(INSTANCE, HashBasedTable.create(),
42            TreeBasedTable.create())
43        .addEqualityGroup(ArrayTable.create(ImmutableSet.of("A"),
44            ImmutableSet.of(1)))
45        .testEquals();
46  }
47
48  public void testToString() {
49    assertEquals("{}", INSTANCE.toString());
50  }
51
52  public void testSize() {
53    assertEquals(0, INSTANCE.size());
54  }
55
56  public void testGet() {
57    assertNull(INSTANCE.get('a', 1));
58  }
59
60  public void testIsEmpty() {
61    assertTrue(INSTANCE.isEmpty());
62  }
63
64  public void testCellSet() {
65    assertEquals(ImmutableSet.of(), INSTANCE.cellSet());
66  }
67
68  public void testColumn() {
69    assertEquals(ImmutableMap.of(), INSTANCE.column(1));
70  }
71
72  public void testColumnKeySet() {
73    assertEquals(ImmutableSet.of(), INSTANCE.columnKeySet());
74  }
75
76  public void testColumnMap() {
77    assertEquals(ImmutableMap.of(), INSTANCE.columnMap());
78  }
79
80  public void testContains() {
81    assertFalse(INSTANCE.contains('a', 1));
82  }
83
84  public void testContainsColumn() {
85    assertFalse(INSTANCE.containsColumn(1));
86  }
87
88  public void testContainsRow() {
89    assertFalse(INSTANCE.containsRow('a'));
90  }
91
92  public void testContainsValue() {
93    assertFalse(INSTANCE.containsValue("blah"));
94  }
95
96  public void testRow() {
97    assertEquals(ImmutableMap.of(), INSTANCE.row('a'));
98  }
99
100  public void testRowKeySet() {
101    assertEquals(ImmutableSet.of(), INSTANCE.rowKeySet());
102  }
103
104  public void testRowMap() {
105    assertEquals(ImmutableMap.of(), INSTANCE.rowMap());
106  }
107
108  public void testValues() {
109    assertTrue(INSTANCE.values().isEmpty());
110  }
111
112  public void testReadResolve() {
113    assertSame(EmptyImmutableTable.INSTANCE,
114        EmptyImmutableTable.INSTANCE.readResolve());
115  }
116
117}
118