111
|
1 // Copyright 2014 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 // Issue 8092. Test that linker defined symbols (e.g., text, data) don't
|
|
6 // conflict with C symbols.
|
|
7
|
|
8 package cgotest
|
|
9
|
|
10 /*
|
|
11 char text[] = "text";
|
|
12 char data[] = "data";
|
|
13 char *ctext(void) { return text; }
|
|
14 char *cdata(void) { return data; }
|
|
15 */
|
|
16 import "C"
|
|
17
|
|
18 import "testing"
|
|
19
|
|
20 func test8092(t *testing.T) {
|
|
21 tests := []struct {
|
|
22 s string
|
|
23 a, b *C.char
|
|
24 }{
|
|
25 {"text", &C.text[0], C.ctext()},
|
|
26 {"data", &C.data[0], C.cdata()},
|
|
27 }
|
|
28 for _, test := range tests {
|
|
29 if test.a != test.b {
|
|
30 t.Errorf("%s: pointer mismatch: %v != %v", test.s, test.a, test.b)
|
|
31 }
|
|
32 if got := C.GoString(test.a); got != test.s {
|
|
33 t.Errorf("%s: points at %#v, want %#v", test.s, got, test.s)
|
|
34 }
|
|
35 }
|
|
36 }
|