用于媒体编辑的命令行工具
code-tester的Python项目详细描述
代码测试仪
code_tester是一个命令行代码测试工具,用于根据朋友/暴力代码测试代码。
安装
从源代码生成
git clone https://github.com/srbcheema1/code_tester
cd code_tester
python3 setup.py install --user
使用pip安装
linux和mac用户
python3 -m pip install --user code_tester
git clone https://github.com/srbcheema1/code_tester
cd code_tester
python3 setup.py install --user
linux和mac用户
python3 -m pip install --user code_tester
python3 -m pip install --user code_tester
别忘了~/.local/bin
应该在你的PATH
中。在~/.bashrc
中添加export PATH=$PATH:"~/.local/bin"
行
windows用户
对于Windows用户,应在系统中安装python3
python3 -m pip install --user code_tester
使用量
srb@srb-pc:$ code_tester --help
usage: code_tester [-h] [-f FILE] [-o OTHER] [-t TEST] [-i ID] [-n NUM]
[-s SEC] [-c]
[legacy [legacy ...]]
positional arguments:
legacy legacy way of args
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE Input file name, ex: one.cpp
-o OTHER, --other OTHER
Other input file name, ex: brute.cpp
-t TEST, --test TEST Test generator, ex: testgen.py
-i ID, --id ID Unique_id, ex: 111
-n NUM, --num NUM Maximum number of test cases, ex: 1000
-s SEC, --sec SEC Maximum time in seconds for a test file, ex: 4
-c, --clean Clean the files generated by tester
参数--test
可以包含输出testcase或自定义testcasetxt
文件的testcase生成器。
srb@srb-pc:$ code_tester -f one.cpp -o brute_one.cpp -t testgen.py -n 500
tested 100
tested 200
tested 300
tested 400
tested 500
passed 500 testcases
srb@srb-pc:$ code_tester wrong.cpp brute.cpp testgen.py
Difference detected in outputs
---------Failed Test Case----------
10 11 4
1 0 0 0 0 0 0 1 1 1
!?!!?!?!!!!
---------End of Test Case----------
first difference in line 3
+---+-----------+-----------+
| # | wrong.cpp | brute.cpp |
+---+-----------+-----------+
| 1 | 2 | 2 |
| 2 | 4 | 4 |
| 3 | 3 | 4 |
+---+-----------+-----------+
足够聪明
- 聪明到足以检测到
1
与1.0
相同 - 能够检测并忽略小于1e-6的浮点值差异
- 能够忽略尾随空格
srb@srb-pc:$ code_tester wrong.cpp brute.cpp testgen.py
Difference detected in outputs
---------Failed Test Case----------
10
5 1
13 9
15 2
11 10
16 2
18 9
17 16
13 2
16 16
19 16
---------End of Test Case----------
first difference in line 8
+----+-------------+-----------+
| # | wrong.cpp | brute.cpp |
+----+-------------+-----------+
| 1 | 0.33333333 | 0.3333333 | ignore percision differences smaller than 1e-6
| 2 | 1.00000000 | 1 | it will detect values are same in 1.0, 1.000 and 1
| 3 | 0.25000000 | 0.2500000 |
| 4 | 1.00000000 | 1 |
| 5 | 0.25000000 | 0.2500000 |
| 6 | 1.00000000 | 1 |
| 7 | 0.14285714 | 0.1428571 | this line is not marked as diff(smart to detect negligible change)
| 8 | 0.33333333 | 0.2500000 | this one is 7th line which actually differs
| 9 | 1.00000000 | 1 |
| 10 | 1.00000000 | 1 |
+----+-------------+-----------+
支持的语言
- c++
- C
- Python3
- Java
- 红宝石
联系人/社交媒体
由
开发开发人员/作者:Srb Cheema