示例#1
0
void lc3_write_test_report(std::stringstream& oss, lc3_test& test, int& minipass_count, int& total_minitests)
{
    int pass_count = 0;
    if (test.max_points)
    {
        oss << (test.passed ? "Passed" : "Failed") << " Test case - " << test.name << " " <<
                test.points << " / " << test.max_points << " " << (test.has_halted ? "" : "(Did not finish!)") << "\n";
    }
    else
    {
        oss << (test.passed ? "Passed" : "Failed") << " Test case - " << test.name << " " <<
               (test.has_halted ? "" : "(Did not finish!)") << "\n";
    }

    if (test.passed) pass_count++;
    oss << "----------------------\n";

    for (unsigned int j = 0; j < test.output.size(); j++)
    {
        lc3_test_output& output = test.output[j];
        std::string type = lc3_test_output_string(output);

        if (output.points)
        {
            oss << (j + 1) << " (" << (output.passed ? 'P' : 'F') << " " << output.earned << " / " << output.points <<
                   ") " << type << "\n  expected (right): " << output.expected << "\n    actual  (left): " << output.actual << "\n";
        }
        else
        {
            oss << (j + 1) << " (" << (output.passed ? 'P' : 'F') << ") " << type << "\n  expected (right): " << output.expected <<
                   "\n    actual  (left): " << output.actual << "\n";
        }

        if (!output.extra_output.empty())
            oss << output.extra_output;

        if (output.passed) minipass_count++;
        total_minitests++;
    }

    if (test.warnings)
    {
        oss << "\nTest completed with " << test.warnings <<" warnings\n";
        oss << "-----------------------------------\n";
        oss << test.warning;
        oss << "\n";
    }

    oss << "\n";
}
示例#2
0
void RunTestDialog::UpdateTests()
{
    testTree->DeleteAllItems();
    wxTreeItemId root = testTree->AddRoot(filename);
    for (unsigned int i = 0; i < suite.tests.size(); i++)
    {
        lc3_test& test = suite.tests[i];
        wxTreeItemId testId = testTree->AppendItem(root, test.name, -1, -1, new TestTreeItem(&test));
        //printf("Test case %d - %s - %s %d/%d %s\n", i + 1, test.name.c_str(), test.passed ? "Passed" : "Failed", test.points, test.max_points, test.has_halted ? "" : "(Did not finish!)");
        for (unsigned int j = 0; j < test.output.size(); j++)
        {
            lc3_test_output& output = test.output[j];
            testTree->AppendItem(testId, lc3_test_output_string(output), -1, -1, new TestTreeItem(&output));
        }
    }
}
示例#3
0
/** @brief Update
  *
  * @todo: document this function
  */
void CheckInfoPanel::Update(lc3_test_output& output)
{
    this->output = &output;
    pointsText->Hide();
    points->Hide();
    passed->SetLabel(output.passed ? "Yes" : "No");
    condition->SetLabel(lc3_test_output_string(output));
    expected->SetLabel(output.expected);
    actual->SetLabel(output.actual);

    if (output.points)
    {
        pointsText->Show();
        points->Show();
        points->SetLabel(wxString::Format("%d / %d", output.earned, output.points));
    }

    Layout();
}
示例#4
0
/** @brief Update
  *
  * @todo: document this function
  */
void TestCaseInfoPanel::Update(lc3_test& testcase)
{
    this->testcase = &testcase;

    testName->SetLabel(testcase.name);
    int pass_count = 0;

    testOutputs->Clear();
    testInputs->Clear();
    testInfo->Clear();
    halted->Hide();
    warning->Hide();
    warningButton->Hide();
    pointsText->Hide();
    points->Hide();

    // Set up output list and calculate stats
    for (unsigned int j = 0; j < testcase.output.size(); j++)
    {
        lc3_test_output& output = testcase.output[j];
        if (output.passed) pass_count++;

        wxString address = (output.type != TEST_IO && output.type != TEST_PC && output.type != TEST_SUBROUTINE) ? output.address : "";
        testOutputs->Append(wxString::Format("(%s) %s", output.passed ? "Passed" : "Failed", lc3_test_output_string(output)));
    }

    // Set up input list
    for (unsigned int j = 0; j < testcase.input.size(); j++)
    {
        lc3_test_input& input = testcase.input[j];
        testInputs->Append(lc3_test_input_string(input));
    }

    // Set up info list
    testInfo->Append(wxString::Format("True Traps Enabled: %s", testcase.true_traps ? "Yes" : "No"));
    testInfo->Append(wxString::Format("Interrupts Enabled: %s", testcase.interrupt_enabled ? "Yes" : "No"));
    testInfo->Append(wxString::Format("Disable Plugins: %s", testcase.disable_plugins ? "Yes" : "No"));
    testInfo->Append(wxString::Format("Randomize Memory: %s", testcase.randomize ? "Yes" : "No"));
    if (testcase.has_max_executions)
        testInfo->Append(wxString::Format("Maximum Instructions: %lu", testcase.max_executions));

    // Set up other
    executions->SetLabel(wxString::Format("%lu Instructions", testcase.executions));
    if (!testcase.has_halted) halted->Show();
    if (testcase.warnings > 0)
    {
        warning->Show();
        warningButton->Show();
    }

    checksPassed->SetLabel(wxString::Format("%d / %d", pass_count, testcase.output.size()));

    if (testcase.max_points)
    {
        pointsText->Show();
        points->Show();
        points->SetLabel(wxString::Format("%d / %d", testcase.points, testcase.max_points));
    }

    Layout();
}