annotate libgo/misc/cgo/test/issue8092.go @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2014 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 // Issue 8092. Test that linker defined symbols (e.g., text, data) don't
kono
parents:
diff changeset
6 // conflict with C symbols.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 package cgotest
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 /*
kono
parents:
diff changeset
11 char text[] = "text";
kono
parents:
diff changeset
12 char data[] = "data";
kono
parents:
diff changeset
13 char *ctext(void) { return text; }
kono
parents:
diff changeset
14 char *cdata(void) { return data; }
kono
parents:
diff changeset
15 */
kono
parents:
diff changeset
16 import "C"
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 import "testing"
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 func test8092(t *testing.T) {
kono
parents:
diff changeset
21 tests := []struct {
kono
parents:
diff changeset
22 s string
kono
parents:
diff changeset
23 a, b *C.char
kono
parents:
diff changeset
24 }{
kono
parents:
diff changeset
25 {"text", &C.text[0], C.ctext()},
kono
parents:
diff changeset
26 {"data", &C.data[0], C.cdata()},
kono
parents:
diff changeset
27 }
kono
parents:
diff changeset
28 for _, test := range tests {
kono
parents:
diff changeset
29 if test.a != test.b {
kono
parents:
diff changeset
30 t.Errorf("%s: pointer mismatch: %v != %v", test.s, test.a, test.b)
kono
parents:
diff changeset
31 }
kono
parents:
diff changeset
32 if got := C.GoString(test.a); got != test.s {
kono
parents:
diff changeset
33 t.Errorf("%s: points at %#v, want %#v", test.s, got, test.s)
kono
parents:
diff changeset
34 }
kono
parents:
diff changeset
35 }
kono
parents:
diff changeset
36 }