introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / test / helpers.go
blobf6a822a1065b268f37da359b07f6efa2276d3405
1 // Copyright 2011 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 package cgotest
7 // const char *greeting = "hello, world";
8 import "C"
10 import (
11 "reflect"
12 "testing"
13 "unsafe"
16 const greeting = "hello, world"
18 type testPair struct {
19 Name string
20 Got, Want interface{}
23 var testPairs = []testPair{
24 {"GoString", C.GoString(C.greeting), greeting},
25 {"GoStringN", C.GoStringN(C.greeting, 5), greeting[:5]},
26 {"GoBytes", C.GoBytes(unsafe.Pointer(C.greeting), 5), []byte(greeting[:5])},
29 func testHelpers(t *testing.T) {
30 for _, pair := range testPairs {
31 if !reflect.DeepEqual(pair.Got, pair.Want) {
32 t.Errorf("%s: got %#v, want %#v", pair.Name, pair.Got, pair.Want)