本文整理汇总了C++中TestCase类的典型用法代码示例。如果您正苦于以下问题:C++ TestCase类的具体用法?C++ TestCase怎么用?C++ TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestCase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: DATA_INFO
ReturnCode TestCaseLoader::loadAllTestCases()
{
ReturnCode retCode;
if(tcList.size() == 0)
tcList.reserve(20);
if(tcBuilders.size() == 0) {
DATA_INFO("No Test Case Builder Registered :: Operation Failed");
retCode.code = ERROR;
retCode.desc = "No Test Case Builder Registered :: Operation Failed";
return retCode;
}
vector<TestCaseBuilder*>::iterator itrVector;
for(itrVector = tcBuilders.begin(); itrVector != tcBuilders.end(); ++itrVector) {
TestCase* ptrToTC = (*itrVector)->buildTestCase();
DATA_INFO("Test Case built successfully");
int idx = (int)(ptrToTC->getTestCaseNumber());
itrList = tcList.begin();
std::advance(itrList,idx);
tcList.insert(itrList, ptrToTC);
DATA_INFO("Test Case inserted successfully");
}
retCode.code = SUCCESS;
retCode.desc = "All Test Cases loaded";
return retCode;
}
开发者ID:hailpam,项目名称:test-framework,代码行数:27,代码来源:testbench.cpp
示例2: run_test
bool run_test(TestCase& testCase, bool catch_exceptions)
{
gCurrentTestCase = testCase;
if (catch_exceptions) {
try {
gCurrentTestCase = testCase;
testCase.execute();
// the test code may declare itself failed
bool result = !gCurrentTestCase.failed;
post_test_sanity_check();
return result;
}
catch (std::runtime_error const& err) {
std::cout << "Error white running test case " << testCase.name << std::endl;
std::cout << err.what() << std::endl;
return false;
}
} else {
testCase.execute();
}
post_test_sanity_check();
return !gCurrentTestCase.failed;
}
开发者ID:whunmr,项目名称:circa,代码行数:28,代码来源:main.cpp
示例3: setupTests
Result * Suite::run(){
setupTests();
Result * r = new Result( _name );
Result::cur = r;
for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ){
TestCase * tc = *i;
r->_tests++;
bool passes = false;
log(1) << "\t" << tc->getName() << endl;
try {
tc->run();
passes = true;
}
catch ( ... ){
log() << "unknown exception in test: " << tc->getName() << endl;
}
if ( ! passes )
r->_fails++;
}
return r;
}
开发者ID:zhuk,项目名称:mongo,代码行数:29,代码来源:framework.cpp
示例4: TestCase
// This method is cloned from Operator, just resetting sign and exception bits
// (because we don't have any exception support in this toy example)
TestCase* FPSumOf3Squares::buildRandomTestCase(int i){
TestCase *tc;
/* Generate test cases using random input numbers */
tc = new TestCase(this); // TODO free all this memory when exiting TestBench
/* Fill inputs */
for (unsigned int j = 0; j < ioList_.size(); j++) {
Signal* s = ioList_[j];
if (s->type() == Signal::in) {
// ****** Modification: positive normal numbers with small exponents
mpz_class m = getLargeRandom(wF);
mpz_class bias = (mpz_class(1)<<(wE-1)) - 1;
mpz_class e = getLargeRandom(wE-2) - (mpz_class(1)<<(wE-3)) + bias; // ensure no overflow
mpz_class a = (mpz_class(1)<<(wE+wF+1)) // 01 to denote a normal number
+ (e<<wF) + m;
tc->addInput(s->getName(), a);
}
}
/* Get correct outputs */
emulate(tc);
// cout << tc->getInputVHDL();
// cout << tc->getExpectedOutputVHDL();
return tc;
}
开发者ID:jpdoyle,项目名称:flopoco,代码行数:28,代码来源:FPSumOf3Squares.cpp
示例5: runTestCase
void runTestCase(void* item, void* extraData) {
TestCase testCase = (TestCase)item;
TestSuite testSuite = (TestSuite)extraData;
int result;
if(!testSuite->onlyPrintFailing) {
printTestName(testCase->name);
}
if(testCase->testCaseFunc != NULL) {
if(testSuite->setup != NULL) {
testSuite->setup();
}
result = testCase->testCaseFunc();
if(result == 0) {
if(!testSuite->onlyPrintFailing) {
printTestSuccess();
}
testSuite->numSuccess++;
}
else {
printTestFail();
testSuite->numFail++;
}
if(testSuite->teardown != NULL) {
testSuite->teardown();
}
}
else {
if(!testSuite->onlyPrintFailing) {
_printTestSkipped();
}
testSuite->numSkips++;
}
}
开发者ID:Notalib,项目名称:MrsWatson,代码行数:35,代码来源:TestRunner.c
示例6: germanStudentsTest
/**
* \brief Executes a Z test for the "German students test" example on the slides.
*/
void StatisticalTesting::germanStudentsTest() {
const double testResults[] = {
97, 77, 100, 99, 100, 75, 76, 95, 96, 90,
96, 70, 71, 98, 97, 97, 67, 100, 97, 100,
92, 130, 100, 100, 95, 100, 92, 94, 89,
89, 82, 65, 100, 98, 85, 100, 93, 87, 100,
97, 73, 100, 93, 110, 95, 110, 79, 92, 96,
100, 87, 92, 110, 110, 100
};
const double distributionMean = 100;
const double distributionStandardDeviation = 12;
const double confidenceLevel = 0.95;
TestCase test;
Hypothesis a("Bonn students are better than other students", GREATER);
Hypothesis b("Bonn students are worse than other students", LESS);
Hypothesis c("Bonn students are at least as good as other students", AT_LEAST);
Hypothesis d("Bonn students are at most as good as other students", AT_MOST);
Hypothesis e("Bonn students are as good as other students", EQUAL);
Hypothesis f("Bonn students perform differently from other students", DIFFERENT);
/* TODO: Select a hypothesis and a null hypothesis from the above choices a-f and
* call test.setHypothesis(...) and test.setNullHypothesis(...) with the chosen
* variable.
*/
test.setHypothesis(b);
test.setNullHypothesis(c);
oneSampleZTest(arrayToVector(testResults), distributionMean, distributionStandardDeviation, confidenceLevel, test);
}
开发者ID:CheHaoKang,项目名称:HumanoidRobotics,代码行数:33,代码来源:StatisticalTesting.cpp
示例7: simple_unittest_suite_run
static int simple_unittest_suite_run(Suite* suite)
{
printf(" Unit test for Suite : %s \n", suite->name);
int fail_count = 0;
TestCase* index = suite->cases;
while (index != NULL)
{
if (suite->setup_func)
{
suite->setup_func();
}
simple_unittest_set_flag(1);
testInst->cur_time = simple_monotonic_time_now();
index->func();
int64_t tmp = simple_monotonic_time_now();
if (ut_flag == 1)
{
if(isatty(stdout->_fileno) == 1){
printf("\e[32m PASS \e[37m\x1b[0m , %s , %"PRId64" micro-seconds\n",
index->name, (tmp - testInst->cur_time));
}
else{
printf(" PASS , %s , %"PRId64" micro-seconds\n",
index->name, (tmp - testInst->cur_time));
}
testInst->cur_time = tmp;
}
开发者ID:red-chen,项目名称:simple,代码行数:27,代码来源:unittest.c
示例8: currentItem
void SummaryTree::addTestCases()
{
QTreeWidgetItem *curItem = currentItem();
if (indexOfTopLevelItem(curItem) == -1)
curItem = curItem->parent();
int index = indexOfTopLevelItem(curItem);
Task *curTask = curContest->getTask(index);
AddTestCasesWizard *wizard = new AddTestCasesWizard(this);
wizard->setSettings(settings, curTask->getTaskType() == Task::Traditional);
if (wizard->exec() == QDialog::Accepted) {
QList<QStringList> inputFiles = wizard->getMatchedInputFiles();
QList<QStringList> outputFiles = wizard->getMatchedOutputFiles();
for (int i = 0; i < inputFiles.size(); i ++) {
addTestCase();
QTreeWidgetItem *curItem = currentItem();
QTreeWidgetItem *parentItem = curItem->parent();
int taskIndex = indexOfTopLevelItem(parentItem);
int testCaseIndex = parentItem->indexOfChild(curItem);
Task *curTask = curContest->getTask(taskIndex);
TestCase *curTestCase = curTask->getTestCase(testCaseIndex);
curTestCase->setFullScore(wizard->getFullScore());
curTestCase->setTimeLimit(wizard->getTimeLimit());
curTestCase->setMemoryLimit(wizard->getMemoryLimit());
for (int j = 0; j < inputFiles[i].size(); j ++)
curTestCase->addSingleCase(inputFiles[i][j], outputFiles[i][j]);
setCurrentItem(parentItem);
setCurrentItem(curItem);
}
}
delete wizard;
}
开发者ID:DapperX,项目名称:project-lemon,代码行数:31,代码来源:summarytree.cpp
示例9: runTestCase
Result runTestCase (const TestCase& testCase)
{
Result result;
printf ("%s\n", testCase.getName ().c_str());
intend++;
for (auto& it : testCase)
{
try {
if (testCase.setup ())
{
testCase.setup () (this);
}
if (runTest (it.first, it.second))
{
result.succeded++;
}
else
{
result.failed++;
}
if (testCase.teardown ())
{
testCase.teardown () (this);
}
} catch (const std::exception& exc)
{
result.failed++;
}
}
intend--;
return result;
}
开发者ID:Piticfericit,项目名称:vstgui,代码行数:32,代码来源:unittests.cpp
示例10: planning
/**
* \brief Executes a two sample T test for the "Planning" example on the exercise sheet.
*/
void StatisticalTesting::planning() {
const double confidenceLevel = 0.95;
const double myPlanner[] = {
90, 104, 142, 143, 121,
190, 92, 93, 166, 110,
191, 122, 129, 176, 110,
45, 78, 166, 173, 115,
197, 63, 156, 124, 98
};
const double baselinePlanner[] = {
56, 92, 145, 117, 121,
91, 147, 174, 122, 111,
143, 142, 189, 129, 92,
112, 122, 120, 125, 200,
137, 147, 89, 101, 108
};
TestCase test;
Hypothesis a("My planner produces longer paths than the baseline.", GREATER);
Hypothesis b("My planner produces shorter paths than the baseline.", LESS);
Hypothesis c("My plans are at most as long as the baseline plans.", AT_MOST);
Hypothesis d("My plans are at least as long as the baseline plans.", AT_LEAST);
Hypothesis e("My plans are as long as the baseline paths.", EQUAL);
Hypothesis f("My plans have different lengths than the baseline paths.", DIFFERENT);
test.setHypothesis(f);
test.setNullHypothesis(e);
twoSampleTTest(arrayToVector(myPlanner), arrayToVector(baselinePlanner),
confidenceLevel, test);
}
开发者ID:CheHaoKang,项目名称:HumanoidRobotics,代码行数:34,代码来源:StatisticalTesting.cpp
示例11: TestCase
ReturnCode TestCaseLoader::loadTestCase(unsigned int tcIdx)
{
// TODO : to be reviewed : segmentation fault without the initial PAD
ReturnCode retCode;
if(tcList.size() == 0) {
tcList.reserve((tcIdx + 10));
TestCase* pad = new TestCase();
pad->setTestCaseNumber(100000);
pad->setSetupTestItem(0);
pad->setTearDownTestItem(0);
pad->addRunnableTestItem(0);
tcList.push_back(pad);
}
if(tcIdx > tcBuilders.size()) {
DATA_INFO("Index Out of Bound :: Operation Failed");
retCode.code = ERROR;
retCode.desc = "Index Out of Bound :: Operation Failed";
return retCode;
}
TestCaseBuilder* tcBuild = tcBuilders[tcIdx];
TestCase* ptrToTC = tcBuild->buildTestCase();
DATA_INFO("Test Case built successfully");
itrList = tcList.begin();
std::advance(itrList,tcIdx);
tcList.insert(itrList, ptrToTC);
DATA_INFO("Test Case inserted successfully");
retCode.code = SUCCESS;
retCode.desc = "Test Case loaded";
return retCode;
}
开发者ID:hailpam,项目名称:test-framework,代码行数:32,代码来源:testbench.cpp
示例12: registerTest
virtual void registerTest( TestCase const& testCase ) {
std::string name = testCase.getTestCaseInfo().name;
if( name == "" ) {
std::ostringstream oss;
oss << "Anonymous test case " << ++m_unnamedCount;
return registerTest( testCase.withName( oss.str() ) );
}
if( m_functions.find( testCase ) == m_functions.end() ) {
m_functions.insert( testCase );
m_functionsInOrder.push_back( testCase );
if( !testCase.isHidden() )
m_nonHiddenFunctions.push_back( testCase );
}
else {
TestCase const& prev = *m_functions.find( testCase );
{
Colour colourGuard( Colour::Red );
Catch::cerr() << "error: TEST_CASE( \"" << name << "\" ) already defined.\n"
<< "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n"
<< "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl;
}
exit(1);
}
}
开发者ID:jubalh,项目名称:Catch,代码行数:25,代码来源:catch_test_case_registry_impl.hpp
示例13: TEST_P
TEST_P(EncodeTest, EncodesAsExpected) {
std::string id = GetParam().first;
std::cout << "Test ID: " << id << std::endl;
const int passLength = 128;
char passwd[passLength];
char * const password = passwd;
char keyIDBuf[passLength];
char * const keyID = keyIDBuf;
TestCase testCase = GetParam().second;
char const * const userName = testCase.at("fullName").c_str();
char const * const masterPassword = testCase.at("masterPassword").c_str();
char const * const siteTypeString = testCase.at("siteType").c_str();
char const * const siteName = testCase.at("siteName").c_str();
const uint32_t siteCounter = (uint32_t)atoll(testCase.at("siteCounter").c_str());
char const * const siteScope = ScopeForVariant(VariantWithName(testCase.at("siteVariant").c_str()));
char const * const siteContext = testCase.at("siteContext").c_str();
int bOK = mpw_core(siteScope, password, passLength, userName, masterPassword, siteTypeString, siteName, siteCounter, siteContext, keyID, passLength);
EXPECT_EQ(0, bOK);
EXPECT_EQ(std::string(testCase.at("keyID")), std::string(keyID));
EXPECT_EQ(std::string(testCase.at("result")), std::string(password));
}
开发者ID:cuardin,项目名称:MasterPassword02,代码行数:27,代码来源:StandardizedTestSuite.cpp
示例14: printf
void
Runner::runTestAt( unsigned int index, TestResult &result ) const
{
TestCase *test = tests_[index]();
result.setTestName( test->testName() );
printf( "Testing %s: ", test->testName() );
fflush( stdout );
#if JSON_USE_EXCEPTION
try
{
#endif // if JSON_USE_EXCEPTION
test->run( result );
#if JSON_USE_EXCEPTION
}
catch ( const std::exception &e )
{
result.addFailure( __FILE__, __LINE__,
"Unexpected exception caugth:" ) << e.what();
}
#endif // if JSON_USE_EXCEPTION
delete test;
const char *status = result.failed() ? "FAILED"
: "OK";
printf( "%s\n", status );
fflush( stdout );
}
开发者ID:maheshmahajanplk,项目名称:Continuum,代码行数:26,代码来源:jsontest.cpp
示例15: runAllTests
int test::runAllTests() {
const std::vector<TestCase*> &testCases = TestCase::getCases();
int passed = 0;
const char *prevFixture = "";
for (int i = 0; i < testCases.size(); i++) {
TestCase *tc = testCases[i];
if (strcmp(tc->fixture, prevFixture) != 0) {
if (strlen(prevFixture) != 0) {
cout << endl;
}
cout << tc->fixture << ":" << endl;
prevFixture = tc->fixture;
}
cout << "- " << tc->name << ": " << flush;
try {
tc->run();
cout << "[OK]" << endl;
passed++;
} catch (TestFailedException &e) {
cout << "[FAILED]" << endl;
cout << " " << e.message << endl;
cout << " (" << e.file << ":" << e.line << ")" << endl;
}
}
cout << endl << passed << " / " << testCases.size() << " tests passed." << endl;
return (passed == testCases.size() ? 0 : 1);
}
开发者ID:fnothaft,项目名称:snap,代码行数:29,代码来源:TestLib.cpp
示例16:
std::string
Runner::testNameAt( unsigned int index ) const
{
TestCase *test = tests_[index]();
std::string name = test->testName();
delete test;
return name;
}
开发者ID:maheshmahajanplk,项目名称:Continuum,代码行数:8,代码来源:jsontest.cpp
示例17:
TestSuite::~TestSuite() {
unsigned i;
for (i = 0; i < this->mTests->count(); ++i) {
TestCase * ts = (TestCase*)this->mTests->objectAtIndex(i);
ts->release();
}
this->mTests->release();
}
开发者ID:guangshun,项目名称:SimpleMVC,代码行数:8,代码来源:TestSuite.cpp
示例18: log
Result * Suite::run(){
tlogLevel = -1;
log(1) << "\t about to setupTests" << endl;
setupTests();
log(1) << "\t done setupTests" << endl;
Result * r = new Result( _name );
Result::cur = r;
/* see note in SavedContext */
//writelock lk("");
for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ){
TestCase * tc = *i;
r->_tests++;
bool passes = false;
log(1) << "\t going to run test: " << tc->getName() << endl;
stringstream err;
err << tc->getName() << "\t";
try {
tc->run();
passes = true;
}
catch ( MyAssertionException * ae ){
err << ae->ss.str();
delete( ae );
}
catch ( std::exception& e ){
err << " exception: " << e.what();
}
catch ( int x ){
err << " caught int : " << x << endl;
}
catch ( ... ){
cerr << "unknown exception in test: " << tc->getName() << endl;
}
if ( ! passes ){
string s = err.str();
log() << "FAIL: " << s << endl;
r->_fails++;
r->_messages.push_back( s );
}
}
if ( r->_fails )
r->_rc = 17;
log(1) << "\t DONE running tests" << endl;
return r;
}
开发者ID:mikejs,项目名称:mongo,代码行数:58,代码来源:framework.cpp
示例19: registerTest
void TestRegistry::registerTest( TestCase const& testCase ) {
std::string name = testCase.getTestCaseInfo().name;
if( name.empty() ) {
ReusableStringStream rss;
rss << "Anonymous test case " << ++m_unnamedCount;
return registerTest( testCase.withName( rss.str() ) );
}
m_functions.push_back( testCase );
}
开发者ID:Corvusoft,项目名称:catch-dependency,代码行数:9,代码来源:catch_test_case_registry_impl.cpp
示例20: OnTestCaseEnd
void SDKUnitTestListener::OnTestCaseEnd(const TestCase& test_case) {
if (!GTEST_FLAG(print_time)) return;
const std::string counts = FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
PushResult( "[----------] " );
PushResult( UTIL_VarArgs("%s from %s (%s ms total)\n\n",
counts.c_str(), test_case.name(),
internal::StreamableToString(test_case.elapsed_time()).c_str() ) );
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:9,代码来源:sdk_listener.cpp
注:本文中的TestCase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论