diff options
| author | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 | 
|---|---|---|
| committer | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 | 
| commit | bd6adfa17d453e4c486e36fed4c5779db90a8a0e (patch) | |
| tree | 9798677560d5f99061afe9f0db105a8c97f2438a /tests/signature.h | |
| parent | 79ca645d222db2e158784642c3b464a47bea26f3 (diff) | |
| parent | 3e0814cd9862b89c7a39672672937477bd87ddfb (diff) | |
Merge commit 'upstream/0.9.3'
Diffstat (limited to 'tests/signature.h')
| -rw-r--r-- | tests/signature.h | 48 | 
1 files changed, 48 insertions, 0 deletions
| diff --git a/tests/signature.h b/tests/signature.h new file mode 100644 index 00000000..6e15c43a --- /dev/null +++ b/tests/signature.h @@ -0,0 +1,48 @@ +/* Macro for checking that a function declaration is compliant. +   Copyright (C) 2009, 2010 Free Software Foundation, Inc. + +   This program is free software: you can redistribute it and/or modify +   it under the terms of the GNU General Public License as published by +   the Free Software Foundation; either version 3 of the License, or +   (at your option) any later version. + +   This program is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +   GNU General Public License for more details. + +   You should have received a copy of the GNU General Public License +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ + +#ifndef SIGNATURE_CHECK + +/* Check that the function FN takes the specified arguments ARGS with +   a return type of RET.  This header is designed to be included after +   <config.h> and the one system header that is supposed to contain +   the function being checked, but prior to any other system headers +   that are necessary for the unit test.  Therefore, this file does +   not include any system headers, nor reference anything outside of +   the macro arguments.  For an example, if foo.h should provide: + +   extern int foo (char, float); + +   then the unit test named test-foo.c would start out with: + +   #include <config.h> +   #include <foo.h> +   #include "signature.h" +   SIGNATURE_CHECK (foo, int, (char, float)); +   #include <other.h> +   ... +*/ +# define SIGNATURE_CHECK(fn, ret, args) \ +  SIGNATURE_CHECK1 (fn, ret, args, __LINE__) + +/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test. +   Note that the checks must not occupy the same line.  */ +# define SIGNATURE_CHECK1(fn, ret, args, id) \ +  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */ +# define SIGNATURE_CHECK2(fn, ret, args, id) \ +  static ret (* _GL_UNUSED signature_check ## id) args = fn + +#endif /* SIGNATURE_CHECK */ | 
