From 0f4b53c1c2db3ae7f3ed25ba7e5149baf14fc46c Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 17 Jun 2014 00:36:23 -0700 Subject: 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 --- src/pkg/runtime/string_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/pkg/runtime/string_test.go') diff --git a/src/pkg/runtime/string_test.go b/src/pkg/runtime/string_test.go index dbccc24a5b..28a5c6bd1e 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 BenchmarkRuneIterate2(b *testing.B) { } } } + +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) + } + } +} -- cgit v1.3-5-g9baa