1 package org.sat4j.tools;
2
3 import static org.junit.Assert.assertFalse;
4 import static org.junit.Assert.assertTrue;
5
6 import org.junit.Before;
7 import org.junit.Test;
8 import org.sat4j.core.VecInt;
9 import org.sat4j.minisat.SolverFactory;
10 import org.sat4j.specs.IVecInt;
11
12 public class TestCheckItIsAMUS {
13
14 private CheckMUSSolutionListener check;
15
16 @Before
17 public void setUp() throws Exception {
18 check = new CheckMUSSolutionListener(SolverFactory.instance());
19 }
20
21 @Test
22 public void testItWorksOnSimpleMUSes() {
23 IVecInt c1 = new VecInt();
24
25 c1.push(1);
26 check.addOriginalClause(c1);
27
28 c1.clear();
29 c1.push(2);
30 check.addOriginalClause(c1);
31
32 c1.clear();
33 c1.push(-1).push(-2);
34 check.addOriginalClause(c1);
35
36 IVecInt mus = new VecInt();
37 mus.push(1).push(2).push(3);
38
39 assertTrue(check.checkThatItIsAMUS(mus));
40 }
41
42 @Test
43 public void testItWorksOnSimpleNonMUSes() {
44 IVecInt c1 = new VecInt();
45
46 c1.push(1);
47 check.addOriginalClause(c1);
48
49 c1.clear();
50 c1.push(2);
51 check.addOriginalClause(c1);
52
53
54
55
56
57 IVecInt mus = new VecInt();
58 mus.push(1).push(2);
59
60 assertFalse(check.checkThatItIsAMUS(mus));
61 }
62
63 }