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.
10 #pragma ident "%Z%%M% %I% %E% SMI"
13 SM_IDSTR(id
, "@(#)$Id: t-float.c,v 1.16 2001/02/02 23:11:46 ca Exp $")
15 #include <sm/limits.h>
17 #include <sm/string.h>
32 ** Sendmail uses printf and scanf with doubles,
33 ** so make sure that this works.
36 sm_test_begin(argc
, argv
, "test floating point stuff");
39 sm_snprintf(buf
, sizeof(buf
), "%d %.3f %d", 0, d
, 1);
41 if (!SM_TEST(strcmp(buf
, r
) == 0))
42 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
43 "got %s instead\n", buf
);
46 sm_snprintf(buf
, sizeof(buf
), "%.3f", d
);
48 if (!SM_TEST(strcmp(buf
, r
) == 0))
49 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
50 "got %s instead\n", buf
);
52 sm_io_sscanf(buf
, "%lf", &d2
);
53 #if SM_CONF_BROKEN_STRTOD
56 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
57 "wanted %f, got %f\n", d
, d2
);
58 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
59 "error ignored since SM_CONF_BROKEN_STRTOD is set for this OS\n");
61 #else /* SM_CONF_BROKEN_STRTOD */
62 if (!SM_TEST(d
== d2
))
63 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
64 "wanted %f, got %f\n", d
, d2
);
65 #endif /* SM_CONF_BROKEN_STRTOD */
68 sm_snprintf(buf
, sizeof(buf
), "%.3f %.1f", d
, ld
);
70 if (!SM_TEST(strcmp(buf
, r
) == 0))
71 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
72 "got %s instead\n", buf
);