mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/xml: make sure Encoder.Encode reports Write errors.
Fixes #4112. R=remyoudompheng, daniel.morsing, dave, rsc CC=golang-dev https://golang.org/cl/7085053
This commit is contained in:
parent
8eb80914ca
commit
afde71cfbd
4 changed files with 61 additions and 14 deletions
|
|
@ -689,3 +689,17 @@ func TestDirectivesWithComments(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Writer whose Write method always returns an error.
|
||||
type errWriter struct{}
|
||||
|
||||
func (errWriter) Write(p []byte) (n int, err error) { return 0, fmt.Errorf("unwritable") }
|
||||
|
||||
func TestEscapeTextIOErrors(t *testing.T) {
|
||||
expectErr := "unwritable"
|
||||
err := EscapeText(errWriter{}, []byte{'A'})
|
||||
|
||||
if err == nil || err.Error() != expectErr {
|
||||
t.Errorf("EscapeTest = [error] %v, want %v", err, expectErr)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue