コード例 #1
0
void UTF8ValidatorTests::runTests(TestReporter &tr)
{
    tr.reportTestSuite("UTF-8 validator tests");
    for (auto &val : VALIDATION) {
        bool valid = validateUTF8String(val.second);
        tr.registerTest("Is '" + val.second + "' valid?",
                        val.first, valid);
    }
    tr.endTestSuite();
}
コード例 #2
0
int RunAllTests(TestReporter& reporter, TestList const& list, int const maxTestTimeInMs )
{
    TestResults result(&reporter);

    Timer overallTimer;
    overallTimer.Start();

    Test const* curTest = list.GetHead();
    while (curTest != 0)
    {
        Timer testTimer;
        testTimer.Start();
        result.OnTestStart(curTest->m_testName);

        curTest->Run(result);

        int const testTimeInMs = testTimer.GetTimeInMs();
        if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs)
        {
            MemoryOutStream stream;
            stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
                      "ms but took " << testTimeInMs << "ms.";
            result.OnTestFailure(curTest->m_filename, curTest->m_lineNumber,
                                 curTest->m_testName, stream.GetText());
        }
        result.OnTestFinish(curTest->m_testName, testTimeInMs/1000.0f);

        curTest = curTest->next;
    }

    float const secondsElapsed = overallTimer.GetTimeInMs() / 1000.0f;
    reporter.ReportSummary(result.GetTestCount(), result.GetFailureCount(), secondsElapsed);

    return result.GetFailureCount();
}
コード例 #3
0
ファイル: runner.c プロジェクト: thoni56/cgreen
/**
   run()
   
   N.B. Although this is neither an API or public function, it is
   documented as a good place to put a breakpoint. Do not change the
   name or semantics of this function, it should continue to be very
   close to the test code. */
static void run(CgreenTest *spec) {
#ifdef __cplusplus
    std::string message = "an exception was thrown during test: ";
    try {
#endif
        spec->run();
#ifdef __cplusplus
        return;
    } catch(const std::exception& exception) {
        message += '[';
        message += exception.what();
        message += ']';
    } catch(const std::exception* exception) {
        message += '[';
        message += exception->what();
        message += ']';
    } catch(const std::string& exception_message) {
        message += '[';
        message += exception_message;
        message += ']';
    } catch(const std::string *exception_message) {
        message += '[';
        message += *exception_message;
        message += ']';
    } catch(const char *exception_message) {
        message += '[';
        message += exception_message;
        message += ']';
    } catch (...) {
        message += "unknown exception type";
    }
    va_list no_arguments;
    memset(&no_arguments, 0, sizeof(va_list));
    TestReporter *reporter = get_test_reporter();
    reporter->show_incomplete(reporter, spec->filename, spec->line, message.c_str(), no_arguments);
    send_reporter_exception_notification(reporter);
#endif
}
コード例 #4
0
ファイル: TestRunner.cpp プロジェクト: fatman2021/sharm
int RunAllTests(TestReporter& reporter, TestList const& list, char const* suiteName, int const maxTestTimeInMs )
{
    TestResults result(&reporter);

    Timer overallTimer;
    overallTimer.Start();

    Test const* curTest = list.GetHead();
    while (curTest != 0)
    {
        if (suiteName == 0 || !std::strcmp(curTest->m_details.suiteName, suiteName))
        {
            Timer testTimer;
            testTimer.Start();
            result.OnTestStart(curTest->m_details);

            curTest->Run(result);

            int const testTimeInMs = testTimer.GetTimeInMs();
            if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_timeConstraintExempt)
            {
                MemoryOutStream stream;
                stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
                       "ms but took " << testTimeInMs << "ms.";
                result.OnTestFailure(curTest->m_details, stream.GetText());
            }
            result.OnTestFinish(curTest->m_details, (float)testTimeInMs);
        }

        curTest = curTest->next;
    }

    float const secondsElapsed = overallTimer.GetTimeInMs() / 1000.0f;
    reporter.ReportSummary(result.GetTotalTestCount(), result.GetFailedTestCount(), result.GetFailureCount(), secondsElapsed);

    return result.GetFailureCount();
}