GoConvey是一款优秀的Golang测试框架,可以快速优雅的开发Golang的测试用例,并且提供自动化的测试支持。
同时GoConvey框架提供了丰富的Assertions支持,其中ShouldPanic系列的Assertions提供了优雅的在测试用例中测试Golang panic的方法。
| uintmax_t parseHumanSize (const char* s) { | |
| char *endp = (char *)s; | |
| int sh; | |
| errno = 0; | |
| uintmax_t x = strtoumax(s, &endp, 10); | |
| if (errno || endp == s) { | |
| errno = EINVAL; | |
| goto ERROR; | |
| } |
| cue_file = 'file.cue' | |
| d = open(cue_file).read().splitlines() | |
| general = {} | |
| tracks = [] | |
| current_file = None |
| func NewGzipReader(source io.Reader) io.Reader { | |
| r, w := io.Pipe() | |
| go func() { | |
| defer w.Close() | |
| zip, err := gzip.NewWriterLevel(w, gzip.BestSpeed) | |
| defer zip.Close() | |
| if err != nil { | |
| w.CloseWithError(err) | |
| } |
| #!/bin/bash | |
| if [ -z $1 ]; then | |
| FILTER='Name=instance-state-code,Values=16' | |
| else | |
| FILTER=$1 | |
| fi | |
| IDs=`aws ec2 describe-instances --filters "$FILTER" | jq '.Reservations[].Instances[].InstanceId' -r` |
| #!/bin/sh | |
| yum update -y | |
| yum --enablerepo=epel install jq bash-completion -y | |
| cat <<EOT >> /etc/profile.d/aws-cli.sh | |
| if [ $SHELL = "/bin/bash" ]; then | |
| complete -C '/usr/bin/aws_completer' aws | |
| fi |
| // Based on whitelist v1.2 by https://github.com/n0wa11 | |
| function FindProxyForURL(url, host) { | |
| var PROXY = 'SOCKS 127.0.0.1:1983'; | |
| if (isPlainHostName(host)) return 'DIRECT'; | |
| if (/^\d+\.\d+\.\d+\.\d+$/g.test(host)) return 'DIRECT'; | |
| var rules = [ | |
| [ | |
| 'cn', | |
| 'lan', |
| // Based on whitelist v1.2 by https://github.com/n0wa11 | |
| function FindProxyForURL(url, host) { | |
| var PROXY = 'SOCKS 127.0.0.1:1983'; | |
| if (isPlainHostName(host)) return 'DIRECT'; | |
| if (/^\d+\.\d+\.\d+\.\d+$/g.test(host)) return 'DIRECT'; | |
| var rules = [ | |
| [ | |
| 'cn', | |
| 'lan', |
| func readLines(path string) ([]string, error) { | |
| file, err := os.Open(path) | |
| if err != nil { | |
| return nil, err | |
| } | |
| defer file.Close() | |
| var lines []string | |
| scanner := bufio.NewScanner(file) | |
| for scanner.Scan() { |
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "time" | |
| ) | |
| // The custom time format for json | |
| type MyTime time.Time |
GoConvey是一款优秀的Golang测试框架,可以快速优雅的开发Golang的测试用例,并且提供自动化的测试支持。
同时GoConvey框架提供了丰富的Assertions支持,其中ShouldPanic系列的Assertions提供了优雅的在测试用例中测试Golang panic的方法。