当前位置: 首页>>代码示例>>C++>>正文


C++ Test::BeforeTest方法代码示例

本文整理汇总了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)" :
//.........这里部分代码省略.........
开发者ID:nevkontakte,项目名称:hayai,代码行数:101,代码来源:hayai-benchmarker.hpp


注:本文中的Test::BeforeTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。