aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/bufio/bufio_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/bufio/bufio_test.go')
-rw-r--r--libgo/go/bufio/bufio_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libgo/go/bufio/bufio_test.go b/libgo/go/bufio/bufio_test.go
index d7b34bd..ebcc711 100644
--- a/libgo/go/bufio/bufio_test.go
+++ b/libgo/go/bufio/bufio_test.go
@@ -534,6 +534,20 @@ func TestReadWriteRune(t *testing.T) {
}
}
+func TestWriteInvalidRune(t *testing.T) {
+ // Invalid runes, including negative ones, should be written as the
+ // replacement character.
+ for _, r := range []rune{-1, utf8.MaxRune + 1} {
+ var buf bytes.Buffer
+ w := NewWriter(&buf)
+ w.WriteRune(r)
+ w.Flush()
+ if s := buf.String(); s != "\uFFFD" {
+ t.Errorf("WriteRune(%d) wrote %q, not replacement character", r, s)
+ }
+ }
+}
+
func TestReadStringAllocs(t *testing.T) {
r := strings.NewReader(" foo foo 42 42 42 42 42 42 42 42 4.2 4.2 4.2 4.2\n")
buf := NewReader(r)