...
1
2
3
4
5 package main
6
7 import "reflect"
8
9 func main() {
10 type MyByte byte
11 type MyRune rune
12 type MyString string
13
14 a := []MyByte{'a', 'b', 'c'}
15 if s := string(a); s != "abc" {
16 panic(s)
17 }
18
19 b := []MyRune{'五', '五'}
20 if s := string(b); s != "五五" {
21 panic(s)
22 }
23
24 c := []MyByte{'l', 'o', 'r', 'e', 'm'}
25 if s := MyString(c); s != MyString("lorem") {
26 panic(s)
27 }
28
29 d := "lorem"
30 if a := []MyByte(d); !reflect.DeepEqual(a, []MyByte{'l', 'o', 'r', 'e', 'm'}) {
31 panic(a)
32 }
33
34 e := 42
35 if s := MyString(e); s != "*" {
36 panic(s)
37 }
38 }
39
View as plain text