3 // Copyright 2011 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 // Verify that illegal conversions involving strings are detected.
21 si := []int64{'h', 'e', 'l', 'l', 'o'}
31 _ = []int64(s) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
35 _ = Tint64(s) // ERROR "cannot convert.*Tint64|invalid type conversion"
39 _ = []rune(sb) // ERROR "cannot convert.*\[\]rune|invalid type conversion"
40 _ = []int64(sb) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
43 _ = Trune(sb) // ERROR "cannot convert.*Trune|invalid type conversion"
44 _ = Tint64(sb) // ERROR "cannot convert.*Tint64|invalid type conversion"
47 _ = []byte(sr) // ERROR "cannot convert.*\[\]byte|invalid type conversion"
49 _ = []int64(sr) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
51 _ = Tbyte(sr) // ERROR "cannot convert.*Tbyte|invalid type conversion"
53 _ = Tint64(sr) // ERROR "cannot convert.*Tint64|invalid type conversion"
55 _ = string(si) // ERROR "cannot convert.* string|invalid type conversion"
56 _ = []byte(si) // ERROR "cannot convert.*\[\]byte|invalid type conversion"
57 _ = []rune(si) // ERROR "cannot convert.*\[\]rune|invalid type conversion"
59 _ = Tstring(si) // ERROR "cannot convert.*Tstring|invalid type conversion"
60 _ = Tbyte(si) // ERROR "cannot convert.*Tbyte|invalid type conversion"
61 _ = Trune(si) // ERROR "cannot convert.*Trune|invalid type conversion"
67 _ = []int64(ts) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
71 _ = Tint64(ts) // ERROR "cannot convert.*Tint64|invalid type conversion"
75 _ = []rune(tsb) // ERROR "cannot convert.*\[\]rune|invalid type conversion"
76 _ = []int64(tsb) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
79 _ = Trune(tsb) // ERROR "cannot convert.*Trune|invalid type conversion"
80 _ = Tint64(tsb) // ERROR "cannot convert.*Tint64|invalid type conversion"
83 _ = []byte(tsr) // ERROR "cannot convert.*\[\]byte|invalid type conversion"
85 _ = []int64(tsr) // ERROR "cannot convert.*\[\]int64|invalid type conversion"
87 _ = Tbyte(tsr) // ERROR "cannot convert.*Tbyte|invalid type conversion"
89 _ = Tint64(tsr) // ERROR "cannot convert.*Tint64|invalid type conversion"
91 _ = string(tsi) // ERROR "cannot convert.* string|invalid type conversion"
92 _ = []byte(tsi) // ERROR "cannot convert.*\[\]byte|invalid type conversion"
93 _ = []rune(tsi) // ERROR "cannot convert.*\[\]rune|invalid type conversion"
95 _ = Tstring(tsi) // ERROR "cannot convert.*Tstring|invalid type conversion"
96 _ = Tbyte(tsi) // ERROR "cannot convert.*Tbyte|invalid type conversion"
97 _ = Trune(tsi) // ERROR "cannot convert.*Trune|invalid type conversion"