Mercurial > hg > octave-kai > gnulib-hg
annotate tests/test-printf-posix.c @ 12421:e8d2c6fc33ad
Use spaces for indentation, not tabs.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 10 Dec 2009 20:28:30 +0100 (2009-12-10) |
parents | 849e7305914c |
children | 33ab12a7cea2 |
rev | line source |
---|---|
9430 | 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 | 28 #define ASSERT(expr) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
29 do \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
30 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
31 if (!(expr)) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
32 { \ |
8754 | 33 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
34 fflush (stderr); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
35 abort (); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
36 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10994
diff
changeset
|
37 } \ |
8754 | 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 |