@Test
public void runningAverage() {

    RunningAverage avg = new RunningAverage(3, 1);
    Assert.assertEquals("0.0", avg.toString());
    avg.add(2);
    Assert.assertEquals("2.0", avg.toString());
    avg.add(3);
    Assert.assertEquals("2.5", avg.toString());
    avg.add(4);
    Assert.assertEquals("3.0", avg.toString());
    avg.add(5);
    // last value should have kicked out the 2 above
    Assert.assertEquals("4.0", avg.toString());
    Assert.assertEquals("4.000", avg.toString(3));
    Assert.assertEquals("4", avg.toString(0));
}