File: status_test.go

package info (click to toggle)
golang-github-valyala-fasthttp 1%3A1.59.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,932 kB
  • sloc: makefile: 34
file content (24 lines) | stat: -rw-r--r-- 796 bytes parent folder | download
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))
	}
}