-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
status_test.go
24 lines (20 loc) · 796 Bytes
/
status_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 := formatStatusLine(nil, strHTTP11, statusCode, s2b(StatusMessage(statusCode)))
if !bytes.Equal(expected, line) {
t.Fatalf("unexpected status line %q. Expecting %q", string(line), string(expected))
}
}