mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Added a test for bufferStartEnd
This commit is contained in:
@@ -10,6 +10,35 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBufferStartEnd(t *testing.T) {
|
||||
testBufferStartEnd(t, "", "", "")
|
||||
testBufferStartEnd(t, "foobar", "foobar", "")
|
||||
|
||||
b := string(createFixedBody(199))
|
||||
testBufferStartEnd(t, b, b, "")
|
||||
for i := 0; i < 10; i++ {
|
||||
b += "foobar"
|
||||
testBufferStartEnd(t, b, b, "")
|
||||
}
|
||||
|
||||
b = string(createFixedBody(400))
|
||||
testBufferStartEnd(t, b, b, "")
|
||||
for i := 0; i < 10; i++ {
|
||||
b += "sadfqwer"
|
||||
testBufferStartEnd(t, b, b[:200], b[len(b)-200:])
|
||||
}
|
||||
}
|
||||
|
||||
func testBufferStartEnd(t *testing.T, buf, expectedStart, expectedEnd string) {
|
||||
start, end := bufferStartEnd([]byte(buf))
|
||||
if string(start) != expectedStart {
|
||||
t.Fatalf("unexpected start %q. Expecting %q. buf %q", start, expectedStart, buf)
|
||||
}
|
||||
if string(end) != expectedEnd {
|
||||
t.Fatalf("unexpected end %q. Expecting %q. buf %q", end, expectedEnd, buf)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderTrailingCRLFSuccess(t *testing.T) {
|
||||
trailingCRLF := "\r\n\r\n\r\n"
|
||||
s := "HTTP/1.1 200 OK\r\nContent-Type: aa\r\nContent-Length: 123\r\n\r\n" + trailingCRLF
|
||||
|
||||
Reference in New Issue
Block a user