package jsettlers.algorithms.datastructures;

import org.junit.Test;

import static org.junit.Assert.*;

public class BooleanMovingAverageTest {


    @Test
    public void insertValue() {
    }

    @Test
    public void testGetAverageDefaultFalse() {
        BooleanMovingAverage booleanMovingAverage = new BooleanMovingAverage(3, false);

        float average = booleanMovingAverage.getAverage();

        assertEquals("All values should be false", 0.0, average, 0.0);
    }

    @Test
    public void testGetAverageDefaultTrue() {
        BooleanMovingAverage booleanMovingAverage = new BooleanMovingAverage(3, true);

        float average = booleanMovingAverage.getAverage();

        assertEquals("All values should be true", 1.0, average, 0.0);
    }

    @Test
    public void testInsertValue() {
        BooleanMovingAverage booleanMovingAverage = new BooleanMovingAverage(3, false);

        booleanMovingAverage.insertValue(true);
        float average = booleanMovingAverage.getAverage();

        assertEquals("One out of three values should be true", 1f/3, average, 0.0);
    }

    @Test
    public void testInsertValueDoesNotOverflow() {
        BooleanMovingAverage booleanMovingAverage = new BooleanMovingAverage(3, false);

        booleanMovingAverage.insertValue(true);
        booleanMovingAverage.insertValue(true);
        booleanMovingAverage.insertValue(true);

        booleanMovingAverage.insertValue(false);

        float average = booleanMovingAverage.getAverage();

        assertEquals("One out of three values should be false", 2f/3, average, 0.0);
    }

}

@@ -98,9 +98,20 @@
 ert.
-*
+assertEquals
 ;%0A%0Ap
@@ -154,58 +154,8 @@
  %7B%0A%0A
-%0A    @Test%0A    public void insertValue() %7B%0A    %7D%0A%0A
     
@@ -1545,11 +1545,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Remove empty test case