]> Cypherpunks.ru repositories - gostls13.git/blob - misc/cgo/test/issue9026/issue9026.go
misc/cgo/test: simplify for module mode
[gostls13.git] / misc / cgo / test / issue9026 / issue9026.go
1 package issue9026
2
3 // This file appears in its own package since the assertion tests the
4 // per-package counter used to create fresh identifiers.
5
6 /*
7 typedef struct { int i; } git_merge_file_input;
8
9 typedef struct { int j; } git_merge_file_options;
10
11 void git_merge_file(
12         git_merge_file_input *in,
13         git_merge_file_options *opts) {}
14 */
15 import "C"
16 import (
17         "fmt"
18         "testing"
19 )
20
21 func Test(t *testing.T) {
22         var in C.git_merge_file_input
23         var opts *C.git_merge_file_options
24         C.git_merge_file(&in, opts)
25
26         // Test that the generated type names are deterministic.
27         // (Previously this would fail about 10% of the time.)
28         //
29         // Brittle: the assertion may fail spuriously when the algorithm
30         // changes, but should remain stable otherwise.
31         got := fmt.Sprintf("%T %T", in, opts)
32         want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
33         if got != want {
34                 t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
35         }
36 }