Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueueInput ¶
func QueueInput(newline bool)
Signal the stdin pipe to queue the next input. Should be called right before reading from stdin.
Optionally print a newline to stdout to mimic pressing enter in a terminal.
Note: if the pipe is not open, this function does nothing.
Types ¶
type StdinPipe ¶
type StdinPipe struct {
// contains filtered or unexported fields
}
StdinPipe is a test helper for inputting stdin. The primary use case is to submit program input typically collected from the console.
func OpenStdinPipe ¶
Create a new StdinPipe. After calling, stdin will read input from the pipe until Close is called.
'bufSize' defines the size of the input buffer. Ensure the size is large enough to prevent stalling.
type StdoutPipe ¶
type StdoutPipe struct {
// contains filtered or unexported fields
}
StdoutPipe is a test helper for capturing stdout. The primary use case is to test program output typically printed to the console.
func OpenStdoutPipe ¶
func OpenStdoutPipe() StdoutPipe
Create a new StdoutPipe. After calling, stdout will write output to the pipe until Close is called.
func (StdoutPipe) Close ¶
func (p StdoutPipe) Close()
Close the pipe and restore stdout. The pipe can no longer be written to or read from.
func (StdoutPipe) ReadLine ¶
func (p StdoutPipe) ReadLine() string
Read from the pipe until a newline is encountered.
If there are no more newlines in the pipe, the program stalls until one is written.
func (StdoutPipe) ReadLines ¶
func (p StdoutPipe) ReadLines(n int) []string
Read 'n' lines from the pipe and return as a slice. Lines are separated by the newline character.
If there are no more newlines in the pipe, the program stalls until one is written.