mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
2509c12e77
* 🚀 improve statusLine and StatusMessage by using slice instead of map Co-authored-by: Fenny <fenny@gofiber.io> Co-authored-by: ReneWerner87 <rene@gofiber.io> * for cli stuff * make invalidStatusLine() just return the formatted line * for ci stuff Co-authored-by: Fenny <fenny@gofiber.io> Co-authored-by: ReneWerner87 <rene@gofiber.io>
25 lines
742 B
Go
25 lines
742 B
Go
package fasthttp
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestStatusLine(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testStatusLine(t, -1, []byte("HTTP/1.1 -1 Unknown Status Code\r\n"))
|
|
testStatusLine(t, 99, []byte("HTTP/1.1 99 Unknown Status Code\r\n"))
|
|
testStatusLine(t, 200, []byte("HTTP/1.1 200 OK\r\n"))
|
|
testStatusLine(t, 512, []byte("HTTP/1.1 512 Unknown Status Code\r\n"))
|
|
testStatusLine(t, 512, []byte("HTTP/1.1 512 Unknown Status Code\r\n"))
|
|
testStatusLine(t, 520, []byte("HTTP/1.1 520 Unknown Status Code\r\n"))
|
|
}
|
|
|
|
func testStatusLine(t *testing.T, statusCode int, expected []byte) {
|
|
line := statusLine(statusCode)
|
|
if !bytes.Equal(expected, line) {
|
|
t.Fatalf("unexpected status line %s. Expecting %s", string(line), string(expected))
|
|
}
|
|
}
|