本文整理汇总了C++中Test::BeforeTest方法的典型用法代码示例。如果您正苦于以下问题:C++ Test::BeforeTest方法的具体用法?C++ Test::BeforeTest怎么用?C++ Test::BeforeTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::BeforeTest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunAllTests
/// Run all benchmarking tests.
static void RunAllTests()
{
Benchmarker& instance = Instance();
// Initial output
std::cout << std::fixed;
std::cout << Console::TextGreen << "[==========]"
<< Console::TextDefault << " Running "
<< instance._tests.size()
<< (instance._tests.size() == 1 ?
" benchmark." :
" benchmarks.")
<< std::endl;
// Run through all the tests in ascending order.
#define PAD(x) std::cout << std::setw(34) << x << std::endl;
#define PAD_DEVIATION(description, \
deviated, \
average, \
unit) \
{ \
double _d_ = \
double(deviated) - double(average); \
\
PAD(description << \
deviated << " "unit" (" << \
(deviated < average ? \
Console::TextRed : \
Console::TextGreen) << \
(deviated > average ? "+" : "") << \
_d_ << " "unit" / " << \
(deviated > average ? "+" : "") << \
(_d_ * 100.0 / average) << " %" << \
Console::TextDefault << ")"); \
}
#define PAD_DEVIATION_INVERSE(description, \
deviated, \
average, \
unit) \
{ \
double _d_ = \
double(deviated) - double(average); \
\
PAD(description << \
deviated << " "unit" (" << \
(deviated > average ? \
Console::TextRed : \
Console::TextGreen) << \
(deviated > average ? "+" : "") << \
_d_ << " "unit" / " << \
(deviated > average ? "+" : "") << \
(_d_ * 100.0 / average) << " %" << \
Console::TextDefault << ")"); \
}
std::size_t index = 0;
std::size_t ran = 0; /// Number of executed tests
while (index < instance._tests.size())
{
// Get the test descriptor.
TestDescriptor* descriptor = instance._tests[index++];
// Check if test matches include filters
if(instance._include.size() > 0) {
bool included = false;
std::string name = descriptor->FixtureName + "." + descriptor->TestName+descriptor->Parameters;
for(std::size_t i = 0; i <instance._include.size(); i++) {
if(name.find(instance._include[i]) != std::string::npos) {
included = true;
break;
}
}
if(!included) {
continue;
}
}
ran++;
// Get test instance, which will handle BeforeTest() and AfterTest() hooks.
Test* hooks = descriptor->Factory->CreateTest();
hooks->BeforeTest(descriptor->FixtureName, descriptor->TestName, descriptor->Runs, descriptor->Iterations);
// Describe the beginning of the run.
std::cout << Console::TextGreen << "[ RUN ]"
<< Console::TextYellow << " "
<< descriptor->FixtureName << "."
<< descriptor->TestName
<< descriptor->Parameters
<< Console::TextDefault
<< " (" << descriptor->Runs
<< (descriptor->Runs == 1 ? " run, " : " runs, ")
<< descriptor->Iterations
<< (descriptor->Iterations == 1 ?
" iteration per run)" :
//.........这里部分代码省略.........