-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing: replace CRLF by LF on windows before comparing to the expect…
…ed output Fixes #51269 Change-Id: I06747db18ca078c1f1bda9b7bc60006f53191f4d Reviewed-on: https://go-review.googlesource.com/c/go/+/627035 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters