flockfile list corruption test
[libc-test.git] / src / regression / printf-fmt-g-zeros.c
blob2b08691773e9204114792aa93c0457015537ff9a
1 // commit 89740868c9f1c84b8ee528468d12df1fa72cd392 2014-04-07
2 // %g should not print trailing zeros
3 #include <stdio.h>
4 #include <string.h>
5 #include "test.h"
7 static void t(const char *fmt, double d, const char *want)
9 char buf[256];
10 int n = strlen(want);
11 int r = snprintf(buf, sizeof buf, fmt, d);
12 if (r != n || memcmp(buf, want, n+1) != 0)
13 t_error("snprintf(\"%s\",%f) want %s got %s\n", fmt, d, want, buf);
16 int main()
18 t("%.50g", 100000000000000.5, "100000000000000.5");
19 t("%.50g", 987654321098765.0, "987654321098765");
20 return t_status;