1 18 package net.sf.uitags.util; 19 20 import junit.framework.TestCase; 21 22 28 public class ValueLabelPairTest extends TestCase { 29 30 33 private ValueLabelPair pair; 34 35 40 public static void main(String [] args) { 41 junit.textui.TestRunner.run(ValueLabelPairTest.class); 42 } 43 44 45 protected void setUp() throws Exception { 46 super.setUp(); 47 this.pair = new ValueLabelPair("value1", "label1"); 48 } 49 50 51 protected void tearDown() throws Exception { 52 super.tearDown(); 53 this.pair = null; 54 } 55 56 59 public void testGetStrings() { 60 assertEquals("value1", this.pair.getValueAsString()); 61 assertEquals("label1", this.pair.getLabelAsString()); 62 assertEquals(this.pair.getValueAsString(), this.pair.getKey()); 63 assertEquals(this.pair.getLabelAsString(), this.pair.getValue()); 64 } 65 66 70 public void testEquals() { 71 ValueLabelPair pair1 = new ValueLabelPair("value1", "label2"); 73 ValueLabelPair pair2 = new ValueLabelPair("value2", "label1"); 75 ValueLabelPair pair3 = new ValueLabelPair("value1", "label1"); 77 ValueLabelPair pair4 = new ValueLabelPair("value2", "label2"); 79 80 assertTrue(this.pair.equals(pair1)); 84 assertTrue(!this.pair.equals(pair2)); 85 assertTrue(this.pair.equals(pair3)); 86 assertTrue(!this.pair.equals(pair4)); 87 } 88 89 93 public void testHashCode() { 94 ValueLabelPair tempPair = new ValueLabelPair("value1", "label1"); 98 99 assertEquals(this.pair.hashCode(), tempPair.hashCode()); 100 } 101 } 102 | Popular Tags |