mime_test.go 433 B

1234567891011121314151617
  1. package restful
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. // go test -v -test.run TestSortMimes ...restful
  7. func TestSortMimes(t *testing.T) {
  8. accept := "text/html; q=0.8, text/plain, image/gif, */*; q=0.01, image/jpeg"
  9. result := sortedMimes(accept)
  10. got := fmt.Sprintf("%v", result)
  11. want := "[{text/plain 1} {image/gif 1} {image/jpeg 1} {text/html 0.8} {*/* 0.01}]"
  12. if got != want {
  13. t.Errorf("bad sort order of mime types:%s", got)
  14. }
  15. }