Search in sources :

Example 1 with Model

use of de.neemann.digital.core.Model 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());
}
Also used : ValueTable(de.neemann.digital.data.ValueTable) Model(de.neemann.digital.core.Model)

Example 2 with Model

use of de.neemann.digital.core.Model in project Digital by hneemann.

the class TestResultTest method testResultOk.

public void testResultOk() 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 tr = new TestExecutor(data).create(model);
    assertEquals(4, tr.getResult().getRows());
    assertTrue(tr.allPassed());
}
Also used : Model(de.neemann.digital.core.Model)

Example 3 with Model

use of de.neemann.digital.core.Model 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());
}
Also used : ValueTable(de.neemann.digital.data.ValueTable) Model(de.neemann.digital.core.Model)

Example 4 with Model

use of de.neemann.digital.core.Model 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());
}
Also used : ValueTable(de.neemann.digital.data.ValueTable) Model(de.neemann.digital.core.Model)

Example 5 with Model

use of de.neemann.digital.core.Model in project Digital by hneemann.

the class ValueTableDialog method addTestResult.

/**
 * Add test results
 *
 * @param tsl     list of test sets
 * @param circuit the circuit
 * @param library the library to use
 * @return this for chained calls
 * @throws NodeException            NodeException
 * @throws TestingDataException     DataException
 * @throws PinException             PinException
 * @throws ElementNotFoundException ElementNotFoundException
 */
public ValueTableDialog addTestResult(ArrayList<TestSet> tsl, Circuit circuit, ElementLibrary library) throws PinException, NodeException, ElementNotFoundException, TestingDataException {
    Collections.sort(tsl);
    int i = 0;
    int errorTabIndex = -1;
    for (TestSet ts : tsl) {
        Model model = new ModelCreator(circuit, library).createModel(false);
        try {
            TestExecutor testExecutor = new TestExecutor(ts.data).create(model);
            if (testExecutor.getException() != null)
                SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_errorWhileExecutingTests_N0", ts.name)).addCause(testExecutor.getException()).setComponent(this));
            String tabName;
            Icon tabIcon;
            if (testExecutor.allPassed()) {
                tabName = Lang.get("msg_test_N_Passed", ts.name);
                tabIcon = ICON_PASSED;
            } else {
                tabName = Lang.get("msg_test_N_Failed", ts.name);
                tabIcon = ICON_FAILED;
                errorTabIndex = i;
            }
            if (testExecutor.toManyResults())
                tabName += " " + Lang.get("msg_test_missingLines");
            tp.addTab(tabName, tabIcon, new JScrollPane(createTable(testExecutor.getResult())));
            if (testExecutor.toManyResults())
                tp.setToolTipTextAt(i, new LineBreaker().toHTML().breakLines(Lang.get("msg_test_missingLines_tt")));
            resultTableData.add(testExecutor.getResult());
            i++;
        } finally {
            model.close();
        }
    }
    if (errorTabIndex >= 0)
        tp.setSelectedIndex(errorTabIndex);
    pack();
    setLocationRelativeTo(owner);
    return this;
}
Also used : ValueTableModel(de.neemann.digital.data.ValueTableModel) Model(de.neemann.digital.core.Model) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Aggregations

Model (de.neemann.digital.core.Model)85 ObservableValue (de.neemann.digital.core.ObservableValue)56 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)52 TestExecuter (de.neemann.digital.TestExecuter)49 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)16 ValueTable (de.neemann.digital.data.ValueTable)6 Signal (de.neemann.digital.core.Signal)4 ModelCreator (de.neemann.digital.draw.model.ModelCreator)4 ObservableValues (de.neemann.digital.core.ObservableValues)3 Expression (de.neemann.digital.analyse.expression.Expression)2 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)2 Node (de.neemann.digital.core.Node)2 Delay (de.neemann.digital.core.wiring.Delay)2 Circuit (de.neemann.digital.draw.elements.Circuit)2 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)2 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Variable (de.neemann.digital.analyse.expression.Variable)1 Parser (de.neemann.digital.analyse.parser.Parser)1