blob: c879f2ae91d59d5f9ec5da1cb3c3f23b25786e88 [file] [log] [blame]
Ian Lance Taylor8f7863d2013-05-23 22:51:07 -07001// 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.
4
5package cgotest
6
7import "testing"
8
9/*
10extern int issue5548_in_c(void);
11*/
12import "C"
13
14//export issue5548FromC
15func issue5548FromC(s string, i int) int {
16 if len(s) == 4 && s == "test" && i == 42 {
Russ Coxfcbe51c2014-09-05 14:59:09 -040017 return 12345
Ian Lance Taylor8f7863d2013-05-23 22:51:07 -070018 }
Russ Coxfcbe51c2014-09-05 14:59:09 -040019 println("got", len(s), i)
20 return 9876
Ian Lance Taylor8f7863d2013-05-23 22:51:07 -070021}
22
23func test5548(t *testing.T) {
Russ Coxfcbe51c2014-09-05 14:59:09 -040024 if x := C.issue5548_in_c(); x != 12345 {
25 t.Errorf("issue5548_in_c = %d, want %d", x, 12345)
Ian Lance Taylor8f7863d2013-05-23 22:51:07 -070026 }
27}