View Javadoc

1   package org.sat4j.pb;
2   
3   import static org.junit.Assert.fail;
4   
5   import java.math.BigInteger;
6   
7   import org.junit.Test;
8   import org.sat4j.core.Vec;
9   import org.sat4j.core.VecInt;
10  import org.sat4j.pb.tools.XplainPB;
11  import org.sat4j.specs.ContradictionException;
12  import org.sat4j.specs.IVec;
13  import org.sat4j.specs.IVecInt;
14  import org.sat4j.tools.xplain.Xplain;
15  
16  public class BugSAT66 {
17  
18      @Test(expected = IllegalStateException.class)
19      public void testMissingNewVarWithClauseInXplainPB()
20              throws ContradictionException {
21          Xplain<IPBSolver> solver = new XplainPB(SolverFactory.newDefault());
22          IVecInt clause = new VecInt();
23          clause.push(-1).push(-2);
24          solver.addClause(clause);
25          fail("Should not accept clauses if newvar has not been called!!!");
26      }
27  
28      @Test(expected = IllegalStateException.class)
29      public void testMissingNewVarWithAtLeastInXplainPB()
30              throws ContradictionException {
31          Xplain<IPBSolver> solver = new XplainPB(SolverFactory.newDefault());
32          IVecInt clause = new VecInt();
33          clause.push(-1).push(-2).push(-3);
34          solver.addAtLeast(clause, 2);
35          fail("Should not accept clauses if newvar has not been called!!!");
36      }
37  
38      @Test(expected = IllegalStateException.class)
39      public void testMissingNewVarWithAtMostInXplainPB()
40              throws ContradictionException {
41          Xplain<IPBSolver> solver = new XplainPB(SolverFactory.newDefault());
42          IVecInt clause = new VecInt();
43          clause.push(-1).push(-2).push(-3);
44          solver.addAtMost(clause, 2);
45          fail("Should not accept clauses if newvar has not been called!!!");
46      }
47  
48      @Test(expected = IllegalStateException.class)
49      public void testMissingNewVarWithExactlyInXplainPB()
50              throws ContradictionException {
51          Xplain<IPBSolver> solver = new XplainPB(SolverFactory.newDefault());
52          IVecInt clause = new VecInt();
53          clause.push(-1).push(-2).push(-3);
54          solver.addExactly(clause, 2);
55          fail("Should not accept clauses if newvar has not been called!!!");
56      }
57  
58      @Test(expected = IllegalStateException.class)
59      public void testMissingNewVarWithPBInXplainPB()
60              throws ContradictionException {
61          XplainPB solver = new XplainPB(SolverFactory.newDefault());
62          IVecInt clause = new VecInt();
63          clause.push(-1).push(-2).push(-3);
64          IVec<BigInteger> coeffs = new Vec<BigInteger>();
65          coeffs.push(BigInteger.valueOf(5));
66          coeffs.push(BigInteger.valueOf(15));
67          coeffs.push(BigInteger.valueOf(30));
68          solver.addPseudoBoolean(clause, coeffs, true, BigInteger.valueOf(10));
69          fail("Should not accept clauses if newvar has not been called!!!");
70      }
71  
72  }