use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class BoolTableExpandedTest method checkTable.
private void checkTable(ArrayList<Signal> in1) {
ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
List<Variable> vars = new Vars("a", "b", "c", "d").list();
check(new BoolTableByteArray(new byte[] { 1, 1, 0, 1 }), in1, in2, vars);
check(new BoolTableByteArray(new byte[] { 0, 1, 1, 0 }), in1, in2, vars);
check(new BoolTableByteArray(new byte[] { 1, 0, 0, 1 }), in1, in2, vars);
check(new BoolTableByteArray(new byte[] { 0, 0, 0, 1 }), in1, in2, vars);
check(new BoolTableByteArray(new byte[] { 0, 1, 1, 1 }), in1, in2, vars);
}
use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class BuilderExpressionCreatorTest method testMultipleResults.
public void testMultipleResults() throws AnalyseException, FormatterException, ExpressionException {
BoolTable table = new BoolTableByteArray(new byte[] { 2, 0, 0, 0, 1, 2, 0, 0, 1, 1, 2, 0, 1, 1, 1, 2 });
TruthTable tt = new TruthTable(vars(4)).addResult("Y", table);
ExpressionListenerStore els = new ExpressionListenerStore(null);
new ExpressionCreator(tt).create(els);
assertEquals(4, els.getResults().size());
}
use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class TruthTableTest method testGetByContext.
public void testGetByContext() throws Exception {
ArrayList<Variable> vars = Variable.vars(5);
TruthTable t = new TruthTable(vars).addResult();
BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
for (int i = 0; i < t.getRows(); i++) {
result.set(i, i % 3);
}
ContextFiller fc = new ContextFiller(vars);
for (int i = 0; i < t.getRows(); i++) {
fc.setContextTo(i);
assertEquals(i % 3, t.getByContext(0, fc));
}
}
use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class TruthTableTest method testHexExportTwo.
public void testHexExportTwo() throws Exception {
ArrayList<Variable> vars = Variable.vars(3);
TruthTable t = new TruthTable(vars).addResult();
BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
for (int i = 0; i < t.getRows(); i++) {
result.set(i, i % 2);
}
t.addResult();
result = (BoolTableByteArray) t.getResult(1);
for (int i = 0; i < t.getRows(); i++) {
result.set(i, (i + 1) % 2);
}
StringWriter w = new StringWriter();
t.saveHex(w);
w.close();
assertEquals("v2.0 raw\n" + "2\n" + "1\n" + "2\n" + "1\n" + "2\n" + "1\n" + "2\n" + "1\n", w.toString());
}
use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class TruthTableTest method testHexExportSingle.
public void testHexExportSingle() throws Exception {
ArrayList<Variable> vars = Variable.vars(3);
TruthTable t = new TruthTable(vars).addResult();
BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
for (int i = 0; i < t.getRows(); i++) {
result.set(i, i % 2);
}
StringWriter w = new StringWriter();
t.saveHex(w);
w.close();
assertEquals("v2.0 raw\n" + "0\n" + "1\n" + "0\n" + "1\n" + "0\n" + "1\n" + "0\n" + "1\n", w.toString());
}
Aggregations