runtime: reconstitute runetochar for use by gostringw.
Fixes windows builds (hopefully).
LGTM=bradfitz
R=golang-codereviews, bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/103470045
diff --git a/src/pkg/runtime/string_test.go b/src/pkg/runtime/string_test.go
index dbccc24..28a5c6b 100644
--- a/src/pkg/runtime/string_test.go
+++ b/src/pkg/runtime/string_test.go
@@ -5,6 +5,7 @@
package runtime_test
import (
+ "runtime"
"testing"
)
@@ -99,3 +100,25 @@
}
}
}
+
+func TestStringW(t *testing.T) {
+ strings := []string{
+ "hello",
+ "a\u5566\u7788\b",
+ }
+
+ for _, s := range strings {
+ var b []byte
+ for _, c := range s {
+ b = append(b, byte(c&255))
+ b = append(b, byte(c>>8))
+ if c>>16 != 0 {
+ t.Errorf("bad test: stringW can't handle >16 bit runes")
+ }
+ }
+ r := runtime.GostringW(b)
+ if r != s {
+ t.Errorf("gostringW(%v) = %s, want %s", b, r, s)
+ }
+ }
+}