예제 #1
0
  @Test
  public void test_constructors() {
    Straight s1 = new Straight(new Vector(0, 0), new Vector(3, 3));
    Straight s2 = new Straight(new Point(0, 0), new Point(3, 3));
    assertTrue(s1.equals(s2));

    s1 = new Straight(new Vector(1, 2), new Vector(3, 4));
    s2 = new Straight(new Point(1, 2), new Point(3, 4));
    assertFalse(s1.equals(s2));
  }
예제 #2
0
  @Test
  public void test_equals() {
    Straight s1 = new Straight(new Vector(0, 0), new Vector(3, 3));
    Straight s2 = new Straight(new Vector(4, 4), new Vector(2, 2));
    assertTrue(s1.equals(s2));
    assertTrue(s2.equals(s1));
    assertFalse(s1.equals(new Straight(new Vector(2, 0), s1.direction)));

    // wrong type
    assertFalse(s1.equals(new Point()));
  }