TestResults* TestCaseTokens::doit(const std::string &prefix) { std::ifstream student_instr((prefix+"_"+filename).c_str()); std::string s = ""; if (student_instr) { std::cout << "STUDENT FILE EXISTS" << std::endl; s = std::string(std::istreambuf_iterator<char>(student_instr), std::istreambuf_iterator<char>()); std::cout << "student file size = " << s.size() << std::endl; } if (s.size() > MAX_FILE_SIZE) { std::cout << "ERROR: student file size too big " << s.size() << " > " << MAX_FILE_SIZE << std::endl; return new TestResults(0,"ERROR: student file too large for grader"); } //return test_case_grader[j]->cmp_output (s,e); return token_grader(s,tokens); }
TestResults* TestCaseCustom::doit(const std::string &prefix) { std::ifstream student_instr((prefix+"_"+filename).c_str()); std::string s = ""; if (!student_instr) { std::cout << "ERROR: STUDENT FILE DOES NOT EXIST" << std::endl; return new TestResults(0,"Error: student file does not exist"); } std::vector<std::string> argv; argv.push_back("MY_EXECUTABLE.out"); std::stringstream ss(my_arg_string); std::string token; while (ss >> token) { argv.push_back(token); } std::stringstream output; float answer = custom_grader(student_instr,output,argv); std::cout << "GRADE: " << answer << "\nOUTPUT:\n" << output.str() << std::endl; std::string tmp = output.str(); std::string replaced; for (int i = 0; i < tmp.size(); i++) { if (tmp[i] != '\n') { replaced.push_back(tmp[i]); } else { replaced += "<br>\n"; } } return new TestResults(answer,replaced); }
TestResults* TestCaseComparison::doit(const std::string &prefix) { std::cout << "IN DOIT FOR COMPARISON '" << prefix+"_"+filename << "' '" << expected_file << "'" << std::endl; std::ifstream student_instr((prefix+"_"+filename).c_str()); std::ifstream expected_instr(expected_file.c_str()); std::string s = ""; std::string e = ""; if (student_instr) { std::cout << "STUDENT FILE EXISTS" << std::endl; s = std::string(std::istreambuf_iterator<char>(student_instr), std::istreambuf_iterator<char>()); std::cout << "student file size = " << s.size() << std::endl; } if (expected_instr) { std::cout << "EXPECTED FILE EXISTS" << std::endl; e = std::string(std::istreambuf_iterator<char>(expected_instr), std::istreambuf_iterator<char>()); std::cout << "expected file size = " << e.size() << std::endl; } if (s.size() > MYERS_DIFF_MAX_FILE_SIZE) { std::cout << "ERROR: student file size too big " << s.size() << " > " << MYERS_DIFF_MAX_FILE_SIZE << std::endl; return new TestResults(0,"Error: student file too large for grader"); } if (e.size() > MYERS_DIFF_MAX_FILE_SIZE) { std::cout << "ERROR: expected file size too big " << e.size() << " > " << MYERS_DIFF_MAX_FILE_SIZE << std::endl; return new TestResults(0,"Error: expected file too large for grader"); } std::cout << "GOING TO COMPARE studentsize=" << s.size() << " expectedsize="<< e.size() << std::endl; //return test_case_grader[j]->cmp_output (s,e); return cmp_output (s,e); }