1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.sat4j;
31
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertTrue;
34
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.sat4j.core.VecInt;
38 import org.sat4j.minisat.SolverFactory;
39 import org.sat4j.specs.ContradictionException;
40 import org.sat4j.specs.ISolver;
41 import org.sat4j.specs.TimeoutException;
42
43 public class BugSAT17 {
44
45 private ISolver solver;
46
47 @Before
48 public void setup() throws ContradictionException {
49 this.solver = SolverFactory.newDefault();
50 this.solver.addClause(new VecInt(new int[] { 1 }));
51 this.solver.addClause(new VecInt(new int[] { 2 }));
52 }
53
54 @Test
55 public void testAll() throws ContradictionException, TimeoutException {
56 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { -2 })));
57 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { 2, -2 })));
58 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { 1, -2 })));
59 assertTrue(this.solver.isSatisfiable(new VecInt(new int[] { 2, 1 })));
60 }
61
62 @Test
63 public void testSingleLit() throws ContradictionException, TimeoutException {
64 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { -2 })));
65 }
66
67 @Test
68 public void testInconsistentLits() throws ContradictionException,
69 TimeoutException {
70 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { 2, -2 })));
71 }
72
73 @Test
74 public void testTwoLits() throws ContradictionException, TimeoutException {
75 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { 1, -2 })));
76 }
77
78 @Test
79 public void testSameLits() throws ContradictionException, TimeoutException {
80 assertTrue(this.solver.isSatisfiable(new VecInt(new int[] { 2, 1 })));
81 }
82
83 @Test
84 public void testOneSameOneContradictory() throws ContradictionException,
85 TimeoutException {
86 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { 2, -1 })));
87 assertFalse(this.solver.isSatisfiable(new VecInt(new int[] { -2 })));
88 }
89
90 }