• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 junit.framework.TestCase;
21 
22 /**
23  * Tests {@link ImmutableTable}
24  *
25  * @author Gregory Kick
26  */
27 @GwtCompatible
28 @ElementTypesAreNonnullByDefault
29 public abstract class AbstractImmutableTableTest extends TestCase {
30 
getTestInstances()31   abstract Iterable<ImmutableTable<Character, Integer, String>> getTestInstances();
32 
testClear()33   public final void testClear() {
34     for (Table<Character, Integer, String> testInstance : getTestInstances()) {
35       try {
36         testInstance.clear();
37         fail();
38       } catch (UnsupportedOperationException e) {
39         // success
40       }
41     }
42   }
43 
testPut()44   public final void testPut() {
45     for (Table<Character, Integer, String> testInstance : getTestInstances()) {
46       try {
47         testInstance.put('a', 1, "blah");
48         fail();
49       } catch (UnsupportedOperationException e) {
50         // success
51       }
52     }
53   }
54 
testPutAll()55   public final void testPutAll() {
56     for (Table<Character, Integer, String> testInstance : getTestInstances()) {
57       try {
58         testInstance.putAll(ImmutableTable.of('a', 1, "blah"));
59         fail();
60       } catch (UnsupportedOperationException e) {
61         // success
62       }
63     }
64   }
65 
testRemove()66   public final void testRemove() {
67     for (Table<Character, Integer, String> testInstance : getTestInstances()) {
68       try {
69         testInstance.remove('a', 1);
70         fail();
71       } catch (UnsupportedOperationException e) {
72         // success
73       }
74     }
75   }
76 
testConsistentToString()77   public final void testConsistentToString() {
78     for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
79       assertEquals(testInstance.rowMap().toString(), testInstance.toString());
80     }
81   }
82 
testConsistentHashCode()83   public final void testConsistentHashCode() {
84     for (ImmutableTable<Character, Integer, String> testInstance : getTestInstances()) {
85       assertEquals(testInstance.cellSet().hashCode(), testInstance.hashCode());
86     }
87   }
88 }
89