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
8package cgotest
9
10/*
11char text[] = "text";
12char data[] = "data";
13char *ctext(void) { return text; }
14char *cdata(void) { return data; }
15*/
16import "C"
17
18import "testing"
19
20func 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}
37