Esempio n. 1
0
  /** Confirm that the equals method can distinguish all the required fields. */
  public void testEquals() {

    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));

    // private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    // private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    // private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    // private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));
  }
Esempio n. 2
0
 /** Confirm that cloning works. */
 @Test
 public void testCloning() throws CloneNotSupportedException {
   NumberAxis a1 = new NumberAxis("Test");
   NumberAxis a2 = (NumberAxis) a1.clone();
   assertTrue(a1 != a2);
   assertTrue(a1.getClass() == a2.getClass());
   assertTrue(a1.equals(a2));
 }
Esempio n. 3
0
 /** Two objects that are equal are required to return the same hashCode. */
 @Test
 public void testHashCode() {
   NumberAxis a1 = new NumberAxis("Test");
   NumberAxis a2 = new NumberAxis("Test");
   assertTrue(a1.equals(a2));
   int h1 = a1.hashCode();
   int h2 = a2.hashCode();
   assertEquals(h1, h2);
 }
Esempio n. 4
0
 /** Confirm that cloning works. */
 public void testCloning() {
   NumberAxis a1 = new NumberAxis("Test");
   NumberAxis a2 = null;
   try {
     a2 = (NumberAxis) a1.clone();
   } catch (CloneNotSupportedException e) {
     System.err.println("NumberAxisTests.testCloning: failed to clone.");
   }
   assertTrue(a1 != a2);
   assertTrue(a1.getClass() == a2.getClass());
   assertTrue(a1.equals(a2));
 }