自动化测大样例
省流:
for((i=1;i<=10;i++))
do
g++ T1.cpp -std=c++14 -w -O2 -Wall -Wextra -o a.exe
cp ex_edit$i.in edit.in
./a.exe
diff -s -Z ex_edit$i.out edit.out
done
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
string filename="kamen",codename="T1";
string input1,input2,output1,output2;
void init();
signed main()
{
init();
// exit(0);
for(int i=0,nw=1;i<=100;i++,nw++)
{
if(access((input1+to_string(i)+input2).c_str(),F_OK)==0)
{
nw=system(("cp "+input1+to_string(i)+input2+" "+filename+".in").c_str());
nw=system(("g++ "+codename+".cpp -std=c++14 -w -O2 -o run_exe.exe").c_str());
nw=system("./run_exe.exe");
nw=system(("diff -s -Z "+filename+".out "+output1+to_string(i)+output2).c_str());
nw=system("rm run_exe.exe");
}
}
// system("rm .fuse_hidden*");
return 0;
}
void init()
{
if(access((filename+"1.in").c_str(),F_OK)==0) { input1=filename; input2=".in"; }
if(access(("ex_"+filename+"1.in").c_str(),F_OK)==0) { input1="ex_"+filename; input2=".in"; }
if(access(("ex"+filename+"1.in").c_str(),F_OK)==0) { input1="ex"+filename; input2=".in"; }
if(access((filename+"1.out").c_str(),F_OK)==0) { output1=filename; output2=".out"; }
if(access(("ex_"+filename+"1.out").c_str(),F_OK)==0) { output1="ex_"+filename; output2=".out"; }
if(access(("ex"+filename+"1.out").c_str(),F_OK)==0) { output1="ex"+filename; output2=".out"; }
if(access((filename+"1.ans").c_str(),F_OK)==0) { output1=filename; output2=".ans"; }
if(access(("ex_"+filename+"1.ans").c_str(),F_OK)==0) { output1="ex_"+filename; output2=".ans"; }
if(access(("ex"+filename+"1.ans").c_str(),F_OK)==0) { output1="ex"+filename; output2=".ans"; }
}
以下是博客签名,正文无关
本文来自博客园,作者:Wy_x,转载请在文首注明原文链接:https://www.cnblogs.com/Wy-x/p/19228364
版权声明:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议(CC-BY-NC-SA 4.0 协议)进行许可。

浙公网安备 33010602011771号