mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
adds some test cases
This commit is contained in:
parent
fd867f08f8
commit
b5a6f26af1
@ -0,0 +1,48 @@
|
||||
package de.neemann.digital.testing;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.integration.ToBreakRunner;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestExecutorTest extends TestCase {
|
||||
|
||||
private Model m;
|
||||
private TestCaseDescription tcd;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
ToBreakRunner tbr = new ToBreakRunner("dig/setStateToTestResult.dig");
|
||||
List<Circuit.TestCase> tl = tbr.getCircuit().getTestCases();
|
||||
assertEquals(1, tl.size());
|
||||
tcd = tl.get(0).getTestCaseDescription();
|
||||
m = tbr.getModel();
|
||||
}
|
||||
|
||||
public void testSetStateToTestResult0() throws Exception {
|
||||
new TestExecutor(tcd, m).executeTo(0);
|
||||
assertEquals(0, m.getOutput("S").getValue());
|
||||
assertEquals(0, m.getOutput("O").getValue());
|
||||
}
|
||||
|
||||
public void testSetStateToTestResult12() throws Exception {
|
||||
new TestExecutor(tcd, m).executeTo(12);
|
||||
assertEquals(6, m.getOutput("S").getValue());
|
||||
assertEquals(0, m.getOutput("O").getValue());
|
||||
}
|
||||
|
||||
public void testSetStateToTestResultCarry() throws Exception {
|
||||
new TestExecutor(tcd, m).executeTo(256 * 2 - 1);
|
||||
assertEquals(0, m.getOutput("S").getValue());
|
||||
assertEquals(1, m.getOutput("O").getValue());
|
||||
}
|
||||
|
||||
public void testSetStateToTestResultError() throws Exception {
|
||||
new TestExecutor(tcd, m).executeTo(256 * 256 * 2 - 1);
|
||||
assertEquals(255, m.getOutput("S").getValue());
|
||||
assertEquals(0, m.getOutput("O").getValue());
|
||||
}
|
||||
|
||||
}
|
276
src/test/resources/dig/setStateToTestResult.dig
Normal file
276
src/test/resources/dig/setStateToTestResult.dig
Normal file
@ -0,0 +1,276 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<circuit>
|
||||
<version>1</version>
|
||||
<attributes/>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
<elementName>Testcase</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Testdata</string>
|
||||
<testData>
|
||||
<dataString>A B C O S
|
||||
|
||||
loop (a,256)
|
||||
loop (b,256)
|
||||
loop (c,2)
|
||||
let sum=a+b+c;
|
||||
(a) (b) (c) (sum>>8) (sum)
|
||||
end loop
|
||||
end loop
|
||||
end loop
|
||||
</dataString>
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="900" y="-120"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>A</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="960" y="-240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>B</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="960" y="-200"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>C</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="960" y="-160"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>S</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1240" y="-240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Add</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1040" y="-220"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>O</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1240" y="-180"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Comparator</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1040" y="-140"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Comparator</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1040" y="-60"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Const</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Value</string>
|
||||
<long>255</long>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Bits</string>
|
||||
<int>8</int>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="980" y="-40"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>NAnd</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="1140" y="-100"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>And</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="1160" y="-200"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="980" y="-180"/>
|
||||
<p2 x="1040" y="-180"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1220" y="-180"/>
|
||||
<p2 x="1240" y="-180"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1120" y="-100"/>
|
||||
<p2 x="1140" y="-100"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="960" y="-200"/>
|
||||
<p2 x="1000" y="-200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1100" y="-200"/>
|
||||
<p2 x="1160" y="-200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1000" y="-200"/>
|
||||
<p2 x="1040" y="-200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-120"/>
|
||||
<p2 x="1040" y="-120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1100" y="-120"/>
|
||||
<p2 x="1120" y="-120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1140" y="-120"/>
|
||||
<p2 x="1240" y="-120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="980" y="-40"/>
|
||||
<p2 x="1020" y="-40"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1100" y="-40"/>
|
||||
<p2 x="1120" y="-40"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-40"/>
|
||||
<p2 x="1040" y="-40"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1100" y="-220"/>
|
||||
<p2 x="1140" y="-220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-220"/>
|
||||
<p2 x="1040" y="-220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-140"/>
|
||||
<p2 x="1040" y="-140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1000" y="-60"/>
|
||||
<p2 x="1040" y="-60"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1120" y="-60"/>
|
||||
<p2 x="1140" y="-60"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="960" y="-240"/>
|
||||
<p2 x="1020" y="-240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1140" y="-240"/>
|
||||
<p2 x="1240" y="-240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="960" y="-160"/>
|
||||
<p2 x="980" y="-160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1140" y="-160"/>
|
||||
<p2 x="1160" y="-160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1220" y="-80"/>
|
||||
<p2 x="1240" y="-80"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1120" y="-60"/>
|
||||
<p2 x="1120" y="-40"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1120" y="-120"/>
|
||||
<p2 x="1120" y="-100"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1140" y="-240"/>
|
||||
<p2 x="1140" y="-220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1140" y="-160"/>
|
||||
<p2 x="1140" y="-120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="980" y="-180"/>
|
||||
<p2 x="980" y="-160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1000" y="-200"/>
|
||||
<p2 x="1000" y="-60"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1240" y="-120"/>
|
||||
<p2 x="1240" y="-80"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-240"/>
|
||||
<p2 x="1020" y="-220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-120"/>
|
||||
<p2 x="1020" y="-40"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="1020" y="-220"/>
|
||||
<p2 x="1020" y="-140"/>
|
||||
</wire>
|
||||
</wires>
|
||||
<measurementOrdering/>
|
||||
</circuit>
|
Loading…
x
Reference in New Issue
Block a user