annotate tests/signature.h @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
1 /* Macro for checking that a function declaration is compliant.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
3
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 (at your option) any later version.
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
12 GNU General Public License for more details.
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
13
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
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/>. */
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
16
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
17 #ifndef SIGNATURE_CHECK
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
18
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
19 /* Check that the function FN takes the specified arguments ARGS with
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
20 a return type of RET. This header is designed to be included after
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
21 <config.h> and the one system header that is supposed to contain
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
22 the function being checked, but prior to any other system headers
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
23 that are necessary for the unit test. Therefore, this file does
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
24 not include any system headers, nor reference anything outside of
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
25 the macro arguments. For an example, if foo.h should provide:
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
26
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
27 extern int foo (char, float);
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
28
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
29 then the unit test named test-foo.c would start out with:
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
30
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
31 #include <config.h>
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
32 #include <foo.h>
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
33 #include "signature.h"
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
34 SIGNATURE_CHECK (foo, int, (char, float));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
35 #include <other.h>
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
36 ...
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
37 */
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
38 # define SIGNATURE_CHECK(fn, ret, args) \
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
39 SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
40
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
41 /* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test.
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
42 Note that the checks must not occupy the same line. */
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
43 # define SIGNATURE_CHECK1(fn, ret, args, id) \
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
44 SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
45 # define SIGNATURE_CHECK2(fn, ret, args, id) \
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
46 static ret (* _GL_UNUSED signature_check ## id) args = fn
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
47
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents:
diff changeset
48 #endif /* SIGNATURE_CHECK */