A simple command-line tool to test your C++ competitive programming solutions against sample test cases.
-
Clone this repository:
git clone <your-repo-url> cd pj-programs
-
Install Python requirements:
pip install -r requirements.txt
-
Test your C++ solution:
python3 cp_tester.py your_solution.cpp
-
Run the tester with your C++ file:
python3 cp_tester.py solution.cpp
-
Enter your test cases when prompted:
- Input the sample input (finish with
END) - Input the expected output (finish with
END) - Repeat for more test cases
- Input the sample input (finish with
-
The tester will:
- Compile your C++ code with g++
- Run each test case
- Show PASS/FAIL results
- Display diffs for failed tests
$ python3 cp_tester.py sample_solution.cpp
Enter sample INPUT for test case #1:
5
1 2 3 4 5
END
Enter expected OUTPUT for test case #1:
15
END
Add another test case? [y/N]: n
Enter the path to your .cpp file: sample_solution.cpp
Test #1: PASS
Passed 1/1 test cases.- Python 3.6+
- g++ compiler
- See
requirements.txtfor Python dependencies
Check out sample_solution.cpp for a working example you can test!