@Test
public void iBounds_findsMinMax() {

    FastXYSeries series = mock(FastXYSeries.class);
    when(series.size()).thenReturn(3);
    when(series.getX(0)).thenReturn(0);
    when(series.getX(1)).thenReturn(1);
    when(series.getX(2)).thenReturn(2);
    Region result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1));
    assertEquals(0, result.getMin().intValue());
    assertEquals(1, result.getMax().intValue());
    // test with nulls:
    when(series.size()).thenReturn(6);
    when(series.getX(0)).thenReturn(0);
    when(series.getX(1)).thenReturn(0.5);
    when(series.getX(2)).thenReturn(null);
    when(series.getX(3)).thenReturn(null);
    when(series.getX(4)).thenReturn(1);
    when(series.getX(5)).thenReturn(3);
    result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1));
    assertEquals(0, result.getMin().intValue());
    assertEquals(4, result.getMax().intValue());
}