github.com/flyinox/gosm@v0.0.0-20171117061539-16768cb62077/misc/cgo/test/issue18720.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  #define HELLO "hello"
     9  #define WORLD "world"
    10  #define HELLO_WORLD HELLO "\000" WORLD
    11  
    12  struct foo { char c; };
    13  #define SIZE_OF(x) sizeof(x)
    14  #define SIZE_OF_FOO SIZE_OF(struct foo)
    15  */
    16  import "C"
    17  import "testing"
    18  
    19  func test18720(t *testing.T) {
    20  	if C.HELLO_WORLD != "hello\000world" {
    21  		t.Fatalf(`expected "hello\000world", but got %q`, C.HELLO_WORLD)
    22  	}
    23  
    24  	// Issue 20125.
    25  	if got, want := C.SIZE_OF_FOO, 1; got != want {
    26  		t.Errorf("C.SIZE_OF_FOO == %v, expected %v", got, want)
    27  	}
    28  }