So let's say you messed up on a test case. That doesn't really say much.
There are two things you can do:
Method 1: Compare your output with the solution output
When you run
, it generates files in the following format:
is replaced with the number of the test case you just ran.
You can compare your output to the solution's output in 2 ways (there are more but let's keep it simple).
diff -y file1 file2
I'd recommend pairing this with
since your program's output may be larger than your terminal.
Preview (Note the third line is different):
vimdiff file1 file2
Vimdiff highlights the lines and characters that are different, so you'll instantly know what is different between your output and the solution executable's output.
Preview (Again, third line is different):
You can tell if X lines are the same via vimdiff if it says something like "190 lines: 255" and is gray like in the picture above.
Vimdiff is basically telling you "These lines are the same and it is pointless for me to print them".
To Quit Vimdiff, use
:qa (Quit All)
Method 2: See how the gradescript runs your program
This method varies per lab. The test cases can vary:
- The file is read in to the program via
- The file is read as command line arguments for the application
- The file is used in command line arguments for the program to read in via
Go in to the
directory (found via the path above) and then use
to view the test case files directly.
It should be obvious, when you get there, what files are used in test cases.
If your program uses command line arguments, the contents of the file may be command line arguments.
For instance, CS140's Bigwhite
executable for Lab 2 accepts input like this:
./bigwhite width height
The lab has a
directory that looks like this:
Opening 021.txt via
gives us this:
It's obvious, based on the input method above (The lab accepts 2 command line arguments) that this file specifies command line arguments.
Therefore, we can run the test ourselves without the gradescript:
./bigwhite 14 14
"Clara, what about those pgm files prior to 021.txt?"
Yes, the lab I used as an example has 5 executable files. Bigwhite
accepts command line arguments.
But the one before it (called pgminfo
) reads a PGM file in from
You know what this means? Those first 20 files are PGM files read directly in to your executable via
You can look at the files manually and see how it's structured.
Some files purposefully contain errors that you can probably catch via looking at it manually.