1 // Copyright 2013 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 // This file contains test cases for cgo with function pointer variables.
10 typedef int (*intFunc) ();
13 bridge_int_func(intFunc f)
27 func callBridge(f C
.intFunc
) int {
28 return int(C
.bridge_int_func(f
))
31 func callCBridge(f C
.intFunc
) C
.int {
32 return C
.bridge_int_func(f
)
35 func testFpVar(t
*testing
.T
) {
37 f
:= C
.intFunc(C
.fortytwo
)
38 res1
:= C
.bridge_int_func(f
)
39 if r1
:= int(res1
); r1
!= expected
{
40 t
.Errorf("got %d, want %d", r1
, expected
)
42 res2
:= callCBridge(f
)
43 if r2
:= int(res2
); r2
!= expected
{
44 t
.Errorf("got %d, want %d", r2
, expected
)
48 t
.Errorf("got %d, want %d", r3
, expected
)