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


C++ TestSuite::outputLogFile方法代码示例

本文整理汇总了C++中TestSuite::outputLogFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TestSuite::outputLogFile方法的具体用法?C++ TestSuite::outputLogFile怎么用?C++ TestSuite::outputLogFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestSuite的用法示例。


在下文中一共展示了TestSuite::outputLogFile方法的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;
}
开发者ID:rwfeather,项目名称:autotest-sp2,代码行数:60,代码来源:main.cpp

示例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");
    }
开发者ID:bonnebonne,项目名称:autotest-sp3,代码行数:99,代码来源:main.cpp


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