modulepackage
0.6.0
Repository: https://github.com/king133134/leetcodetests.git
Documentation: pkg.go.dev
# README
自动生成LeetCode Go单元测试用例
用于基于 LeetCode 提供的示例自动生成单元测试用例。该工具目前并不能百分之百地支持所有题目,支持绝大部分数据类型但是不太普遍或没有返回值的问题无法自动生成单元测试。
功能
- 基于 LeetCode 提供的示例自动生成 Go 单元测试用例
- 能够自动生成超过 98% 的 LeetCode 题目的单元测试用例
- 不能生成的题目包括环形单向链表和双向链表等
使用方法
- 快速安装
go get github.com/king133134/leetcodeTests
- 进入 leetCodeTests 文件夹
- 有两种方式来生成测试用例,只需要提供题目的URL无论是.cn还是.com都支持
- 直接生成代码文件(推荐使用),下面命令就会在当前./tests目录生成对应的题目URL的单元测试用例
会提示你输入URL,如下图:go run example/main.go -mod=file -dir=./tests
- 通过网页表单表单交互生成
然后打开网址http://localhost:8080/index,输入题目URL即可go run example/main.go -mod=http -port=8080
- 直接生成代码文件(推荐使用),下面命令就会在当前./tests目录生成对应的题目URL的单元测试用例
- 可以使用以下自定义方式
- 直接通过给URL和指定生成文件目录
package main import "github.com/king133134/leetCodeTests" func main() { leetcodeTests.CreatByUrl("./tests", "https: //leetcode.cn/problems/brace-expansion-ii/") }
- 通过网页交互的方式,然后打开网址http://localhost:8080/index,输入题目URL即可
package main import "github.com/king133134/leetCodeTests" func main() { leetcodeTests.HttpStart(8080) }
- 直接通过给URL和指定生成文件目录
LICENSE
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HttpStart 用于创建HTTP服务器并启动它。它会将HTML模板加载到gin中,并注册两个处理函数Index和Question。.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author