### 20170104's blog

By 20170104, history, 16 months ago, ,

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.

• +12

 » 16 months ago, # |   0 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.
•  » » 16 months ago, # ^ |   0 How can you check TLE and RE?
 » 16 months ago, # |   +12 You can check out this mini-grader bash script made by marsenis. It is very easy to use.
•  » » 16 months ago, # ^ |   0 Thank you, it actually helpful.
•  » » 16 months ago, # ^ | ← Rev. 2 →   0 chpipis But, I use a brute-force solution to test, it returned Runtime Error instead of Time Limit Exceed :( Can you help me?
•  » » » 16 months ago, # ^ |   +8 Hi, did you check if you actually had a Runtime Error (eg. allocating too much memory)?Also, do you return 0; at the end of main()? That may be a possible reason. I cannot think of anything else at the moment, it usually works smoothly for me.
•  » » » » 16 months ago, # ^ |   0 I had recheck but nothing wrong :( I have return 0;. Oh, I'm using MacOS High Sierra, what OS are you using?
•  » » » » » 16 months ago, # ^ |   +8 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?
•  » » » » » » 16 months ago, # ^ |   +8 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?
•  » » » » » » » 16 months ago, # ^ |   +8 Oh yeah, you must be right. I have g++ so I cannot test this on my machine.
 » 16 months ago, # |   +5 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
•  » » 16 months ago, # ^ |   0 I think your script can't check TLE and RE?
•  » » » 16 months ago, # ^ |   +3 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.
•  » » » » 16 months ago, # ^ |   0 Thank you
•  » » 6 weeks ago, # ^ |   0 The link is not working, Can you please update it?
•  » » » 6 weeks ago, # ^ |   +3 Oh, I changed my GitHub login from VladimirPetrov to vovuh so you can just change this part of URL (here is the correct link)
 » 16 months ago, # |   -37 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?
•  » » 16 months ago, # ^ |   +10 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?
 » 16 months ago, # |   +3 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
•  » » 16 months ago, # ^ |   0 Thank you! I will try it.
 » 16 months ago, # |   0 you can use polygon
•  » » 16 months ago, # ^ |   0 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.
•  » » » 16 months ago, # ^ |   0 My bad, I read one of your comments above and for some reason thought you were testing it against a bruteforce solution, sorry.
 » 16 months ago, # |   0 Khủng
 » 6 weeks ago, # | ← Rev. 2 →   +1