/** Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); }
/** Confirm that cloning works. */ public void testCloning() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = null; try { t2 = (ImageTitle) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("ImageTitleTests.testCloning: failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); }
/** Check that the equals() method distinguishes all fields. */ public void testEquals() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); assertEquals(t1, t2); }
/** Check the width and height. */ public void testWidthAndHeight() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); assertEquals(100, t1.getWidth(), EPSILON); assertEquals(100, t1.getHeight(), EPSILON); }