summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-06-13 22:19:31 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-06-13 22:19:31 +0200
commit2b4ad89e72fdf9612854b27bc8dd818c8f062d35 (patch)
treecf323935dd3e58f43cdd4b2c19660055639948e0 /test
parenta15626ac3b86d3153e32b7b160403c9ab66b1034 (diff)
downloadJRummikub-2b4ad89e72fdf9612854b27bc8dd818c8f062d35.tar
JRummikub-2b4ad89e72fdf9612854b27bc8dd818c8f062d35.zip
Restructured fdsolver api and made first test succeed
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@423 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/ai/fdsolver/SolverTest.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/test/jrummikub/ai/fdsolver/SolverTest.java b/test/jrummikub/ai/fdsolver/SolverTest.java
index 3798423..d03dfe4 100644
--- a/test/jrummikub/ai/fdsolver/SolverTest.java
+++ b/test/jrummikub/ai/fdsolver/SolverTest.java
@@ -1,8 +1,8 @@
package jrummikub.ai.fdsolver;
import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
+import jrummikub.ai.fdsolver.constraint.LessThan;
+import jrummikub.ai.fdsolver.constraint.LessThanConst;
import org.junit.Test;
@@ -11,18 +11,20 @@ public class SolverTest {
public void test() {
Solver solver = new Solver();
- Var<Integer> x = new Var<Integer>(solver, Arrays.asList(1, 2, 3));
- Var<Integer> y = Var.range(solver, 1,13);
+ Var<Integer> x = solver.makeVar(1, 2, 3);
+ Var<Integer> y = solver.makeRangeVar(1, 13);
- Constraints.lessThan(solver, y, x);
-
- while(solver.solve()) {
- solver.push();
- Constraints.lessThan(solver, x, x.getValue());
- }
- solver.pop();
+ solver.addConstraint(new LessThan<Integer>(false, y, x));
- assertEquals(2, (int)x.getValue());
- assertEquals(1, (int)y.getValue());
+ int lastx = 0, lasty = 0;
+ while (solver.solve()) {
+ lastx = x.getValue();
+ lasty = y.getValue();
+ System.out.println("x = " + lastx + ", y = " + lasty);
+ solver.addConstraint(new LessThanConst<Integer>(false, x, x.getValue()));
+ }
+
+ assertEquals(2, lastx);
+ assertEquals(1, lasty);
}
}