本文整理汇总了C++中TestResults类的典型用法代码示例。如果您正苦于以下问题:C++ TestResults类的具体用法?C++ TestResults怎么用?C++ TestResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestResults类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void Test::Run(TestResults& testResults)
{
try
{
#ifdef TRANSLATE_POSIX_SIGNALS
//add any signals you want translated into system exceptions here
SignalTranslator<SIGSEGV> sigSEGV;
SignalTranslator<SIGFPE> sigFPE;
SignalTranslator<SIGBUS> sigBUS;
#endif
RunImpl(testResults);
}
catch (std::exception const& e)
{
std::string msg = "Unhandled exception: ";
msg += e.what();
testResults.ReportFailure(m_filename.c_str(), m_lineNumber, msg);
}
catch (...)
{
testResults.ReportFailure(m_filename.c_str(), m_lineNumber, "Unhandled exception: crash!");
}
testResults.ReportDone(m_testName);
}
示例2: DegradedComponentTest
void TailGasMS::DegradedComponentTest(double _mean21, double _cv21, double _mean10, double _cv10, double _muTime, TestResults& result, std::string name, bool bAddTime)
{
std::cout << name << std::endl;
vector<double> _phi;
vector<double> _time;
JaggedMatrix *jm =
new JaggedMatrix(3);
jm->AddDistribution(2,1, _mean21, _cv21, DistributionFactory::Weibull);
jm->AddDistribution(1,0, _mean10, _cv10, DistributionFactory::Weibull);
jm->AddDistribution(1,2, _muTime, 1.0, DistributionFactory::Weibull);
jm->Display();
SemiMarkovModel smp(jm);
smp.SetModelInput(_missionTime, _NSteps);
smp.RegisterHandlers(NULL, NULL);
smp.SetupMatrices();
smp.ComputeStateProbabilities();
if(bAddTime)
{
_time = smp.GetTimeVector();
result.AddResult(_time);
}
_phi = smp.GetStateProbability(-1,0);
result.AddResult(_phi);
}
示例3: done
/*
* Name : _mem_cache_test_impl()
* Desc : Implements the memory cache performance config test
* as a separate RT thread.
* Args : args - Contains the test parameters.
* Returns : (void *) NULL.
*/
void *_mem_cache_test_impl(void *args) {
RTThreadArgs *threadArgs = (RTThreadArgs *) args;
TestResults *tResult = threadArgs->tResult;
int loop = 0, count = 0;
bool done(false);
int num = MCACHE_CONFIG_ARR_SIZE;
struct timespec startTime, endTime;
long long timeDiff;
bool printFlag(false);
while (!done) {
for (loop = 0; loop < threadArgs->iterations; loop++) {
TimeOperations::getCurTime(&startTime);
ArrayOperations::doArrayOpern(num);
TimeOperations::getCurTime(&endTime);
timeDiff = TimeOperations::getTimeDiff(endTime, startTime);
if (threadArgs->clParams.getVerboseLevel() >= 2) {
cout << "mem_cache_test: Difference "
"between end and start times = " << MICROSEC(timeDiff) << " us"
<< endl;
}
/* Add this to results */
tResult->setValuesAtNextIndex(timeDiff);
}
if (tResult->getMedian() > threadArgs -> clockAccuracy) {
printFlag = true;
if (tResult->checkStdDev(threadArgs->rangePct,
threadArgs->acceptablePct,
threadArgs->clParams.getVerboseLevel(), false)) {
done = true;
break;
} else {
if (++count == threadArgs->threshold) {
done = true;
break;
}
if (printFlag) {
VerbosePrint::rtmbPrintRetryMsg(threadArgs->clParams, 1,
"mcache_perf");
}
}
}
delete tResult;
tResult = new TestResults(MCACHE_CONFIG, threadArgs->iterations);
threadArgs->tResult = tResult;
num = num * 2;
}
tResult->setWorkQuantum(num);
return (void *) NULL;
}
示例4: CheckEqual
// Custom checkers
void CheckEqual(TestResults& results, const wchar_t* expected, const wchar_t* actual, TestDetails const& details)
{
using namespace std;
if (wcscmp(expected, actual))
{
UnitTest::MemoryOutStream stream;
stream << "Expected '" << expected << "' but was '" << actual << "'";
results.OnTestFailure(details, stream.GetText());
}
}
示例5: Run
void Test::Run(TestResults& testResults) const
{
try
{
#ifdef UNITTEST_POSIX
UNITTEST_THROW_SIGNALS
#endif
RunImpl(testResults);
}
catch (AssertException const& e)
{
testResults.OnTestFailure( TestDetails(m_details.testName, m_details.suiteName, e.Filename(), e.LineNumber()), e.what());
}
catch (std::exception const& e)
{
MemoryOutStream stream;
stream << "Unhandled exception: " << e.what();
testResults.OnTestFailure(m_details, stream.GetText());
}
catch (...)
{
testResults.OnTestFailure(m_details, "Unhandled exception: Crash!");
}
}
示例6: processManifest
bool processManifest(std::string manifestPath, TestResults &accumulatedResults)
{
fprintf(stderr, "manifest %s\n", manifestPath.c_str());
std::string base = basename(manifestPath);
std::string dir = dirname(manifestPath);
std::string cwd(getcwd());
chdir(dir.c_str());
std::ifstream fin(base.c_str());
YAML::Parser parser(fin);
TestResults testResults;
YAML::Node doc;
while (parser.GetNextDocument(doc))
{
for (YAML::Iterator it=doc.begin(); it!=doc.end(); ++it)
{
if (it->Type() == YAML::NodeType::Map)
{
testResults.entries++;
ManifestEntry manifestEntry(*it);
ManifestEntry::Result result = manifestEntry.process();
if (result == ManifestEntry::kSuccess)
testResults.successes++;
else if (result == ManifestEntry::kFailure)
testResults.failures++;
else if (result == ManifestEntry::kSkipped)
testResults.skipped++;
else if (result == ManifestEntry::kManifestError)
testResults.manifestErrors++;
}
}
}
chdir(cwd.c_str());
fprintf(stderr, "entries: %d, successes: %d, failures: %d, skipped: %d, manifest errors: %d\n",
testResults.entries,
testResults.successes,
testResults.failures,
testResults.skipped,
testResults.manifestErrors);
accumulatedResults.accumulate(testResults);
return 0;
}
示例7: fullName
void RunnerGUI::showDetails(Q3ListViewItem *item)
{
if ( item == 0L ) return;
QString name = fullName(item);
if ( name.endsWith("()") ) name = fullName(item->parent());
Tester *tester = Runner::self()->registry().find(name.local8Bit());
if ( tester == 0L ) return;
TestResults *res = 0L;
if ( tester->inherits("KUnitTest::SlotTester") )
res = static_cast<SlotTester*>(tester)->results(item->text(g_nameColumn).local8Bit());
else
res = tester->results();
if ( tester == 0L )
m_testerWidget->details()->setText("No test found with name: " + fullName(item));
else
{
Q3TextEdit *te = m_testerWidget->details();
te->clear();
te->append("<qt><a name=\"errors\"><font color=\"#990000\">Errors</font></a>:<br></qt>");
appendList(te, res->errorList());
te->append("<qt><br><hr><font color=\"#c2c939\">Expected to fail</font>:<br></qt>");
appendList(te, res->xfailList());
te->append("<qt><br><hr><font color=\"#BF00B5\">Unexpected Success</font>:<br></qt>");
appendList(te, res->xpassList());
te->append("<qt><br><hr><font color=\"#009900\">Success</font>:<br></qt>");
appendList(te, res->successList());
te->append("<qt><br><hr><font color=\"#F7A300\">Skipped</font>:<br></qt>");
appendList(te, res->skipList());
te->append("<qt><br><hr><font color=\"#000099\">Debug</font>:<br></qt>");
te->append(res->debugInfo());
te->scrollToAnchor("errors");
}
}
示例8: mem_cache_test
extern "C" bool mem_cache_test(CmdLineParams &clParams,
BenchMarkTestInfo &testInfo, RealTimeValues &rtValues,
ResultTable &resultTable) {
pthread_t tid;
pthread_attr_t *attr = NULL;
int new_iters = testInfo.getIterations();
bool rc(true);
/* If we are running quick mode, then we should just do 1 iteration */
if (clParams.isQuickRun()) {
new_iters = 1;
} else {
new_iters = new_iters * rtValues.getMultiplier();
}
testInfo.setIterations(new_iters);
list<TestResults *> *listOfResults = new list<TestResults *> ();
TestResults *tResult = new TestResults(MCACHE_CONFIG, new_iters);
/* Now ready the arguments to RT thread that will run the test */
RTThreadArgs thr_args(clParams, new_iters, testInfo.getThreshold(), tResult,
rtValues, getClockAccuracy(resultTable));
if (clParams.isVerbose() && (clParams.getVerboseLevel() >= 1)) {
cout << endl << "Test Report for mem_cache_test test:" << endl;
cout << "=============================================" << endl;
cout << endl << "mem_cache_test: Total number of iterations: "
<< new_iters << endl;
}
/* Create pthread attribute for the RT test thread */
attr = (pthread_attr_t *) malloc(sizeof(pthread_attr_t));
if (attr != NULL) {
pthread_attr_init(attr);
PthreadWrapper::setPthreadAttrSchedParam(attr, SCHED_FIFO,
(PthreadWrapper::schedGetPriorityMax(SCHED_FIFO) - 10));
/* Create and start RT test thread */
if (pthread_create(&tid, NULL, _mem_cache_test_impl, (void *) &thr_args)
== -1) {
perror("mem_cache_test");
cerr << "ERROR: Thread creation failed in " << "mem_cache_test()"
<< endl;
rc = false;
} else {
pthread_join(tid, (void **) NULL);
tResult = thr_args.tResult;
listOfResults->push_back(tResult);
if (thr_args.ret) {
if (clParams.isVerbose()) {
if (clParams.getVerboseLevel() >= 1) {
cout << "mem_cache_test: " << "Benchmark will be configured"
<< " to expect the memory cache "
<< " performance of this system "
<< " to be accurate to " << tResult->getMedian()
/ 1000.0 << " us." << endl;
}
}
rc = true;
} else {
rc = false;
}
resultTable.addResult(testInfo, listOfResults, rc);
}
} else {
cerr << "ERROR: malloc() of pthread_attr_t failed in "
<< "mem_cache_test()" << endl;
rc = false;
}
if (attr != NULL) {
pthread_attr_destroy(attr);
free(attr);
}
if (!rc) {
if (tResult != NULL) {
delete tResult;
}
}
return rc;
}
示例9: validateTestCases
/* Runs through each test case, pulls in the correct files, validates, and outputs the results */
int validateTestCases(const std::string &hw_id, const std::string &rcsid, int subnum, const std::string &subtime) {
std::string grade_path = ".submit.grade";
std::ofstream gradefile(grade_path.c_str());
gradefile << "Grade for: " << rcsid << std::endl;
gradefile << " submission#: " << subnum << std::endl;
int penalty = -std::min(submission_penalty,int(std::ceil(std::max(0,subnum-max_submissions)/10.0)));
assert (penalty >= -submission_penalty && penalty <= 0);
if (penalty != 0) {
gradefile << " penalty for excessive submissions: " << penalty << " points" << std::endl;
}
int nonhidden_auto_pts = penalty;
int hidden_auto_pts = penalty;
int nonhidden_extra_credit = 0;
int hidden_extra_credit = 0;
int nonhidden_possible_pts = 0;
int hidden_possible_pts = 0;
int possible_ta_pts = ta_pts;
std::stringstream testcase_json;
std::vector<std::string> all_testcases;
// LOOP OVER ALL TEST CASES
for (int i = 0; i < testcases.size(); ++i) {
std::cout << "------------------------------------------\n" << testcases[i].title() << " - points: " << testcases[i].points() << std::endl;
// START JSON FOR TEST CASE
std::vector<std::string> testcase_vector;
testcase_vector.push_back("\t\t\t\"test_name\": \"" + testcases[i].title() + "\"");
testcase_vector.push_back("\t\t\t\"execute_logfile\": \"" + testcases[i].prefix() + "_execute_logfile.txt\"");
int testcase_pts = 0;
std::string message = "";
// FILE EXISTS & COMPILATION TESTS DON'T HAVE FILE COMPARISONS
if (testcases[i].isFileExistsTest()) {
std::cerr << "THIS IS A FILE EXISTS TEST! " << testcases[i].getFilename() << std::endl;
assert (testcases[i].getFilename() != "");
if ( access( (std::string("")+testcases[i].getFilename()).c_str(), F_OK|R_OK|W_OK ) != -1 ) { /* file exists */
std::cerr << "file does exist: " << testcases[i].getFilename() << std::endl;
testcase_pts = testcases[i].points();
}
else {
std::cerr << "ERROR file DOES NOT exist: " << testcases[i].getFilename() << std::endl;
message += "Error: " + testcases[i].getFilename() + " was not found!";
}
}
else if (testcases[i].isCompilationTest()) {
std::cerr << "THIS IS A COMPILATION! " << std::endl;
if ( access( testcases[i].getFilename().c_str(), F_OK|R_OK|W_OK ) != -1 ) { /* file exists */
std::cerr << "file does exist: " << testcases[i].getFilename() << std::endl;
testcase_pts = testcases[i].points();
}
else {
std::cerr << "ERROR file DOES NOT exist: " << testcases[i].getFilename() << std::endl;
message += "Error: compilation was not successful!";
}
if (testcases[i].isCompilationTest()) {
testcase_vector.push_back("\t\t\t\"compilation_output\": \"" + testcases[i].prefix() + "_STDERR.txt\"");
}
}
else {
// ALL OTHER TESTS HAVE 1 OR MORE FILE COMPARISONS
std::vector<std::string> diff_vectors;
double pts_helper = 0.0;
double fraction_sum = 0.0;
for (int j = 0; j < testcases[i].numFileGraders(); j++) {
std::vector<std::string> diff_vector;
std::cerr << "comparison #" << j << std::endl;
std::string helper_message = "";
TestResults *result = testcases[i].do_the_grading(j,helper_message);
// PREPARE THE JSON DIFF FILE
std::stringstream diff_path;
diff_path << testcases[i].prefix() << "_" << j << "_diff.json";
std::ofstream diff_stream(diff_path.str().c_str());
if (result != NULL) {
// THE GRADE (will be compiled across all comparisons)
std::cout << "result->getGrade() " << result->getGrade() << std::endl;
double pts_fraction = testcases[i].test_case_grader[j]->points_fraction;
std::cout << "pts_fraction " << pts_fraction << std::endl;
if (pts_fraction < -0.5) {
pts_fraction = 1 / double(testcases[i].numFileGraders());
}
fraction_sum += pts_fraction;
//.........这里部分代码省略.........
示例10: add
void TestResults::add(const TestResults &result)
{
results_.insert(results_.end(), result.begin(), result.end());
}