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.
13 void issue12030conv(char *buf, double x) {
14 sprintf(buf, "d=%g", x);
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
)