3 Star 3 Fork 0

Gitee 极速下载 / go-restful

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/emicklei/go-restful
克隆/下载
mime_test.go 762 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ernest Micklei 提交于 2019-05-12 10:45 . fix issue #400, mime parse error
package restful
import (
"fmt"
"testing"
)
// go test -v -test.run TestSortMimes ...restful
func TestSortMimes(t *testing.T) {
accept := "text/html; q=0.8, text/plain, image/gif, */*; q=0.01, image/jpeg"
result := sortedMimes(accept)
got := fmt.Sprintf("%v", result)
want := "[{text/plain 1} {image/gif 1} {image/jpeg 1} {text/html 0.8} {*/* 0.01}]"
if got != want {
t.Errorf("bad sort order of mime types:%s", got)
}
}
func TestNonNumberQualityInAccept_issue400(t *testing.T) {
accept := `text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3`
result := sortedMimes(accept)
if got, want := len(result), 7; got != want {
t.Errorf("got %d want %d quality mimes", got, want)
}
}
Go
1
https://gitee.com/mirrors/go-restful.git
git@gitee.com:mirrors/go-restful.git
mirrors
go-restful
go-restful
v3

搜索帮助