001 package aima.test.coretest; 002 003 import aima.basic.Percept; 004 import junit.framework.TestCase; 005 006 public class PerceptTest extends TestCase { 007 008 public void testToString() { 009 Percept p = new Percept("key1", "value1"); 010 011 assertEquals("[key1==value1]", p.toString()); 012 013 p = new Percept("key1", "value1", "key2", "value2"); 014 015 assertEquals("[key1==value1, key2==value2]", p.toString()); 016 } 017 018 public void testEquals() { 019 Percept p1 = new Percept(); 020 Percept p2 = new Percept(); 021 022 assertEquals(p1, p2); 023 024 p1 = new Percept("key1", "value1"); 025 026 assertNotSame(p1, p2); 027 028 p2 = new Percept("key1", "value1"); 029 030 assertEquals(p1, p2); 031 } 032 033 public void testHashCode() { 034 Percept p = new Percept(); 035 036 assertEquals(0, p.hashCode()); 037 038 p = new Percept("key1", "value1"); 039 040 assertEquals("[key1==value1]".hashCode(), p.hashCode()); 041 } 042 }