github.com/hlts2/go@v0.0.0-20170904000733-812b34efaed8/misc/cgo/test/issue20129.go (about)

     1  // Copyright 2017 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  /*
     8  int issue20129 = 0;
     9  typedef void issue20129Void;
    10  issue20129Void issue20129Foo() {
    11  	issue20129 = 1;
    12  }
    13  typedef issue20129Void issue20129Void2;
    14  issue20129Void2 issue20129Bar() {
    15  	issue20129 = 2;
    16  }
    17  */
    18  import "C"
    19  import "testing"
    20  
    21  func test20129(t *testing.T) {
    22  	if C.issue20129 != 0 {
    23  		t.Fatal("test is broken")
    24  	}
    25  	C.issue20129Foo()
    26  	if C.issue20129 != 1 {
    27  		t.Errorf("got %v but expected %v", C.issue20129, 1)
    28  	}
    29  	C.issue20129Bar()
    30  	if C.issue20129 != 2 {
    31  		t.Errorf("got %v but expected %v", C.issue20129, 2)
    32  	}
    33  }