MCPcopy
hub / github.com/segmentio/kafka-go / testConnReadShortBuffer

Function testConnReadShortBuffer

conn_test.go:985–1009  ·  view source on GitHub ↗
(t *testing.T, conn *Conn)

Source from the content-addressed store, hash-verified

983}
984
985func testConnReadShortBuffer(t *testing.T, conn *Conn) {
986 if _, err := conn.Write([]byte("Hello World!")); err != nil {
987 t.Fatal(err)
988 }
989
990 b := make([]byte, 4)
991
992 for i := 0; i != 10; i++ {
993 b[0] = 0
994 b[1] = 0
995 b[2] = 0
996 b[3] = 0
997
998 n, err := conn.Read(b)
999 if !errors.Is(err, io.ErrShortBuffer) {
1000 t.Error("bad error:", i, err)
1001 }
1002 if n != 4 {
1003 t.Error("bad byte count:", i, n)
1004 }
1005 if s := string(b); s != "Hell" {
1006 t.Error("bad content:", i, s)
1007 }
1008 }
1009}
1010
1011func testConnReadEmptyWithDeadline(t *testing.T, conn *Conn) {
1012 b := make([]byte, 100)

Callers

nothing calls this directly

Calls 3

WriteMethod · 0.45
ReadMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected