mirror of https://github.com/golang/go.git
unicode/utf8: add AppendRune Example
Also, correct TestAppendRune error message. Change-Id: I3ca3ac7051af1ae6d449381b78efa86c2f6be8ac Reviewed-on: https://go-review.googlesource.com/c/go/+/354529 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Trust: Robert Findley <rfindley@google.com> Trust: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
fb8b1764d8
commit
75952abc6a
|
|
@ -214,3 +214,13 @@ func ExampleValidString() {
|
|||
// true
|
||||
// false
|
||||
}
|
||||
|
||||
func ExampleAppendRune() {
|
||||
buf1 := utf8.AppendRune(nil, 0x10000)
|
||||
buf2 := utf8.AppendRune([]byte("init"), 0x10000)
|
||||
fmt.Println(string(buf1))
|
||||
fmt.Println(string(buf2))
|
||||
// Output:
|
||||
// 𐀀
|
||||
// init𐀀
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ func TestAppendRune(t *testing.T) {
|
|||
t.Errorf("AppendRune(nil, %#04x) = %s, want %s", m.r, buf, m.str)
|
||||
}
|
||||
if buf := AppendRune([]byte("init"), m.r); string(buf) != "init"+m.str {
|
||||
t.Errorf("AppendRune(nil, %#04x) = %s, want %s", m.r, buf, "init"+m.str)
|
||||
t.Errorf("AppendRune(init, %#04x) = %s, want %s", m.r, buf, "init"+m.str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue