用于媒体编辑的命令行工具

code-tester的Python项目详细描述


代码测试仪

contributions welcomeOpen Source LoveBuild StatusHitCount

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

别忘了~/.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         |
+---+-----------+-----------+

足够聪明

  • 聪明到足以检测到11.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
  • 红宝石

联系人/社交媒体

GithubLinkedInFacebook

开发

开发人员/作者:Srb Cheema

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Thumbnailator库将图像转换为cmyk   Java反射从目录中的类运行测试   JavaEclipseJDT编译器说方法未定义,但EclipseIDE没有   重构如何重构一行重复的java代码   java Eclipse:使用删除线文本呈现自定义注释   java问题与ArrayList复制数据   java如何在swagger中传递访问令牌?   使用另一个java文件运行java文件时出错   java为什么谷歌云存储生成的上传链接在成功上传后不会失效?   java将我的客户端PC重定向到默认登录页面   java hibernate c3p0配置mysql问题   java和java之间的区别。尼奥。文件文件和java。伊奥。文件   列出java循环并向映射中添加值   java为什么OJ报告这段代码的运行时错误?