Ian Lance Taylor | 8f7863d | 2013-05-23 22:51:07 -0700 | [diff] [blame] | 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. |
| 4 | |
| 5 | package cgotest |
| 6 | |
| 7 | import "testing" |
| 8 | |
| 9 | /* |
| 10 | extern int issue5548_in_c(void); |
| 11 | */ |
| 12 | import "C" |
| 13 | |
| 14 | //export issue5548FromC |
| 15 | func issue5548FromC(s string, i int) int { |
| 16 | if len(s) == 4 && s == "test" && i == 42 { |
Russ Cox | fcbe51c | 2014-09-05 14:59:09 -0400 | [diff] [blame] | 17 | return 12345 |
Ian Lance Taylor | 8f7863d | 2013-05-23 22:51:07 -0700 | [diff] [blame] | 18 | } |
Russ Cox | fcbe51c | 2014-09-05 14:59:09 -0400 | [diff] [blame] | 19 | println("got", len(s), i) |
| 20 | return 9876 |
Ian Lance Taylor | 8f7863d | 2013-05-23 22:51:07 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | func test5548(t *testing.T) { |
Russ Cox | fcbe51c | 2014-09-05 14:59:09 -0400 | [diff] [blame] | 24 | if x := C.issue5548_in_c(); x != 12345 { |
| 25 | t.Errorf("issue5548_in_c = %d, want %d", x, 12345) |
Ian Lance Taylor | 8f7863d | 2013-05-23 22:51:07 -0700 | [diff] [blame] | 26 | } |
| 27 | } |