package org.clafer.choco.constraint;

import org.chocosolver.solver.constraints.Constraint;
import org.chocosolver.solver.variables.IntVar;
import org.clafer.choco.constraint.ConstraintQuickTest.Check;
import org.clafer.choco.constraint.propagator.PropElementArraySupport;
import org.clafer.test.NonEmpty;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 *
 * @author jimmy
 */
@RunWith(ConstraintQuickTest.class)
public class ElementArraySupportTest {

    @Check
    public void check(int value, int[] array, int index, int offset, int support) {
        assertTrue(index + offset >= 0);
        assertTrue(index + offset < array.length);
        assertTrue(array[index + offset] == value || array[index + offset] == support);
    }

    @ArcConsistent
    @Test(timeout = 60000)
    public Constraint setup(IntVar value, @NonEmpty IntVar[] array, IntVar index, int offset, int support) {
        return new Constraint("ElementArraySupport", new PropElementArraySupport(value, array, index, offset, support));
    }
}

@@ -31,16 +31,53 @@
 raint;%0A%0A
+import org.chocosolver.solver.Model;%0A
 import o
@@ -181,61 +181,188 @@
 ort 
-org.clafer.choco.constraint.ConstraintQuickTest.Check
+static org.clafer.choco.constraint.ConstraintQuickTest.$;%0Aimport org.clafer.choco.constraint.ConstraintQuickTest.Check;%0Aimport org.clafer.choco.constraint.ConstraintQuickTest.Input
 ;%0Aim
@@ -667,16 +667,244 @@
 Test %7B%0A%0A
+    @Input(solutions = 224)%0A    public Object testElementArraySupport(Model model) %7B%0A        return $(model.intVar(%22value%22, 0, 3), model.intVarArray(%22array%22, 3, 0, 3),%0A                model.intVar(%22index%22, -1, 0), 1, 0);%0A    %7D%0A%0A
     @Che

Add a test case for test element array support constraint.