コード例 #1
0
ファイル: RectTest.java プロジェクト: paulcager/andmore
  public final void testEqualsObject_Invalid() {
    Rect r = new Rect(3, 4, 20, 30);
    assertTrue(r.isValid());

    Rect i1 = new Rect(3, 4, 0, 0);
    assertFalse(i1.isValid());
    Rect i2 = new Rect(10, 20, 0, 0);
    assertFalse(i2.isValid());

    // valid rects can't be equal to invalid rects
    assertFalse(r.equals(i1));
    assertFalse(r.equals(i2));

    // invalid rects are equal to each other whatever their content is
    assertEquals(i2, i1);
  }
コード例 #2
0
ファイル: RectTest.java プロジェクト: paulcager/andmore
  public final void testIsValid() {
    Rect r = new Rect();
    assertFalse(r.isValid());

    r = new Rect(1, 2, 3, 4);
    assertTrue(r.isValid());

    // Rectangles must have a width > 0 to be valid
    r = new Rect(1, 2, 0, 4);
    assertFalse(r.isValid());
    r = new Rect(1, 2, -5, 4);
    assertFalse(r.isValid());

    // Rectangles must have a height > 0 to be valid
    r = new Rect(1, 2, 3, 0);
    assertFalse(r.isValid());
    r = new Rect(1, 2, 3, -5);
    assertFalse(r.isValid());

    r = new Rect(1, 2, 0, 0);
    assertFalse(r.isValid());
    r = new Rect(1, 2, -20, -5);
    assertFalse(r.isValid());
  }