1 42 43 package org.jfree.chart.axis.junit; 44 45 import junit.framework.Test; 46 import junit.framework.TestCase; 47 import junit.framework.TestSuite; 48 49 import org.jfree.chart.axis.AxisSpace; 50 51 54 public class AxisSpaceTests extends TestCase { 55 56 61 public static Test suite() { 62 return new TestSuite(AxisSpaceTests.class); 63 } 64 65 70 public AxisSpaceTests(String name) { 71 super(name); 72 } 73 74 77 public void testEquals() { 78 AxisSpace a1 = new AxisSpace(); 79 AxisSpace a2 = new AxisSpace(); 80 assertEquals(a1, a2); 81 82 a1.setTop(1.11); 83 assertFalse(a1.equals(a2)); 84 a2.setTop(1.11); 85 assertTrue(a1.equals(a2)); 86 87 a1.setBottom(2.22); 88 assertFalse(a1.equals(a2)); 89 a2.setBottom(2.22); 90 assertTrue(a1.equals(a2)); 91 92 a1.setLeft(3.33); 93 assertFalse(a1.equals(a2)); 94 a2.setLeft(3.33); 95 assertTrue(a1.equals(a2)); 96 97 a1.setRight(4.44); 98 assertFalse(a1.equals(a2)); 99 a2.setRight(4.44); 100 assertTrue(a1.equals(a2)); 101 } 102 103 106 public void testHashCode() { 107 AxisSpace s1 = new AxisSpace(); 108 AxisSpace s2 = new AxisSpace(); 109 assertTrue(s1.equals(s2)); 110 int h1 = s1.hashCode(); 111 int h2 = s2.hashCode(); 112 assertEquals(h1, h2); 113 } 114 115 118 public void testCloning() { 119 AxisSpace s1 = new AxisSpace(); 120 AxisSpace s2 = null; 121 try { 122 s2 = (AxisSpace) s1.clone(); 123 } 124 catch (CloneNotSupportedException e) { 125 System.err.println("Failed to clone."); 126 } 127 assertTrue(s1 != s2); 128 assertTrue(s1.getClass() == s2.getClass()); 129 assertTrue(s1.equals(s2)); 130 } 131 132 } 133 134 | Popular Tags |