001 package aima.test.coretest; 002 003 import junit.framework.TestCase; 004 import aima.basic.Percept; 005 import aima.basic.PerceptSequence; 006 007 /** 008 * @author Ciaran O'Reilly 009 * 010 */ 011 public class PerceptSequenceTest extends TestCase { 012 013 public void testToString() { 014 PerceptSequence ps = new PerceptSequence(); 015 ps.append(new Percept("key1", "value1")); 016 017 assertEquals("[key1==value1]", ps.toString()); 018 019 ps.append(new Percept("key1", "value1", "key2", "value2")); 020 021 assertEquals("[key1==value1], [key1==value1, key2==value2]", ps 022 .toString()); 023 } 024 025 public void testEquals() { 026 PerceptSequence ps1 = new PerceptSequence(); 027 PerceptSequence ps2 = new PerceptSequence(); 028 029 assertEquals(ps1, ps2); 030 031 ps1.append(new Percept("key1", "value1")); 032 033 assertNotSame(ps1, ps2); 034 035 ps2.append(new Percept("key1", "value1")); 036 037 assertEquals(ps1, ps2); 038 } 039 040 public void testHashCode() { 041 PerceptSequence ps = new PerceptSequence(); 042 043 assertEquals(0, ps.hashCode()); 044 045 ps.append(new Percept("key1", "value1")); 046 047 assertEquals("[key1==value1]".hashCode(), ps.hashCode()); 048 } 049 }