+ pipeOut.Write([]byte("before\n"))
+
+ for i := range sentBytes {
+ // Some bytes that aren't newlines:
+ sentBytes[i] = byte((rand.Int() & 0xff) | 0x80)
+ }
+ sentBytes[len(sentBytes)-1] = '\n'
+ pipeOut.Write(sentBytes)
+
+ pipeOut.Write([]byte("after"))
+ pipeOut.Close()
+ }()
+
+ if before, err := rcv.ReadBytes('\n'); err != nil || string(before) != "before\n" {
+ t.Fatalf("\"before\n\" not received (got \"%s\", %s)", before, err)
+ }
+
+ var receivedBytes []byte
+ done := false
+ for !done {
+ line, err := rcv.ReadBytes('\n')