Mini Judge is a lightweight program designed to test the correctness of a compiled executable (a.out or a.exe) against a set of predefined test cases. This program works on both Windows and Linux/Ubuntu platforms.
- Executes a compiled C++ program (
a.outora.exe) with input files. - Compares the output with the expected results stored in
.ansfiles. - Supports test case organization for easy management.
- Python 3.x: Ensure Python is installed and added to your system's PATH.
- C++ Compiler: To compile your C++ program:
- On Linux/Ubuntu: Use g++ or clang++.
- On Windows: Use MinGW or Visual Studio.
The program expects the following folder structure:
mini-judge/
├── judge.py # Main Python script to run the tests
├── a.out # Compiled C++ program (output) maybe a.exe
├── tc/ # Test case folder
│ ├── a/ # Test case subfolder (e.g., "a" is the problem name)
│ │ ├── 1.in # Input file for test case 1
│ │ ├── 1.ans # Expected output for test case 1
│ │ ├── 2.in # Input file for test case 2
│ │ ├── 2.ans # Expected output for test case 2
│ └── ... # Additional problem folders (b/, c/, etc.)Test Case Structure
Each test case should have:
Input file (.in): Contains the input data for the test case.
Answer file (.ans): Contains the expected output.
For example:
1.in:5 10
1.ans:15
Compile your C++ program into an executable file
g++ a.cppRun the judge.py script and specify the problem name (e.g., a):
python judge.py ahint: maybe you should use python3 instead python.
The script will:
- Look for test cases in
tc/a/. - Run the executable (
a.outora.exe) for each.infile. - Compare the program's output with the corresponding
.ansfile. - Print whether each test case passed or failed.
The script automatically detects the operating system and selects a.out (Linux/Ubuntu) or a.exe (Windows).
Ensure the a.out or a.exe executable is in the same directory as judge.py.
- Executable not found: Ensure
a.outora.exeis in the correct directory. - Mismatched outputs: Verify your program logic and ensure
.ansfiles are correct. - File naming issues: Ensure .in and
.ansfile names match the required format (e.g.,1.inand1.ans).
This project is licensed under the MIT License.
Looking for a more complex and feature-rich version of this project? check this repo +