Merge from trunk
[official-gcc.git] / gcc / testsuite / go.test / test / fixedbugs / issue5704.go
blob1dfa072143e76c1f0b9bac7c0b1734fb20c7ca5a
1 // run
3 // Copyright 2012 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Issue 5704: Conversions of empty strings to byte
8 // or rune slices return empty but non-nil slices.
10 package main
12 type (
13 mystring string
14 mybytes []byte
15 myrunes []rune
18 func checkBytes(s []byte, arg string) {
19 if len(s) != 0 {
20 panic("len(" + arg + ") != 0")
22 if s == nil {
23 panic(arg + " == nil")
27 func checkRunes(s []rune, arg string) {
28 if len(s) != 0 {
29 panic("len(" + arg + ") != 0")
31 if s == nil {
32 panic(arg + " == nil")
36 func main() {
37 checkBytes([]byte(""), `[]byte("")`)
38 checkBytes([]byte(mystring("")), `[]byte(mystring(""))`)
39 checkBytes(mybytes(""), `mybytes("")`)
40 checkBytes(mybytes(mystring("")), `mybytes(mystring(""))`)
42 checkRunes([]rune(""), `[]rune("")`)
43 checkRunes([]rune(mystring("")), `[]rune(mystring(""))`)
44 checkRunes(myrunes(""), `myrunes("")`)
45 checkRunes(myrunes(mystring("")), `myrunes(mystring(""))`)