Commit a1dbd077 authored by Daniel Le Berre's avatar Daniel Le Berre

Add test case for #145

parent e5a61a7f
Pipeline #2877 failed with stages
in 2 minutes and 44 seconds
......@@ -58,6 +58,11 @@ public class InstanceReader extends Reader {
private final ISolver solver;
public InstanceReader(ISolver solver, Reader reader) {
this.solver = solver;
this.reader = reader;
}
public InstanceReader(ISolver solver) {
// dimacs = new DimacsReader(solver);
this.solver = solver;
......@@ -94,8 +99,8 @@ public class InstanceReader extends Reader {
}
@Override
public IProblem parseInstance(String filename) throws ParseFormatException,
IOException, ContradictionException {
public IProblem parseInstance(String filename)
throws ParseFormatException, IOException, ContradictionException {
String fname;
String prefix = "";
......@@ -116,7 +121,9 @@ public class InstanceReader extends Reader {
} else {
fname = filename;
}
this.reader = handleFileName(fname, prefix);
if (this.reader == null) {
this.reader = handleFileName(fname, prefix);
}
return this.reader.parseInstance(filename);
}
......
package org.sat4j;
import java.io.IOException;
import org.junit.Test;
import org.mockito.Mockito;
import org.sat4j.minisat.SolverFactory;
import org.sat4j.reader.InstanceReader;
import org.sat4j.reader.ParseFormatException;
import org.sat4j.reader.Reader;
import org.sat4j.specs.ContradictionException;
public class BugSAT145 {
@Test
public void testWindowsPath()
throws ParseFormatException, IOException, ContradictionException {
Reader mockReader = Mockito.mock(Reader.class);
InstanceReader instanceReader = new InstanceReader(
SolverFactory.newDefault(), mockReader);
instanceReader
.parseInstance("EZCNF:C:\\projects\\bla\\testcomments.cnf");
Mockito.verify(mockReader)
.parseInstance("C:\\\\projects\\\\bla\\\\testcomments.cnf");
}
@Test
public void testUnixPath()
throws ParseFormatException, IOException, ContradictionException {
Reader mockReader = Mockito.mock(Reader.class);
InstanceReader instanceReader = new InstanceReader(
SolverFactory.newDefault(), mockReader);
instanceReader.parseInstance("EZCNF:/projects/bla/testcomments.cnf");
Mockito.verify(mockReader)
.parseInstance("/projects/bla/testcomments.cnf");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment