github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/test/execution/strings/bytes.go (about) 1 // RUN: llgo -o %t %s 2 // RUN: %t 2>&1 | FileCheck %s 3 4 // CHECK: testBytesConversion: true 5 // CHECK-NEXT: 97 6 // CHECK-NEXT: 98 7 // CHECK-NEXT: 99 8 // CHECK-NEXT: abc 9 // CHECK-NEXT: !bc 10 // CHECK-NEXT: testBytesCopy: true 11 12 package main 13 14 type namedByte byte 15 16 func testBytesConversion() { 17 s := "abc" 18 b := []byte(s) 19 println("testBytesConversion:", s == string(b)) 20 nb := []namedByte(s) 21 for _, v := range nb { 22 println(v) 23 } 24 b[0] = '!' 25 println(s) 26 s = string(b) 27 b[0] = 'a' 28 println(s) 29 } 30 31 func testBytesCopy() { 32 s := "abc" 33 b := make([]byte, len(s)) 34 copy(b, s) 35 println("testBytesCopy:", string(b) == s) 36 } 37 38 func main() { 39 testBytesConversion() 40 testBytesCopy() 41 }