aboutsummaryrefslogtreecommitdiff
path: root/test/string_lit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-02-25 15:11:07 -0800
committerRuss Cox <rsc@golang.org>2010-02-25 15:11:07 -0800
commit3910161307f79fd821148652fb2a77872e7efd52 (patch)
treeed1675a302b1008c7a13de6f750f25e73a3b8d9a /test/string_lit.go
parentb86c0b0c4a69aaca1bd748fb2969f90cb2a28310 (diff)
downloadgo-3910161307f79fd821148652fb2a77872e7efd52.tar.gz
go-3910161307f79fd821148652fb2a77872e7efd52.zip
gc: implement []int(string) and []byte(string)
R=ken2 CC=golang-dev https://golang.org/cl/224060
Diffstat (limited to 'test/string_lit.go')
-rw-r--r--test/string_lit.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/string_lit.go b/test/string_lit.go
index 547be8003a..88b5d251ff 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);
}