logtesting

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C struct {
	// contains filtered or unexported fields
}

func Capture

func Capture(t *testing.T) *C
Example
var stdout, stderr *os.File = os.Stdout, os.Stderr

var (
	t = &testing.T{}
	c = Capture(t)
)

fmt.Fprintln(os.Stdout, "foo")
fmt.Fprintln(os.Stderr, "bar")
fmt.Fprintln(os.Stderr, "baz")

fmt.Fprintf(stdout, "stdout swapped: %t\n", stdout != os.Stdout)
fmt.Fprintf(stdout, "stderr swapped: %t\n", stderr != os.Stderr)
fmt.Fprintf(stdout, "stdout: "+c.Stdout(t))
fmt.Fprintf(stdout, "stderr: "+c.Stderr(t))
Output:

stdout swapped: true
stderr swapped: true
stdout: foo
stderr: bar
baz

func (*C) Stderr

func (c *C) Stderr(t *testing.T) string

func (*C) Stdout

func (c *C) Stdout(t *testing.T) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL