diff options
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) + } + } +} |
