Пример #1
0
  @Test(groups = "1s", expectedExceptions = SolverException.class)
  public void testNeg() {
    Solver solver = new Solver();
    IntVar[] CS = VF.enumeratedArray("CS", 4, -10, 10, solver);
    solver.post(ICF.regular(CS, new FiniteAutomaton("<-9>1*")));
    Chatterbox.showSolutions(solver);
    solver.findAllSolutions();

    final List<Solution> solutions = solver.getSolutionRecorder().getSolutions();

    System.out.println(solutions);

    Assert.assertEquals(1, solutions.size());
    Assert.assertEquals(-9, (int) solutions.get(0).getIntVal(CS[0]));
    Assert.assertEquals(1, (int) solutions.get(0).getIntVal(CS[1]));
    Assert.assertEquals(1, (int) solutions.get(0).getIntVal(CS[2]));
    Assert.assertEquals(-5, (int) solutions.get(0).getIntVal(CS[3]));
  }