diff options
| author | Keith Randall <khr@golang.org> | 2014-06-17 00:36:23 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2014-06-17 00:36:23 -0700 |
| commit | 0f4b53c1c2db3ae7f3ed25ba7e5149baf14fc46c (patch) | |
| tree | 41042f48f85f1a5038404c7a2980619737fe0743 /src/pkg/runtime/string_test.go | |
| parent | ee8e687874b56f7c3ab1dd5585390b84dc74b14e (diff) | |
| download | go-0f4b53c1c2db3ae7f3ed25ba7e5149baf14fc46c.tar.xz | |
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
Diffstat (limited to 'src/pkg/runtime/string_test.go')
| -rw-r--r-- | src/pkg/runtime/string_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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) + } + } +} |
