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.
7 // const char *greeting = "hello, world";
16 const greeting
= "hello, world"
18 type testPair
struct {
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
)