introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / test / issue12030.go
blobf863c58aa2aae022ed6e1788e27eeb1caa6afcdc
1 // Copyright 2015 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.
5 // Issue 12030. sprintf is defined in both ntdll and msvcrt,
6 // Normally we want the one in the msvcrt.
8 package cgotest
11 #include <stdio.h>
12 #include <stdlib.h>
13 void issue12030conv(char *buf, double x) {
14 sprintf(buf, "d=%g", x);
17 import "C"
19 import (
20 "fmt"
21 "testing"
22 "unsafe"
25 func test12030(t *testing.T) {
26 buf := (*C.char)(C.malloc(256))
27 defer C.free(unsafe.Pointer(buf))
28 for _, f := range []float64{1.0, 2.0, 3.14} {
29 C.issue12030conv(buf, C.double(f))
30 got := C.GoString(buf)
31 if want := fmt.Sprintf("d=%g", f); got != want {
32 t.Fatalf("C.sprintf failed for %g: %q != %q", f, got, want)