本文整理汇总了C++中TestSuite::dirCrawl方法的典型用法代码示例。如果您正苦于以下问题:C++ TestSuite::dirCrawl方法的具体用法?C++ TestSuite::dirCrawl怎么用?C++ TestSuite::dirCrawl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestSuite
的用法示例。
在下文中一共展示了TestSuite::dirCrawl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
int i;
vector<string> cpps;
string class_dir;
TestSuite t;
//If they did not provide the minimum set of args
if( argc < 3 )
{
cout << "Usage: ./tester [-g|-r] [directory]" << endl;
cout << " -g: Generate test cases from \"golden\" .cpp" << endl;
cout << " -r: Run tests on student programs." << endl;
return -1;
}
class_dir = argv[2];
if(chdir(argv[2]))
{
cout << "Failed to change to directory: " << class_dir;
}
//Choose one of two modes. [R]unning tests or [G]enerating tests.
string flag = argv[1];
if(flag == "-g")
{
//Call test generation function
t.helper_func();
}
else if(flag == "-r")
{
//fill "cpps" with the name of every .cpp to be ran
t.dirCrawl(".cpp", ".", cpps);
//loop through every .cpp and run it
for(i=0;i<cpps.size();i++)
{
//Excludes the "golden" .cpp from being evaluated
if(count(cpps.at(i).begin(), cpps.at(i).end(), '/') > 1)
{
//t.initTest(argv[1],".tst",".ans");
t.initTest( cpps.at(i) ,".tst",".ans");
t.runTests();
t.outputLogFile();
t.reset();
}
}
//end for loop
t.createSummary();
}
else
{
cout << "Unrecognized command line option. [-g|-r]" << endl;
return -2;
}
return 0;
}
示例2: main
int main(int argc, char ** argv)
{
int i;
vector<string> cpps;
string class_dir = "", presentationOpt = "";
TestSuite t;
vector<string> spec;
bool menuTesting;
//If they did not provide the minimum set of args
if( argc < 3 )
{
cout << "Usage: ./tester [-g|-r] [directory] | [-p]" << endl;
cout << " -g: Generate test cases from \"golden\" .cpp" << endl;
cout << " -r: Run tests on student programs." << endl;
cout << " -p: Profile student code." << endl;
return -1;
}
class_dir = argv[2];
if(chdir(argv[2]))
{
cout << "Failed to change to directory: " << class_dir;
}
string profile_flag = "";
if(argc == 4)
{
profile_flag = argv[3];
if(profile_flag == "-p")
t.profiling = true;
}
//Choose one of two modes. [R]unning tests or [G]enerating tests.
string flag = argv[1];
if(flag == "-g")
{
t.dirCrawl(".spec", ".",spec);
//if spec file exists, do menu driven testing
if ((int)spec.size() != 0)
menuTesting = t.menu_tests(spec[0]);
//Call test generation function
if(!menuTesting)
t.helper_func();
}
else if(flag == "-r")
{
bool run = true, tests_initialized = false;
string test_again;
while(run)
{
test_again = "";
cout << "What is the maximum amount of time you would like a program to run";
cout << " before it is considered an infinite loop (in seconds)? ";
cout << endl;
cin >> t.allowed_time;
t.presentationMenu();
//fill "cpps" with the name of every .cpp to be ran
if(!tests_initialized)
t.dirCrawl(".cpp", ".", cpps);
//loop through every .cpp and run it
for(i=0; i<(int)cpps.size(); i++)
{
//Excludes the "golden" .cpp from being evaluated
if(count(cpps.at(i).begin(), cpps.at(i).end(), '/') > 1)
{
cout << cpps.at(i) << endl;
//t.initTest(argv[1],".tst",".ans");
if(!tests_initialized)
t.initTest( cpps.at(i) ,".tst",".ans");
t.runTests(cpps.at(i));
t.outputLogFile();
}
}
//end for loop
tests_initialized = true;
t.createSummary();
while(test_again != "y" && test_again != "n")
{
cout << "Do you want to run another test? (y/n)";
cin >> test_again;
}
if(test_again == "n")
run = false;
}
t.cleanDir();
system ("rm dummy.out");
system ("rm test_out.klein");
}