コード例 #1
0
 @Test
 public void shouldReturnTheCorrectSize() {
   assertEquals(0, cut.size());
   cut.insert(new Point2D(.0, .0));
   assertEquals(1, cut.size());
   cut.insert(new Point2D(.1, .1));
   assertEquals(2, cut.size());
 }
コード例 #2
0
  @Test
  public void shouldGiveTheCorrectNearestPoint() {
    cut.insert(new Point2D(.0, .0));
    cut.insert(new Point2D(.0, .1));
    cut.insert(new Point2D(.0, .2));
    cut.insert(new Point2D(.0, .3));
    cut.insert(new Point2D(.0, .4));

    Point2D nearest = cut.nearest(new Point2D(.2, .2));

    assertEquals(new Point2D(.0, .2), nearest);
  }
コード例 #3
0
  @Test
  public void shouldGiveTheCorrectRange() {
    cut.insert(new Point2D(.0, .0));
    cut.insert(new Point2D(.1, .1));
    cut.insert(new Point2D(.2, .2));
    cut.insert(new Point2D(.3, .3));
    cut.insert(new Point2D(.4, .4));
    cut.insert(new Point2D(.5, .5));

    List<Point2D> range = (List<Point2D>) cut.range(new RectHV(.1, .1, .4, .4));
    assertEquals(4, range.size());
    assertTrue(range.contains(new Point2D(.1, .1)));
    assertTrue(range.contains(new Point2D(.2, .2)));
    assertTrue(range.contains(new Point2D(.3, .3)));
    assertTrue(range.contains(new Point2D(.4, .4)));
  }
コード例 #4
0
  @Test
  public void shouldCorrectlyDiscoverIfElementIsInSET() {
    cut.insert(new Point2D(.1, .1));

    assertFalse(cut.contains(new Point2D(.0, .0)));
    assertTrue(cut.contains(new Point2D(.1, .1)));
  }
コード例 #5
0
 @Test(expected = NullPointerException.class)
 public void shouldThrowNullPointerExceptionWhenInsertingNull() {
   cut.insert(null);
 }
コード例 #6
0
 @Test
 public void shouldReturnFalseIfSetIsNotEmpty() {
   cut.insert(new Point2D(.0, .0));
   assertFalse(cut.isEmpty());
 }