mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
25 lines
469 B
Go
25 lines
469 B
Go
package fasthttp
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewStreamReader(t *testing.T) {
|
|
r := NewStreamReader(func(w *bufio.Writer) {
|
|
fmt.Fprintf(w, "Hello, world\n")
|
|
fmt.Fprintf(w, "Line #2\n")
|
|
})
|
|
|
|
data, err := ioutil.ReadAll(r)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %s", err)
|
|
}
|
|
expectedData := "Hello, world\nLine #2\n"
|
|
if string(data) != expectedData {
|
|
t.Fatalf("unexpected data %q. Expecting %q", data, expectedData)
|
|
}
|
|
}
|