github.com/stingnevermore/go@v0.0.0-20180120041312-3810f5bfed72/misc/cgo/test/issue6907export.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  extern int CheckIssue6907C(_GoString_);
     9  */
    10  import "C"
    11  
    12  import (
    13  	"testing"
    14  )
    15  
    16  const CString = "C string"
    17  
    18  //export CheckIssue6907Go
    19  func CheckIssue6907Go(s string) C.int {
    20  	if s == CString {
    21  		return 1
    22  	}
    23  	return 0
    24  }
    25  
    26  func test6907Go(t *testing.T) {
    27  	if got := C.CheckIssue6907C(CString); got != 1 {
    28  		t.Errorf("C.CheckIssue6907C() == %d, want %d", got, 1)
    29  	}
    30  }