// Before fix this would throw an ArrayIndexOutOfBoundException @Test public void testCountOverflow() throws Exception { StatsBuffer buffer = new StatsBuffer(SIZE, PERCENTILES); setCount(buffer, Integer.MAX_VALUE); buffer.record(1); buffer.record(2); }
StatsBuffer getWithWrap() { StatsBuffer buffer = new StatsBuffer(SIZE, PERCENTILES); for (int i = SIZE * 2; i > 0; --i) { buffer.record(i); } buffer.computeStats(); return buffer; }
StatsBuffer getNoWrap() { StatsBuffer buffer = new StatsBuffer(SIZE, PERCENTILES); int max = SIZE / 2; for (int i = 0; i <= max; ++i) { buffer.record(i); } buffer.computeStats(); return buffer; }