adds a new backtrack test

This commit is contained in:
helmut.neemann 2018-01-15 15:24:08 +01:00
parent 249df37bd9
commit b35cce111e
2 changed files with 1543 additions and 0 deletions

View File

@ -1,10 +1,20 @@
package de.neemann.digital.analyse;
import de.neemann.digital.core.*;
import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.elements.PinException;
import de.neemann.digital.draw.elements.VisualElement;
import de.neemann.digital.draw.library.ElementLibrary;
import de.neemann.digital.draw.library.ElementNotFoundException;
import de.neemann.digital.integration.ToBreakRunner;
import junit.framework.TestCase;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
/**
* @author hneemann
@ -75,4 +85,26 @@ ExpressionCreator - s0 reduced from 17 to 2 variables ([Q_1n, Q_0n])
assertEquals(1, da.getInputs(m.getOutputs().get(1)).size());
}
public void testBacktrackCompleteness() throws Exception {
ToBreakRunner toBreakRunner = new ToBreakRunner("dig/backtrack/AllComponents.dig", false);
Circuit circuit = toBreakRunner.getCircuit();
Set<String> set = new HashSet<>();
for (VisualElement e : circuit.getElements())
set.add(e.getElementName());
// ensure all components are included in test circuit
for (ElementLibrary.ElementContainer c : toBreakRunner.getLibrary()) {
if (!set.contains(c.getDescription().getName())) {
// nodes with state are allowed to be missing
Element n = c.getDescription().createElement(new ElementAttributes());
boolean ok = (n instanceof Node) && ((Node) n).hasState();
assertTrue("component " + c.getDescription().getName() + " is missing in test/resources/dig/backtrack/AllComponents.dig!", ok);
}
}
// check if backtracking is ok at all components!
ModelAnalyser m = new ModelAnalyser(toBreakRunner.getModel());
new DependencyAnalyser(m);
}
}

File diff suppressed because it is too large Load Diff