diff options
Diffstat (limited to 'libgo/go/bytes/buffer_test.go')
-rw-r--r-- | libgo/go/bytes/buffer_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libgo/go/bytes/buffer_test.go b/libgo/go/bytes/buffer_test.go index fec5ef8..9c9b744 100644 --- a/libgo/go/bytes/buffer_test.go +++ b/libgo/go/bytes/buffer_test.go @@ -6,6 +6,7 @@ package bytes_test import ( . "bytes" + "fmt" "io" "math/rand" "testing" @@ -387,6 +388,16 @@ func TestRuneIO(t *testing.T) { } } +func TestWriteInvalidRune(t *testing.T) { + // Invalid runes, including negative ones, should be written as + // utf8.RuneError. + for _, r := range []rune{-1, utf8.MaxRune + 1} { + var buf Buffer + buf.WriteRune(r) + check(t, fmt.Sprintf("TestWriteInvalidRune (%d)", r), &buf, "\uFFFD") + } +} + func TestNext(t *testing.T) { b := []byte{0, 1, 2, 3, 4} tmp := make([]byte, 5) |