annotate tests/test-func.c @ 40186:8964917f9574

autoupdate
author Karl Berry <karl@freefriends.org>
date Mon, 18 Feb 2019 08:02:49 -0800
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
1 /* Test whether __func__ is available
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2008-2019 Free Software Foundation, Inc.
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
3
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
7 (at your option) any later version.
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
8
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
12 GNU General Public License for more details.
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
13
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
16
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
18
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
19 #include <config.h>
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
20
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
21 #include <string.h>
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
22
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
23 #include "macros.h"
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
24
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
25 int
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
26 main ()
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
27 {
11906
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
28 ASSERT (strlen (__func__) > 0);
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
29
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
30 /* On SunPRO C 5.9, sizeof __func__ evaluates to 0. The compiler warns:
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
31 "warning: null dimension: sizeof()". */
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
32 #if !defined __SUNPRO_C
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
33 ASSERT (strlen (__func__) + 1 == sizeof __func__);
11906
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
34 #endif
6b25bda86ddb Avoid sizeof __func__ == 0 pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9889
diff changeset
35
12242
b966514efbf6 Fix typo in last commit.
Simon Josefsson <simon@josefsson.org>
parents: 12240
diff changeset
36 ASSERT (strcmp (__func__, "main") == 0
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12242
diff changeset
37 || strcmp (__func__, "<unknown function>") == 0);
12240
04732481adba test-func.c: Also test value of __func__.
Simon Josefsson <simon@josefsson.org>
parents: 11906
diff changeset
38
9761
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
39 return 0;
f63d3075f044 Rename __func__ module to func.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
40 }