Note: A more detailed explanation can be found here on Codeforces
.
In competitive programming, stress testing is a technique of testing your solution on a number of random test cases to find where the code might fail.
Download this repository manually or by using git clone on terminal.
Copy your original solution which you expect might fail in the file solution.cpp
.
Copy your brute force solution which is expected to give correct output in the file brute.cpp
.
Change the gen.cpp
file so as to generate test cases according to the question.
Now open your terminal in the directory where file s.sh
resides and execute:
Once give the execute permissions to s.sh
file using:
$ sudo chmod +x s.sh
and then execute:
$ bash s.sh
to run the script.
bash s.sh
-> This will generate 10 (default) test cases and then check the program against it.
bash s.sh 100
-> This will generate 100 test cases and then check the program against it.
Output:
The output of running file s.sh
on every test case is either Accepted
if your solution's output matches the brute solution output or Wrong Answer
and will show the input on which the solution failed, the output of your solution and expected output according to the brute force solution on terminal and the script will be terminated. Now you can debug your original solution and check where it goes wrong.
If you wish to terminate the script at any moment you wish use the command ctrl + c
in your terminal.
Quick Demo: below the solution fails on randomly generated test #4: