Exemplo n.º 1
0
  @Test
  public void testTranslate() {
    IPoint pt1 = ShapeFactory.createPoint(2., 1.);
    IPoint pt2 = ShapeFactory.createPoint(2., 1.);

    pt1.translate(Double.NaN, Double.NaN);
    assertEquals(pt1, pt2);
    pt1.translate(Double.NaN, 2.);
    assertEquals(pt1, pt2);
    pt1.translate(2., Double.NaN);
    assertEquals(pt1, pt2);
    pt1.translate(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    assertEquals(pt1, pt2);
    pt1.translate(Double.POSITIVE_INFINITY, 2.);
    assertEquals(pt1, pt2);
    pt1.translate(2., Double.POSITIVE_INFINITY);
    assertEquals(pt1, pt2);
    pt1.translate(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
    assertEquals(pt1, pt2);
    pt1.translate(Double.NEGATIVE_INFINITY, 2.);
    assertEquals(pt1, pt2);
    pt1.translate(2., Double.NEGATIVE_INFINITY);
    assertEquals(pt1, pt2);
    pt1.translate(0., 0.);
    assertEquals(pt1, pt2);
    pt1.translate(0., 10.);
    assertEquals(pt1, ShapeFactory.createPoint(2., 11.));
    pt1.translate(0., -12.);
    assertEquals(pt1, ShapeFactory.createPoint(2., -1.));
    pt1.translate(5., 0.);
    assertEquals(pt1, ShapeFactory.createPoint(7., -1.));
    pt1.translate(-4., 0.);
    assertEquals(pt1, ShapeFactory.createPoint(3., -1.));
    pt1.translate(3.12, 7.98);
    assertEquals(pt1, ShapeFactory.createPoint(6.12, 6.98));
  }