annotate tests/test-dprintf-posix.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of POSIX compatible dprintf() function.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stdio.h>
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
23 #include "signature.h"
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
24 SIGNATURE_CHECK (dprintf, int, (int, const char *, ...));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
25
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <stddef.h>
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <stdint.h>
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include <string.h>
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
30 #include "infinity.h"
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12489
diff changeset
31 #include "macros.h"
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 static void
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 test_function (int (*my_dprintf) (int, const char *, ...))
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 {
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 /* Here we don't test output that may be platform dependent.
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 The bulk of the tests is done as part of the 'vasnprintf-posix' module. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 /* Test support of size specifiers as in C99. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 my_dprintf (fileno (stdout), "%ju %d\n", (uintmax_t) 12345671, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 my_dprintf (fileno (stdout), "%zu %d\n", (size_t) 12345672, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 my_dprintf (fileno (stdout), "%tu %d\n", (ptrdiff_t) 12345673, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 output of floating-point numbers. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 /* Positive zero. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 my_dprintf (fileno (stdout), "%a %d\n", 0.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 /* Positive infinity. */
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
54 my_dprintf (fileno (stdout), "%a %d\n", Infinityd (), 33, 44, 55);
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 /* Negative infinity. */
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
57 my_dprintf (fileno (stdout), "%a %d\n", - Infinityd (), 33, 44, 55);
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 /* FLAG_ZERO with infinite number. */
15595
328819af1c02 Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
60 my_dprintf (fileno (stdout), "%010a %d\n", Infinityd (), 33, 44, 55);
11036
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 /* Test the support of the %f format directive. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 /* A positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 my_dprintf (fileno (stdout), "%f %d\n", 12.75, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 /* A larger positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 my_dprintf (fileno (stdout), "%f %d\n", 1234567.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 /* A negative number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 my_dprintf (fileno (stdout), "%f %d\n", -0.03125, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 /* Positive zero. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 my_dprintf (fileno (stdout), "%f %d\n", 0.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 /* FLAG_ZERO. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 my_dprintf (fileno (stdout), "%015f %d\n", 1234.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 /* Precision. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 my_dprintf (fileno (stdout), "%.f %d\n", 1234.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 /* Precision with no rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 my_dprintf (fileno (stdout), "%.2f %d\n", 999.95, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 /* Precision with rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 my_dprintf (fileno (stdout), "%.2f %d\n", 999.996, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 /* A positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 my_dprintf (fileno (stdout), "%Lf %d\n", 12.75L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 /* A larger positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 my_dprintf (fileno (stdout), "%Lf %d\n", 1234567.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 /* A negative number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 my_dprintf (fileno (stdout), "%Lf %d\n", -0.03125L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 /* Positive zero. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 my_dprintf (fileno (stdout), "%Lf %d\n", 0.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 /* FLAG_ZERO. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 my_dprintf (fileno (stdout), "%015Lf %d\n", 1234.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 /* Precision. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 my_dprintf (fileno (stdout), "%.Lf %d\n", 1234.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 /* Precision with no rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 my_dprintf (fileno (stdout), "%.2Lf %d\n", 999.95L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 /* Precision with rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 my_dprintf (fileno (stdout), "%.2Lf %d\n", 999.996L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 /* Test the support of the %F format directive. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 /* A positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 my_dprintf (fileno (stdout), "%F %d\n", 12.75, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 /* A larger positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 my_dprintf (fileno (stdout), "%F %d\n", 1234567.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 /* A negative number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 my_dprintf (fileno (stdout), "%F %d\n", -0.03125, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 /* Positive zero. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 my_dprintf (fileno (stdout), "%F %d\n", 0.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 /* FLAG_ZERO. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 my_dprintf (fileno (stdout), "%015F %d\n", 1234.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 /* Precision. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 my_dprintf (fileno (stdout), "%.F %d\n", 1234.0, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 /* Precision with no rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 my_dprintf (fileno (stdout), "%.2F %d\n", 999.95, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 /* Precision with rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 my_dprintf (fileno (stdout), "%.2F %d\n", 999.996, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 /* A positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 my_dprintf (fileno (stdout), "%LF %d\n", 12.75L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 /* A larger positive number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 my_dprintf (fileno (stdout), "%LF %d\n", 1234567.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 /* A negative number. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 my_dprintf (fileno (stdout), "%LF %d\n", -0.03125L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 /* Positive zero. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 my_dprintf (fileno (stdout), "%LF %d\n", 0.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 /* FLAG_ZERO. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 my_dprintf (fileno (stdout), "%015LF %d\n", 1234.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 /* Precision. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 my_dprintf (fileno (stdout), "%.LF %d\n", 1234.0L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 /* Precision with no rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 my_dprintf (fileno (stdout), "%.2LF %d\n", 999.95L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 /* Precision with rounding. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 my_dprintf (fileno (stdout), "%.2LF %d\n", 999.996L, 33, 44, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 /* Test the support of the POSIX/XSI format strings with positions. */
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 my_dprintf (fileno (stdout), "%2$d %1$d\n", 33, 55);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 }
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 int
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 main (int argc, char *argv[])
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 {
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170 test_function (dprintf);
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 return 0;
e901ed0f1ffc Tests for module 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 }