Search in sources :

Example 1 with TestVector

use of com.cburch.logisim.data.TestVector in project logisim-evolution by reds-heig.

the class TestPanel method changeColumnValueRadix.

public void changeColumnValueRadix(int i) {
    if (i == 0)
        return;
    TestVector vec = getModel().getVector();
    switch(vec.columnRadix[i - 1]) {
        case 2:
            vec.columnRadix[i - 1] = 10;
            break;
        case 10:
            vec.columnRadix[i - 1] = 16;
            break;
        default:
            vec.columnRadix[i - 1] = 2;
            break;
    }
    table.modelChanged();
}
Also used : TestVector(com.cburch.logisim.data.TestVector)

Example 2 with TestVector

use of com.cburch.logisim.data.TestVector in project logisim-evolution by reds-heig.

the class TestPanel method getRowData.

public void getRowData(int firstRow, int numRows, ValueTable.Cell[][] rowData) {
    Model model = getModel();
    TestException[] results = model.getResults();
    int numPass = model.getPass();
    int numFail = model.getFail();
    TestVector vec = model.getVector();
    int columns = vec.columnName.length;
    String[] msg = new String[columns];
    Value[] altdata = new Value[columns];
    String passMsg = Strings.get("passStatus");
    String failMsg = Strings.get("failStatus");
    for (int i = firstRow; i < firstRow + numRows; i++) {
        int row = model.sortedIndex(i);
        Value[] data = vec.data.get(row);
        String rowmsg = null;
        String status = null;
        boolean failed = false;
        if (row < numPass + numFail) {
            TestException err = results[row];
            if (err != null && err instanceof FailException) {
                failed = true;
                for (FailException e = (FailException) err; e != null; e = e.getMore()) {
                    int col = e.getColumn();
                    msg[col] = StringUtil.format(Strings.get("expectedValueMessage"), e.getExpected().toDisplayString(getColumnValueRadix(col + 1)));
                    altdata[col] = e.getComputed();
                }
            } else if (err != null) {
                failed = true;
                rowmsg = err.getMessage();
            }
            status = failed ? failMsg : passMsg;
        }
        rowData[i - firstRow][0] = new ValueTable.Cell(status, rowmsg != null ? failColor : null, null, rowmsg);
        for (int col = 0; col < columns; col++) {
            rowData[i - firstRow][col + 1] = new ValueTable.Cell(altdata[col] != null ? altdata[col] : data[col], msg[col] != null ? failColor : null, null, msg[col]);
            msg[col] = null;
            altdata[col] = null;
        }
    }
}
Also used : TestException(com.cburch.logisim.data.TestException) TestVector(com.cburch.logisim.data.TestVector) ValueTable(com.cburch.logisim.gui.log.ValueTable) Value(com.cburch.logisim.data.Value) FailException(com.cburch.logisim.data.FailException)

Example 3 with TestVector

use of com.cburch.logisim.data.TestVector in project logisim-evolution by reds-heig.

the class TestThread method doTestVector.

// used only for automated testing via command line arguments
public static int doTestVector(Project proj, Circuit circuit, String vectorname) {
    System.out.println(StringUtil.format(Strings.get("testLoadingVector"), vectorname));
    TestVector vec;
    try {
        vec = new TestVector(vectorname);
    } catch (Exception e) {
        System.err.println(StringUtil.format(Strings.get("testLoadingFailed"), e.getMessage()));
        return -1;
    }
    TestThread tester;
    try {
        tester = new TestThread(proj, circuit, vec);
    } catch (TestException e) {
        System.err.println(StringUtil.format(Strings.get("testSetupFailed"), e.getMessage()));
        return -1;
    }
    System.out.println(StringUtil.format(Strings.get("testRunning"), Integer.toString(vec.data.size())));
    int numPass = 0, numFail = 0;
    for (int i = 0; i < vec.data.size(); i++) {
        try {
            System.out.print((i + 1) + " \r");
            tester.test(i);
            numPass++;
        } catch (FailException e) {
            System.out.println();
            System.err.println(StringUtil.format(Strings.get("testFailed"), Integer.toString(i + 1)));
            for (; e != null; e = e.getMore()) System.out.println("  " + e.getMessage());
            numFail++;
            continue;
        } catch (TestException e) {
            System.out.println();
            System.err.println(StringUtil.format(Strings.get("testFailed"), Integer.toString(i + 1) + " " + e.getMessage()));
            numFail++;
            continue;
        }
    }
    System.out.println();
    System.out.println(StringUtil.format(Strings.get("testResults"), Integer.toString(numPass), Integer.toString(numFail)));
    return 0;
}
Also used : TestVector(com.cburch.logisim.data.TestVector) TestException(com.cburch.logisim.data.TestException) FailException(com.cburch.logisim.data.FailException) TestException(com.cburch.logisim.data.TestException) FailException(com.cburch.logisim.data.FailException)

Aggregations

TestVector (com.cburch.logisim.data.TestVector)3 FailException (com.cburch.logisim.data.FailException)2 TestException (com.cburch.logisim.data.TestException)2 Value (com.cburch.logisim.data.Value)1 ValueTable (com.cburch.logisim.gui.log.ValueTable)1