本文整理汇总了C++中Test::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Test::Clone方法的具体用法?C++ Test::Clone怎么用?C++ Test::Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: advance
Group::TestResult
Group::RunTest(TestRef &tr, vector<TestRef> &skipTest)
{
string work;
if (TestExists(tr) == false)
return TR_NOTFOUND;
// Take out a valid deque<>::iterator to the test under execution
deque<Test *>::iterator myTest = mTests[tr.xLev][tr.yLev].begin();
advance(myTest, tr.zLev);
LOG_NRM("-----------------START TEST-----------------");
FORMAT_GROUP_DESCRIPTION(work, this)
LOG_NRM("%s", work.c_str());
FORMAT_TEST_NUM(work, "", tr.xLev, tr.yLev, tr.zLev)
work += (*myTest)->GetClassName();
work += ": ";
work += (*myTest)->GetShortDescription();
LOG_NRM("%s", work.c_str());
LOG_NRM("Compliance: %s", (*myTest)->GetComplianceDescription().c_str());
LOG_NRM("%s", (*myTest)->GetLongDescription(false, 0).c_str());
TestResult result;
if (SkippingTest(tr, skipTest)) {
result = TR_SKIPPING;
} else {
result = (*myTest)->Run() ? TR_SUCCESS: TR_FAIL;
if (result == TR_FAIL) {
FORMAT_GROUP_DESCRIPTION(work, this)
LOG_NRM(" %s", work.c_str());
FORMAT_TEST_NUM(work, "", tr.xLev, tr.yLev, tr.zLev)
work += (*myTest)->GetClassName();
work += ": ";
work += (*myTest)->GetShortDescription();
LOG_NRM(" %s", work.c_str());
} else {
LOG_NRM("SUCCESSFUL test case run");
}
}
LOG_NRM("------------------END TEST------------------");
// Guarantee nothing residual or unintended is left around. Enforce this
// by destroying the existing test obj and replace it with a clone of
// itself so looping tests over can still be supported.
LOG_DBG("Enforcing test obj cleanup, cloning & destroying");
Test *cleanMeUp = (*myTest); // Refer to test obj
deque<Test *>::iterator insertPos = mTests[tr.xLev][tr.yLev].erase(myTest);
mTests[tr.xLev][tr.yLev].insert(insertPos, cleanMeUp->Clone());
delete cleanMeUp;
return result;
}
示例2: advance
//.........这里部分代码省略.........
// Get a pointer to the test to execute
TestRef tr = dependencies[tstIdx];
if (TestExists(tr) == false) {
tstIdx = -1;
return TR_NOTFOUND;
}
deque<Test *>::iterator myTest = mTests[tr.xLev][tr.yLev].begin();
advance(myTest, tr.zLev);
// The first test within every group must be proceeded with a chance to
// save the state of the DUT, if and only if the feature is enabled.
if (gCmdLine.restore && (tstIdx == 0)) {
LOG_NRM("Saving the state of the DUT");
if (SaveState() == false) {
LOG_ERR("Unable to save the state of the DUT");
tstIdx = -1;
return TR_FAIL;
}
}
LOG_NRM("-----------------START TEST-----------------");
FORMAT_GROUP_DESCRIPTION(work, this)
LOG_NRM("%s", work.c_str());
FORMAT_TEST_NUM(work, "", tr.xLev, tr.yLev, tr.zLev)
work += (*myTest)->GetClassName();
work += ": ";
work += (*myTest)->GetShortDescription();
LOG_NRM("%s", work.c_str());
LOG_NRM("Compliance: %s", (*myTest)->GetComplianceDescription().c_str());
LOG_NRM("%s", (*myTest)->GetLongDescription(false, 0).c_str());
if (SkippingTest(tr, skipTest)) {
result = TR_SKIPPING;
skippedTests.push_back(tr);
numSkipped = (AdvanceDependencies(dependencies, tstIdx, false,
skippedTests) + 1);
} else {
switch ((*myTest)->Runnable(preserve)) {
case Test::RUN_TRUE:
result = (*myTest)->Run();
if (result == TR_FAIL) {
failedTests.push_back(tr);
numSkipped = AdvanceDependencies(dependencies, tstIdx, true,
skippedTests);
} else {
if (++tstIdx >= (int64_t)dependencies.size())
tstIdx = -1;
LOG_NRM("SUCCESSFUL test case run");
}
break;
case Test::RUN_FALSE:
result = TR_SKIPPING;
skippedTests.push_back(tr);
numSkipped = (AdvanceDependencies(dependencies, tstIdx, false,
skippedTests) + 1);
LOG_WARN("Reporting not runnable, skipping test: %ld:%ld.%ld.%ld",
tr.group, tr.xLev, tr.yLev, tr.zLev);
break;
default:
case Test::RUN_FAIL:
failedTests.push_back(tr);
numSkipped = AdvanceDependencies(dependencies, tstIdx, true,
skippedTests);
break;
}
}
FORMAT_GROUP_DESCRIPTION(work, this)
LOG_NRM("%s", work.c_str());
FORMAT_TEST_NUM(work, "", tr.xLev, tr.yLev, tr.zLev)
work += (*myTest)->GetClassName();
work += ": ";
work += (*myTest)->GetShortDescription();
LOG_NRM("%s", work.c_str());
LOG_NRM("------------------END TEST------------------");
// The last test within every group or a test failure must be following
// with a chance to restore the state of the DUT, if and only if the
// feature is enabled.
if (gCmdLine.restore && ((tstIdx == -1) || (result == TR_FAIL))) {
LOG_NRM("Restoring the state of the DUT");
if (RestoreState() == false) {
LOG_ERR("Unable to restore the state of the DUT");
tstIdx = -1;
return TR_FAIL;
}
}
// Guarantee nothing residing or unintended is left around. Enforce this
// by destroying the existing test obj and replace it with a clone of
// itself so looping tests over can still be supported.
LOG_DBG("Enforcing test obj cleanup, cloning & destroying");
Test *cleanMeUp = (*myTest); // Refer to test obj
deque<Test *>::iterator insertPos = mTests[tr.xLev][tr.yLev].erase(myTest);
mTests[tr.xLev][tr.yLev].insert(insertPos, cleanMeUp->Clone());
delete cleanMeUp;
return result;
}