Hi everyone! I have a testcases include a lot of tests (example 1.in/1.out,...). But I do not know how to write a script (or a program with C++ or any language) to test my testcases. If you know how to do it, hope you will help me! Thank you.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
2 | maomao90 | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Hi everyone! I have a testcases include a lot of tests (example 1.in/1.out,...). But I do not know how to write a script (or a program with C++ or any language) to test my testcases. If you know how to do it, hope you will help me! Thank you.
Name |
---|
I use https://ideone.com/88FCXo to generate the outputs for all input files. You can throw in a diff command to compare the output files.
How can you check TLE and RE?
You can check out this mini-grader bash script made by marsenis. It is very easy to use.
Thank you, it actually helpful.
chpipis But, I use a brute-force solution to test, it returned Runtime Error instead of Time Limit Exceed :( Can you help me?
Hi, did you check if you actually had a Runtime Error (eg. allocating too much memory)?
Also, do you
return 0;
at the end ofmain()
? That may be a possible reason. I cannot think of anything else at the moment, it usually works smoothly for me.I had recheck but nothing wrong :( I have return 0;. Oh, I'm using MacOS High Sierra, what OS are you using?
Ubuntu 16.04 but I am not sure it has to do with the OS. Have you tried replacing the default G++ flags of the script by your own?
Yes, I add 2 flag to the default script? What wrong with it? I think the it also can depend on OS, because your C++ compiler can be g++ and my own is clang, is that true?
Oh yeah, you must be right. I have g++ so I cannot test this on my machine.
I use very simple script on python to run exe-file on many tests. It can be easily modified, hope it will help you. Link
I think your script can't check TLE and RE?
This script is not checking TLE and RE but I'm sure that you can find more information about
subprocess
and its return value or configuration at the official Python site.Thank you
The link is not working, Can you please update it?
Oh, I changed my GitHub login from VladimirPetrov to vovuh so you can just change this part of URL (here is the correct link)
change: p = subprocess.Popen(path, stdin=fin, stdout=fout)
to: p = subprocess.Popen(exepath, stdin=fin, stdout=fout)
But I do not know how to write a script (or a program with C++ or any language) to test my testcases.
LooOoLoOoooOoLoOooOoOoOoL. ROFL. LMAO. How have you been trying to learn "programming"? Have you written so much unreadable code to solve unrealistic problems that you cannot even write a simple program to solve a trivial problem?
You think it a simple trivial problem? Can you give me your code to test a testcases? Your code have to annouce all results such as accepts, time run, run time error or anything else like an online judge?
https://github.com/convict-git/.vimrc/blob/master/compile
It's a shell script. Save it as /usr/bin/compile Make a folder for every problem you solve. And save the inputs as input1, input2, .... and outputs as output1, output2, ... And whenever you want to run your code against these test cases,
compile [cppfile] [allowed run time]
eg. compile sol.cpp 1
Thank you! I will try it.
you can use polygon
I mean test locally. I have created problems on polygon, it only require input file and solution file to generate output. It doesn't check whether my solution is correct or not.
My bad, I read one of your comments above and for some reason thought you were testing it against a bruteforce solution, sorry.
Khủng
follow this tutorial by Errichto