1 /* 2 * Copyright (C) 2008 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.collect.Table.Cell; 21 import com.google.common.testing.EqualsTester; 22 23 import junit.framework.TestCase; 24 25 /** 26 * Tests for {@link Tables}. 27 * 28 * @author Jared Levy 29 */ 30 @GwtCompatible(emulated = true) 31 public class TablesTest extends TestCase { 32 33 public void testImmutableEntryToString() { 34 Cell<String, Integer, Character> entry 35 = Tables.immutableCell("foo", 1, 'a'); 36 assertEquals("(foo,1)=a", entry.toString()); 37 38 Cell<String, Integer, Character> nullEntry 39 = Tables.immutableCell(null, null, null); 40 assertEquals("(null,null)=null", nullEntry.toString()); 41 } 42 43 public void testEntryEquals() { 44 Cell<String, Integer, Character> entry 45 = Tables.immutableCell("foo", 1, 'a'); 46 47 new EqualsTester() 48 .addEqualityGroup(entry, Tables.immutableCell("foo", 1, 'a')) 49 .addEqualityGroup(Tables.immutableCell("bar", 1, 'a')) 50 .addEqualityGroup(Tables.immutableCell("foo", 2, 'a')) 51 .addEqualityGroup(Tables.immutableCell("foo", 1, 'b')) 52 .addEqualityGroup(Tables.immutableCell(null, null, null)) 53 .testEquals(); 54 } 55 56 public void testEntryEqualsNull() { 57 Cell<String, Integer, Character> entry 58 = Tables.immutableCell(null, null, null); 59 60 new EqualsTester() 61 .addEqualityGroup(entry, Tables.immutableCell(null, null, null)) 62 .addEqualityGroup(Tables.immutableCell("bar", null, null)) 63 .addEqualityGroup(Tables.immutableCell(null, 2, null)) 64 .addEqualityGroup(Tables.immutableCell(null, null, 'b')) 65 .addEqualityGroup(Tables.immutableCell("foo", 1, 'a')) 66 .testEquals(); 67 } 68 } 69 70