package humaneval.buggy;

/* Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
    add([4, 2, 6, 7]) ==> 2 */

public class ADD_EVEN_AT_ODD {
    public static int add_even_at_odd(int[] lst) {
        int sum = 0;
        for (int i = 0; i < lst.length; i += 1) {
            if (lst[i] % 2 == 0)
                sum += lst[i];
        }
        return sum;
    }
}

package humaneval;

public class TEST_ADD_EVEN_AT_ODD {
    @org.junit.Test(timeout = 3000)
    public void test_0() throws java.lang.Exception {
        int result = humaneval.buggy.ADD_EVEN_AT_ODD.add_even_at_odd(new int[] {4, 88});
        org.junit.Assert.assertEquals(
            result, 88
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_1() throws java.lang.Exception {
        int result = humaneval.buggy.ADD_EVEN_AT_ODD.add_even_at_odd(new int[] {4, 5, 6, 7, 2, 122});
        org.junit.Assert.assertEquals(
            result, 122
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_2() throws java.lang.Exception {
        int result = humaneval.buggy.ADD_EVEN_AT_ODD.add_even_at_odd(new int[] {4, 0, 6, 7});
        org.junit.Assert.assertEquals(
            result, 0
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_3() throws java.lang.Exception {
        int result = humaneval.buggy.ADD_EVEN_AT_ODD.add_even_at_odd(new int[] {4, 4, 6, 8});
        org.junit.Assert.assertEquals(
            result, 12
        );
    }
}