annotate tests/test-printf-posix.c @ 10994:849e7305914c

remove duplicate inclusion of <stdio.h> * tests/test-fprintf-posix.c: Likewise. * tests/test-printf-posix.c: Likewise. * tests/test-snprintf-posix.c: Likewise. * tests/test-sprintf-posix.c: Likewise. * tests/test-vasprintf-posix.c: Likewise. * tests/test-vfprintf-posix.c: Likewise. * tests/test-vprintf-posix.c: Likewise. * tests/test-vsnprintf-posix.c: Likewise. * tests/test-vsprintf-posix.c: Likewise.
author Jim Meyering <meyering@redhat.com>
date Sun, 04 Jan 2009 20:59:12 +0100
parents 0be6f1ab456d
children e8d2c6fc33ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9430
bb2a238b2c3a Typo in comment.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
1 /* Test of POSIX compatible printf() function.
9889
0be6f1ab456d Flush the standard error stream before aborting.
Bruno Haible <bruno@clisp.org>
parents: 9430
diff changeset
2 Copyright (C) 2007-2008 Free Software Foundation, Inc.
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8891
diff changeset
4 This program is free software: you can redistribute it and/or modify
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8891
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8891
diff changeset
7 (at your option) any later version.
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8891
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
8891
633babea5f62 Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents: 8754
diff changeset
19 #include <config.h>
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stdio.h>
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <stddef.h>
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <stdint.h>
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <stdlib.h>
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <string.h>
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
8754
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
28 #define ASSERT(expr) \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
29 do \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
30 { \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
31 if (!(expr)) \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
32 { \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
33 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
9889
0be6f1ab456d Flush the standard error stream before aborting.
Bruno Haible <bruno@clisp.org>
parents: 9430
diff changeset
34 fflush (stderr); \
8754
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
35 abort (); \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
36 } \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
37 } \
1f57552cdb11 Better ASSERT macro.
Bruno Haible <bruno@clisp.org>
parents: 8403
diff changeset
38 while (0)
8403
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 #include "test-printf-posix.h"
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 int
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 main (int argc, char *argv[])
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 {
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 test_function (printf);
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 return 0;
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 }
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /* Test whether __attribute__ (__format__ (...)) still works. */
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !__STRICT_ANSI__
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 extern int func1 (char *, size_t, const char *, ...)
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 __attribute__ ((__format__ (__printf__, 3, 4)));
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 extern int func2 (char *, size_t, const char *, ...)
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 __attribute__ ((__format__ (printf, 3, 4)));
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 extern int func3 (char *, size_t, const char *, ...)
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 __attribute__ ((format (__printf__, 3, 4)));
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 extern int func4 (char *, size_t, const char *, ...)
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 __attribute__ ((format (printf, 3, 4)));
f05a09ae28b1 Tests for module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 #endif