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.assertNotNull;
33 import static org.junit.Assert.assertTrue;
34 import static org.junit.Assert.fail;
35
36 import java.io.ByteArrayInputStream;
37 import java.io.IOException;
38
39 import org.junit.Test;
40 import org.sat4j.minisat.SolverFactory;
41 import org.sat4j.reader.DimacsReader;
42 import org.sat4j.reader.InstanceReader;
43 import org.sat4j.reader.LecteurDimacs;
44 import org.sat4j.reader.ParseFormatException;
45 import org.sat4j.specs.ContradictionException;
46 import org.sat4j.specs.IProblem;
47 import org.sat4j.specs.TimeoutException;
48
49 public class BugSAT25 {
50
51 @Test(expected = UnsupportedOperationException.class)
52 public void testReaderFromInstanceReader() throws ParseFormatException,
53 ContradictionException, IOException {
54 String cnfString = "p cnf 3 4\n1 2 3 0\n-1 -2 0\n-1 -3 0\n-2 -3 0";
55 InstanceReader reader = new InstanceReader(SolverFactory.newDefault());
56 reader.parseInstance(new ByteArrayInputStream(cnfString.getBytes()));
57 fail();
58 }
59
60 @Test
61 public void testReaderFromDimacsReader() throws ParseFormatException,
62 ContradictionException, IOException, TimeoutException {
63 String cnfString = "p cnf 3 4\n1 2 3 0\n-1 -2 0\n-1 -3 0\n-2 -3 0";
64 DimacsReader reader = new DimacsReader(SolverFactory.newDefault());
65 IProblem problem = reader.parseInstance(new ByteArrayInputStream(
66 cnfString.getBytes()));
67 assertNotNull(problem);
68 assertTrue(problem.isSatisfiable());
69 }
70
71 @Test
72 public void testReaderFromLecteurDimacs() throws ParseFormatException,
73 ContradictionException, IOException, TimeoutException {
74 String cnfString = "p cnf 3 4\n1 2 3 0\n-1 -2 0\n-1 -3 0\n-2 -3 0";
75 LecteurDimacs reader = new LecteurDimacs(SolverFactory.newDefault());
76 IProblem problem = reader.parseInstance(new ByteArrayInputStream(
77 cnfString.getBytes()));
78 assertNotNull(problem);
79 assertTrue(problem.isSatisfiable());
80 }
81 }