TZTester is one of a great plugin for TopCoder SRM. It adds sample test cases of problem statements into the local code automatically (which is generated by CodeProcessor plugin, normally). This function encourages us to write the code as test-first, this is quite helpful to find bugs and fix it quickly. How to introduce these plugins is described here:
How to install The Arena plug-ins – TopCoder Wiki
However, I had little two dissatisfaction about generated test cases of TZTester.
- There are no enough new lines in test cases. This makes little hard to add new own test cases.
- I’d like to put more two cases into the tail of test cases. This intends that it enforce me to think about another tests for considering corner cases or worst cases.
So I’ve tried to modify my TZTester.
How to modify
TZTester is written in Java. I’ve had a little experience for java development. So I’ve confused several times for modification. Because of this, this section is maybe so dully for java programmer.
Step 1: Extract .jar file
TZTester is distributed as .jar file format. “.jar” file is just a zip file. I don’t know about the difference between jar and zip. So don’t be afraid.If Java development environment has been set up on your system, perhaps there are “jar” command. In my case (Mac OSX), the command seems to be bundled. You can extract and compress jar file by this command. The interface of jar command is quite similar to tar command:
// extracting
% jar -xvf foo.jar
// compressing
% jar -cvf foo.jar foo bar baz/
If you don’t have a jar command, try unzip command since jar file is just a zip file, again.Now let’s extract a TZTester.jar. If you type this command:
Then you will get these files:
- tangentz/
- TZTester.java
- TZTester.class
- TZTester.html
- META-INF/
The only important file is TZTester.java. This is a source code of TZTester. TZTester.class is a compiled file of TZTester.java, and TZTester.html is just a manual file.
Step 2: Editting TZTester.java
Now we could get a source code of TZTester. So only you have to do is editing this code. For instance, you’d like to modify test cases, these are generated by generate_test_case() or generate_parameter() method.
Step 3: Compiling TZTester.java, and make TZTester.jar
Before compiling, TZTester requires ContestApplet.jar file, so you need to get this jar. ContestApplet.jar could be downloaded from here. And then put the downloaded ContestApplet.jar file to same directory with tangentz/. ContestApplet.jar contains classes, which is used by TZTester. Also you need to pay attention to the directories, put the source code in tangetz/ directory, ContestApplet.jar and Makefile (describe later) in same directory with tangentz/ itself.
your_working_dir/
| -- ContestApplet.jar
| -- Makefile
` -- tangentz/
|-- TZTester.java
`-- (TZTester.class)
For compiling, firstly just type this commands in “your_working_dir”:
% javac -classpath ContestApplet.jar tangentz/TZTester.java
Then TZTester.class is generated. Next step, make jar file from .class file.
% jar cvf TZTester.jar tangentz/TZTester.class
It’s convenient to make such Makefile and put it in “yoru_working_dir”:
jar: class
jar cvf TZTester.jar tangentz/TZTester.class
class:
javac -classpath ContestApplet.jar tangentz/TZTester.java
The final step is just replacing your existing TZTester.jar by this new modified one.
My modification
I’ve pushed my TZTester.java code to my github repository.
plugin/modify_TZTester/build/tangentz/TZTester.java at master from cou929’s topcoder – GitHub
I’ve modified these two points.
* Add new lines to test cases. Append “ ” to argument of Code.appen() in generate_test_code(), generate_test_case() and generate_parameter()
* Append additional two test cases which contents are same to test case #0. Call generate_test_case() method two times more.
Other modifications
There are another modifications. Petr displays his TZTester:
Algorithm problems for dummies: Petr Mitrichev’s blog: Screencast and challenging
The TZTester.jar file itself is here. This is modified for C# code generation.
cafelier also shows his modification (in Japanese).
TZTester をどうにかする – cafelier@SRM – TopCoder部
The zipped file itself is here. He did a lot of changes such as put the test codes in global, measure processing time and so on.