use of de.neemann.digital.data.ValueTable in project Digital by hneemann.
the class TestResultTest method testResultError.
public void testResultError() throws Exception {
Model model = getModel("A+B");
TestCaseDescription data = new TestCaseDescription("A B Y\n" + "0 0 0\n" + "0 1 1\n" + "1 0 1\n" + "1 1 0\n");
TestExecutor te = new TestExecutor(data).create(model);
ValueTable tr = te.getResult();
assertEquals(4, tr.getRows());
assertFalse(te.allPassed());
assertEquals(true, ((MatchedValue) tr.getValue(0, 2)).isPassed());
assertEquals(true, ((MatchedValue) tr.getValue(1, 2)).isPassed());
assertEquals(true, ((MatchedValue) tr.getValue(2, 2)).isPassed());
assertEquals(false, ((MatchedValue) tr.getValue(3, 2)).isPassed());
}
use of de.neemann.digital.data.ValueTable in project Digital by hneemann.
the class TestResultTest method testResultDontCare2.
public void testResultDontCare2() throws Exception {
Model model = getModel("A+B");
TestCaseDescription data = new TestCaseDescription("A B Y\n" + "0 0 x\n" + "0 1 1\n" + "1 0 1\n" + "1 1 1\n");
TestExecutor te = new TestExecutor(data).create(model);
ValueTable tr = te.getResult();
assertEquals(4, tr.getRows());
assertTrue(te.allPassed());
}
use of de.neemann.digital.data.ValueTable in project Digital by hneemann.
the class TestResultTest method testResultDontCare.
public void testResultDontCare() throws Exception {
Model model = getModel("A+B");
TestCaseDescription data = new TestCaseDescription("A B Y\n" + "0 0 0\n" + "0 1 1\n" + "1 0 1\n" + "1 1 x\n");
TestExecutor te = new TestExecutor(data).create(model);
ValueTable tr = te.getResult();
assertEquals(4, tr.getRows());
assertTrue(te.allPassed());
}
use of de.neemann.digital.data.ValueTable in project Digital by hneemann.
the class TestCaseDescription method testData.
/**
* Runs a 4 bit counter build from JK flip flops 16 ticks.
* The 4 output signals are recoded in a DataSet.
*
* @throws Exception
*/
public void testData() throws Exception {
ToBreakRunner toBreakRunner = new ToBreakRunner("dig/data.dig").runToBreak(29);
// check recorded data
ValueTable dataSet = toBreakRunner.getModel().getObserver(ValueTableObserver.class).getLogData();
assertEquals(29, dataSet.getRows());
int i = 0;
for (Value[] ds : dataSet) {
// clock
assertEquals((~i) & 1, ds[0].getValue());
int s = i / 2 + 1;
// q_0
assertEquals(s & 1, ds[1].getValue());
// q_1
assertEquals((s >> 1) & 1, ds[2].getValue());
// q_2
assertEquals((s >> 2) & 1, ds[3].getValue());
// q_3
assertEquals((s >> 3) & 1, ds[4].getValue());
i++;
}
// try to write data to graphics instance
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Export(toBreakRunner.getCircuit(), (out) -> new GraphicsImage(out, "PNG", 1)).export(baos);
assertTrue(baos.size() > 15000);
// export data to CSV
StringWriter w = new StringWriter();
dataSet.saveCSV(new BufferedWriter(w));
assertEquals("\"step\",\"C\",\"q_0n\",\"q_1n\",\"q_2n\",\"q_3n\"\n" + "\"0\",\"1\",\"1\",\"0\",\"0\",\"0\"\n" + "\"1\",\"0\",\"1\",\"0\",\"0\",\"0\"\n" + "\"2\",\"1\",\"0\",\"1\",\"0\",\"0\"\n" + "\"3\",\"0\",\"0\",\"1\",\"0\",\"0\"\n" + "\"4\",\"1\",\"1\",\"1\",\"0\",\"0\"\n" + "\"5\",\"0\",\"1\",\"1\",\"0\",\"0\"\n" + "\"6\",\"1\",\"0\",\"0\",\"1\",\"0\"\n" + "\"7\",\"0\",\"0\",\"0\",\"1\",\"0\"\n" + "\"8\",\"1\",\"1\",\"0\",\"1\",\"0\"\n" + "\"9\",\"0\",\"1\",\"0\",\"1\",\"0\"\n" + "\"10\",\"1\",\"0\",\"1\",\"1\",\"0\"\n" + "\"11\",\"0\",\"0\",\"1\",\"1\",\"0\"\n" + "\"12\",\"1\",\"1\",\"1\",\"1\",\"0\"\n" + "\"13\",\"0\",\"1\",\"1\",\"1\",\"0\"\n" + "\"14\",\"1\",\"0\",\"0\",\"0\",\"1\"\n" + "\"15\",\"0\",\"0\",\"0\",\"0\",\"1\"\n" + "\"16\",\"1\",\"1\",\"0\",\"0\",\"1\"\n" + "\"17\",\"0\",\"1\",\"0\",\"0\",\"1\"\n" + "\"18\",\"1\",\"0\",\"1\",\"0\",\"1\"\n" + "\"19\",\"0\",\"0\",\"1\",\"0\",\"1\"\n" + "\"20\",\"1\",\"1\",\"1\",\"0\",\"1\"\n" + "\"21\",\"0\",\"1\",\"1\",\"0\",\"1\"\n" + "\"22\",\"1\",\"0\",\"0\",\"1\",\"1\"\n" + "\"23\",\"0\",\"0\",\"0\",\"1\",\"1\"\n" + "\"24\",\"1\",\"1\",\"0\",\"1\",\"1\"\n" + "\"25\",\"0\",\"1\",\"0\",\"1\",\"1\"\n" + "\"26\",\"1\",\"0\",\"1\",\"1\",\"1\"\n" + "\"27\",\"0\",\"0\",\"1\",\"1\",\"1\"\n" + "\"28\",\"1\",\"1\",\"1\",\"1\",\"1\"\n", w.toString());
}
use of de.neemann.digital.data.ValueTable in project Digital by hneemann.
the class TestResultTest method testResultDontCareInput2.
public void testResultDontCareInput2() throws Exception {
Model model = getModel("A*0+B*0+C");
TestCaseDescription data = new TestCaseDescription("A B C Y\n" + "x x 0 0\n" + "x x 1 1\n");
TestExecutor te = new TestExecutor(data).create(model);
ValueTable tr = te.getResult();
assertEquals(8, tr.getRows());
assertTrue(te.allPassed());
}
Aggregations