introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / test / issue14838.go
blobc8e1681295e8f2e5e082028a4f936d7910edb5a6
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Issue 14838. add CBytes function
7 package cgotest
9 /*
10 #include <stdlib.h>
12 int check_cbytes(char *b, size_t l) {
13 int i;
14 for (i = 0; i < l; i++) {
15 if (b[i] != i) {
16 return 0;
19 return 1;
22 import "C"
24 import (
25 "testing"
26 "unsafe"
29 func test14838(t *testing.T) {
30 data := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
31 cData := C.CBytes(data)
32 defer C.free(cData)
34 if C.check_cbytes((*C.char)(cData), C.size_t(len(data))) == 0 {
35 t.Fatalf("mismatched data: expected %v, got %v", data, (*(*[10]byte)(unsafe.Pointer(cData)))[:])