diff options
author | Russ Cox <rsc@golang.org> | 2010-02-25 15:11:07 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-02-25 15:11:07 -0800 |
commit | 35a9a25100101a4956eaeea9cc9d5ffc89f73a0a (patch) | |
tree | 1711df77712c4674453f3a5f66ee1c089dbe63d6 /test/string_lit.go | |
parent | 71055a66762713ccf33a48626514ed2dc7c2f5c5 (diff) | |
download | golang-35a9a25100101a4956eaeea9cc9d5ffc89f73a0a.tar.gz |
gc: implement []int(string) and []byte(string)
R=ken2
CC=golang-dev
http://codereview.appspot.com/224060
Diffstat (limited to 'test/string_lit.go')
-rw-r--r-- | test/string_lit.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/string_lit.go b/test/string_lit.go index 547be8003..88b5d251f 100644 --- a/test/string_lit.go +++ b/test/string_lit.go @@ -34,6 +34,19 @@ func assert(a, b, c string) { } } +const ( + gx1 = "aä本☺" + gx2 = "aä\xFF\xFF本☺" + gx2fix = "aä\uFFFD\uFFFD本☺" +) + +var ( + gr1 = []int(gx1) + gr2 = []int(gx2) + gb1 = []byte(gx1) + gb2 = []byte(gx2) +) + func main() { ecode = 0; s := @@ -86,5 +99,22 @@ func main() { r = 0x10ffff + 1; s = string(r); assert(s, "\xef\xbf\xbd", "too-large rune"); + + assert(string(gr1), gx1, "global ->[]int") + assert(string(gr2), gx2fix, "global invalid ->[]int") + assert(string(gb1), gx1, "->[]byte") + assert(string(gb2), gx2, "global invalid ->[]byte") + + var ( + r1 = []int(gx1) + r2 = []int(gx2) + b1 = []byte(gx1) + b2 = []byte(gx2) + ) + assert(string(r1), gx1, "->[]int") + assert(string(r2), gx2fix, "invalid ->[]int") + assert(string(b1), gx1, "->[]byte") + assert(string(b2), gx2, "invalid ->[]byte") + os.Exit(ecode); } |