Mercurial > hg > octave-kai > gnulib-hg
annotate tests/test-strerror.c @ 16616:2f2ef742aa4b
New module 'exp2'.
* lib/math.in.h (exp2): New declaration.
* lib/exp2.c: New file.
* m4/exp2.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether exp2 is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_EXP2, HAVE_DECL_EXP2,
REPLACE_EXP2.
* modules/math (Makefile.am): Substitute GNULIB_EXP2, HAVE_DECL_EXP2,
REPLACE_EXP2.
* modules/exp2: New file.
* tests/test-math-c++.cc: Check the declaration of exp2.
* doc/posix-functions/exp2.texi: Mention the new module and the IRIX
and OpenBSD problems.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 07 Mar 2012 03:29:32 +0100 |
parents | bb182ee4a09d |
children | e542fd46ad6f |
rev | line source |
---|---|
9224 | 1 /* Test of strerror() function. |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
14895
diff
changeset
|
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. |
9224 | 3 |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16358
diff
changeset
|
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
9224 | 16 |
17 /* Written by Eric Blake <ebb9@byu.net>, 2007. */ | |
18 | |
19 #include <config.h> | |
20 | |
12487
8ba9831d54bf
Include header file being tested immediately after config.h.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
21 #include <string.h> |
8ba9831d54bf
Include header file being tested immediately after config.h.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
22 |
12489 | 23 #include "signature.h" |
24 SIGNATURE_CHECK (strerror, char *, (int)); | |
25 | |
9224 | 26 #include <errno.h> |
27 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12489
diff
changeset
|
28 #include "macros.h" |
9224 | 29 |
30 int | |
12197
e45d9bb2233e
tests: avoid several compiler warnings
Eric Blake <ebb9@byu.net>
parents:
10429
diff
changeset
|
31 main (void) |
9224 | 32 { |
33 char *str; | |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
34 |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
35 errno = 0; |
9224 | 36 str = strerror (EACCES); |
37 ASSERT (str); | |
38 ASSERT (*str); | |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
39 ASSERT (errno == 0); |
9224 | 40 |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
41 errno = 0; |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
42 str = strerror (ETIMEDOUT); |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
43 ASSERT (str); |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
44 ASSERT (*str); |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
45 ASSERT (errno == 0); |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
46 |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
47 errno = 0; |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
48 str = strerror (EOVERFLOW); |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
49 ASSERT (str); |
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
50 ASSERT (*str); |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
51 ASSERT (errno == 0); |
10429
69d9922a5bd2
Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
52 |
14763
19cd3c889b58
strerror: relax test for Solaris
Eric Blake <eblake@redhat.com>
parents:
14762
diff
changeset
|
53 /* POSIX requires strerror (0) to succeed. Reject use of "Unknown |
19cd3c889b58
strerror: relax test for Solaris
Eric Blake <eblake@redhat.com>
parents:
14762
diff
changeset
|
54 error", but allow "Success", "No error", or even Solaris' "Error |
19cd3c889b58
strerror: relax test for Solaris
Eric Blake <eblake@redhat.com>
parents:
14762
diff
changeset
|
55 0" which are distinct patterns from true out-of-range strings. |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
56 http://austingroupbugs.net/view.php?id=382 */ |
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
57 errno = 0; |
9224 | 58 str = strerror (0); |
59 ASSERT (str); | |
60 ASSERT (*str); | |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
61 ASSERT (errno == 0); |
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
62 ASSERT (strstr (str, "nknown") == NULL); |
14895
66b65ce5da39
strerror_r-posix: fix on MacOS
Eric Blake <eblake@redhat.com>
parents:
14763
diff
changeset
|
63 ASSERT (strstr (str, "ndefined") == NULL); |
9224 | 64 |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
65 /* POSIX requires strerror to produce a non-NULL result for all |
16358 | 66 inputs; as an extension, we also guarantee a non-empty result. |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
67 Reporting EINVAL is optional. */ |
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
68 errno = 0; |
9224 | 69 str = strerror (-3); |
70 ASSERT (str); | |
71 ASSERT (*str); | |
14762
3c012e3d3f43
strerror: enforce POSIX ruling on strerror(0)
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
72 ASSERT (errno == 0 || errno == EINVAL); |
9224 | 73 |
74 return 0; | |
75 } |