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


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

本文整理汇总了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;
}
开发者ID:dtseng,项目名称:tnvme,代码行数:53,代码来源:group.cpp

示例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;
}
开发者ID:davidsaOpenu,项目名称:nvmeCompl,代码行数:101,代码来源:group.cpp


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