aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-06-17 09:17:33 -0700
committerKeith Randall <khr@golang.org>2014-06-17 09:17:33 -0700
commit2b309c6e225a908132ddf34316286ec0cdfdb98f (patch)
tree8d1d9a7f23a7c698aa2ec7ed01c921eb68e3f95d /src/pkg/runtime
parent63393faedf65b5b3719965cd4dead9a634be352f (diff)
downloadgo-2b309c6e225a908132ddf34316286ec0cdfdb98f.tar.xz
runtime: fix stringw test.
Null terminate string. Make it endian-agnostic. TBR=bradfitz R=golang-codereviews CC=golang-codereviews https://golang.org/cl/106060044
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/export_test.go2
-rw-r--r--src/pkg/runtime/string_test.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/pkg/runtime/export_test.go b/src/pkg/runtime/export_test.go
index 72d4e11086..4f29106c55 100644
--- a/src/pkg/runtime/export_test.go
+++ b/src/pkg/runtime/export_test.go
@@ -91,6 +91,6 @@ func gogoBytes() int32
var GogoBytes = gogoBytes
-func gostringW([]byte) string
+func gostringW([]uint16) string
var GostringW = gostringW
diff --git a/src/pkg/runtime/string_test.go b/src/pkg/runtime/string_test.go
index cd253b2349..9ed579235d 100644
--- a/src/pkg/runtime/string_test.go
+++ b/src/pkg/runtime/string_test.go
@@ -104,18 +104,18 @@ func BenchmarkRuneIterate2(b *testing.B) {
func TestStringW(t *testing.T) {
strings := []string{
"hello",
- //"a\u5566\u7788b",
+ "a\u5566\u7788b",
}
for _, s := range strings {
- var b []byte
+ var b []uint16
for _, c := range s {
- b = append(b, byte(c&255))
- b = append(b, byte(c>>8))
- if c>>16 != 0 {
+ b = append(b, uint16(c))
+ if c != rune(uint16(c)) {
t.Errorf("bad test: stringW can't handle >16 bit runes")
}
}
+ b = append(b, 0)
r := runtime.GostringW(b)
if r != s {
t.Errorf("gostringW(%v) = %s, want %s", b, r, s)