Commit 7ccf049a authored by JessonChan's avatar JessonChan

bug fixed

parent 7964f7f1
......@@ -14,29 +14,32 @@
package acceptencoder
import "testing"
import (
"net/http"
"testing"
)
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()
}
if parseEncoding("deflate,gzip") != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate,gzip"}}}) != "deflate" {
t.Fail()
}
if parseEncoding("gzip;q=.5,deflate") != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate"}}}) != "deflate" {
t.Fail()
}
if parseEncoding("gzip;q=0,deflate") != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
t.Fail()
}
if parseEncoding("deflate;q=0.5,gzip;q=0.5,identity") != "" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=0,deflate"}}}) != "deflate" {
t.Fail()
}
if parseEncoding("*") != "gzip" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "identity" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"*"}}}) != "*" {
t.Fail()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment