1
2
3
4
5
6
7
8
9
10 package main
11
12 type (
13 mystring string
14 mybytes []byte
15 myrunes []rune
16 )
17
18 func checkBytes(s []byte, arg string) {
19 if len(s) != 0 {
20 panic("len(" + arg + ") != 0")
21 }
22 if s == nil {
23 panic(arg + " == nil")
24 }
25 }
26
27 func checkRunes(s []rune, arg string) {
28 if len(s) != 0 {
29 panic("len(" + arg + ") != 0")
30 }
31 if s == nil {
32 panic(arg + " == nil")
33 }
34 }
35
36 func main() {
37 checkBytes([]byte(""), `[]byte("")`)
38 checkBytes([]byte(mystring("")), `[]byte(mystring(""))`)
39 checkBytes(mybytes(""), `mybytes("")`)
40 checkBytes(mybytes(mystring("")), `mybytes(mystring(""))`)
41
42 checkRunes([]rune(""), `[]rune("")`)
43 checkRunes([]rune(mystring("")), `[]rune(mystring(""))`)
44 checkRunes(myrunes(""), `myrunes("")`)
45 checkRunes(myrunes(mystring("")), `myrunes(mystring(""))`)
46 }
47
View as plain text