1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 16:20:49 +00:00

bug fixed

This commit is contained in:
JessonChan 2015-11-10 13:27:33 +08:00
parent 7964f7f163
commit 7ccf049a50

View File

@ -14,29 +14,32 @@
package acceptencoder package acceptencoder
import "testing" import (
"net/http"
"testing"
)
func Test_ExtractEncoding(t *testing.T) { func Test_ExtractEncoding(t *testing.T) {
if parseEncoding("gzip,deflate") != "gzip" { if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip,deflate"}}}) != "gzip" {
t.Fail() t.Fail()
} }
if parseEncoding("deflate,gzip") != "deflate" { if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate,gzip"}}}) != "deflate" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate"}}}) != "deflate" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
t.Fail() t.Fail()
} }
if parseEncoding("gzip;q=.5,deflate") != "deflate" { if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=0,deflate"}}}) != "deflate" {
t.Fail() t.Fail()
} }
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "identity" {
if parseEncoding("gzip;q=0,deflate") != "deflate" {
t.Fail() t.Fail()
} }
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"*"}}}) != "*" {
if parseEncoding("deflate;q=0.5,gzip;q=0.5,identity") != "" {
t.Fail()
}
if parseEncoding("*") != "gzip" {
t.Fail() t.Fail()
} }
} }