blob: 9c2a70aa39b13aead6fd4c1bb31a3db774f476d8 [file] [log] [blame] [edit]
# Tests that crlf in the output of examples are handled.
# Verifies golang.org/issue/51269
go test x_test.go
-- x_test.go --
package x
import (
"io"
"fmt"
"os"
"runtime"
)
func Example_lf() {
fmt.Print("foo", "\n", "bar")
// Output:
// foo
// bar
}
func Example_println() {
fmt.Println("foo")
fmt.Println("bar")
// Output:
// foo
// bar
}
func Example_crlf() {
if runtime.GOOS == "windows" {
io.WriteString(os.Stdout, "foo\r\nbar\r\n")
} else {
io.WriteString(os.Stdout, "foo\nbar\n")
}
// Output:
// foo
// bar
}