2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_IDSTR(id
, "@(#)$Id: t-float.c,v 1.18 2001/09/11 04:04:49 gshapiro Exp $")
13 #include <sm/limits.h>
15 #include <sm/string.h>
30 ** Sendmail uses printf and scanf with doubles,
31 ** so make sure that this works.
34 sm_test_begin(argc
, argv
, "test floating point stuff");
37 sm_snprintf(buf
, sizeof(buf
), "%d %.3f %d", 0, d
, 1);
39 if (!SM_TEST(strcmp(buf
, r
) == 0))
40 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
41 "got %s instead\n", buf
);
44 sm_snprintf(buf
, sizeof(buf
), "%.3f", d
);
46 if (!SM_TEST(strcmp(buf
, r
) == 0))
47 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
48 "got %s instead\n", buf
);
50 sm_io_sscanf(buf
, "%lf", &d2
);
51 #if SM_CONF_BROKEN_STRTOD
54 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
55 "wanted %f, got %f\n", d
, d2
);
56 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
57 "error ignored since SM_CONF_BROKEN_STRTOD is set for this OS\n");
59 #else /* SM_CONF_BROKEN_STRTOD */
60 if (!SM_TEST(d
== d2
))
61 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
62 "wanted %f, got %f\n", d
, d2
);
63 #endif /* SM_CONF_BROKEN_STRTOD */
66 sm_snprintf(buf
, sizeof(buf
), "%.3f %.1f", d
, ld
);
68 if (!SM_TEST(strcmp(buf
, r
) == 0))
69 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
70 "got %s instead\n", buf
);