/** Simple check that hashCode is implemented. */ @Test public void testHashCode() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); }
/** Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = (IntervalCategoryItemLabelGenerator) g1.clone(); assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); }
/** Tests the equals() method. */ @Test public void testEquals() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); }