X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-stdint.c;h=d64057a2568c6dbf4d5da64f660f3df2a4e774ef;hb=df8bc51660941d7464dcd31170690519cb95c0c2;hp=a2f8f8e0ba481e6575c310ce638adebe1a422359;hpb=d9def6e726d94a8ef88077f46ffec58034e97464;p=gnulib.git diff --git a/tests/test-stdint.c b/tests/test-stdint.c index a2f8f8e0b..d64057a25 100644 --- a/tests/test-stdint.c +++ b/tests/test-stdint.c @@ -1,31 +1,28 @@ /* Test of substitute. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + 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 - Library General Public License for more details. + 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 Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ /* Written by Bruno Haible , 2006. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include /* Whether to enable pedantic checks. */ #define DO_PEDANTIC 0 #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ +#define __STDC_CONSTANT_MACROS 1 /* likewise */ #include #include "verify.h" @@ -38,7 +35,7 @@ # define _verify_func(line) _verify_func2(line) # define _verify_func2(line) verify_func_ ## line #else -# define verify_same_types(expr1,expr2) +# define verify_same_types(expr1,expr2) extern void verify_func (int) #endif /* 7.18.1.1. Exact-width integer types */ @@ -62,7 +59,7 @@ verify (TYPE_MAXIMUM (int32_t) == INT32_MAX); verify_same_types (INT32_MIN, (int32_t) 0 + 0); verify_same_types (INT32_MAX, (int32_t) 0 + 0); -#if HAVE_INT64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64 +#ifdef INT64_MAX int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX }; verify (TYPE_MINIMUM (int64_t) == INT64_MIN); verify (TYPE_MAXIMUM (int64_t) == INT64_MAX); @@ -82,7 +79,7 @@ uint32_t b3[2] = { UINT32_C (17), UINT32_MAX }; verify (TYPE_MAXIMUM (uint32_t) == UINT32_MAX); verify_same_types (UINT32_MAX, (uint32_t) 0 + 0); -#if HAVE_UINT64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64 +#ifdef UINT64_MAX uint64_t b4[2] = { UINT64_C (17), UINT64_MAX }; verify (TYPE_MAXIMUM (uint64_t) == UINT64_MAX); verify_same_types (UINT64_MAX, (uint64_t) 0 + 0); @@ -121,7 +118,7 @@ verify (TYPE_MAXIMUM (int_least32_t) == INT_LEAST32_MAX); verify_same_types (INT_LEAST32_MIN, (int_least32_t) 0 + 0); verify_same_types (INT_LEAST32_MAX, (int_least32_t) 0 + 0); -#if HAVE_INT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64 +#ifdef INT_LEAST64_MAX int_least64_t c4[3] = { 17, INT_LEAST64_MIN, INT_LEAST64_MAX }; verify (TYPE_MINIMUM (int_least64_t) == INT_LEAST64_MIN); verify (TYPE_MAXIMUM (int_least64_t) == INT_LEAST64_MAX); @@ -141,7 +138,7 @@ uint_least32_t d3[2] = { 17, UINT_LEAST32_MAX }; verify (TYPE_MAXIMUM (uint_least32_t) == UINT_LEAST32_MAX); verify_same_types (UINT_LEAST32_MAX, (uint_least32_t) 0 + 0); -#if HAVE_UINT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64 +#ifdef UINT_LEAST64_MAX uint_least64_t d4[2] = { 17, UINT_LEAST64_MAX }; verify (TYPE_MAXIMUM (uint_least64_t) == UINT_LEAST64_MAX); verify_same_types (UINT_LEAST64_MAX, (uint_least64_t) 0 + 0); @@ -180,7 +177,7 @@ verify (TYPE_MAXIMUM (int_fast32_t) == INT_FAST32_MAX); verify_same_types (INT_FAST32_MIN, (int_fast32_t) 0 + 0); verify_same_types (INT_FAST32_MAX, (int_fast32_t) 0 + 0); -#if HAVE_INT_FAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64 +#ifdef INT_FAST64_MAX int_fast64_t e4[3] = { 17, INT_FAST64_MIN, INT_FAST64_MAX }; verify (TYPE_MINIMUM (int_fast64_t) == INT_FAST64_MIN); verify (TYPE_MAXIMUM (int_fast64_t) == INT_FAST64_MAX); @@ -200,7 +197,7 @@ uint_fast32_t f3[2] = { 17, UINT_FAST32_MAX }; verify (TYPE_MAXIMUM (uint_fast32_t) == UINT_FAST32_MAX); verify_same_types (UINT_FAST32_MAX, (uint_fast32_t) 0 + 0); -#if HAVE_UINT_FAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64 +#ifdef UINT_FAST64_MAX uint_fast64_t f4[2] = { 17, UINT_FAST64_MAX }; verify (TYPE_MAXIMUM (uint_fast64_t) == UINT_FAST64_MAX); verify_same_types (UINT_FAST64_MAX, (uint_fast64_t) 0 + 0); @@ -250,11 +247,15 @@ uintmax_t j[2] = { UINTMAX_C (17), UINTMAX_MAX }; verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); verify_same_types (UINTMAX_MAX, (uintmax_t) 0 + 0); +/* As of 2007, Sun C and HP-UX 10.20 cc don't support 'long long' constants in + the preprocessor. */ +#if !(defined __SUNPRO_C || (defined __hpux && !defined __GNUC__)) #if INTMAX_MIN && INTMAX_MAX && UINTMAX_MAX /* ok */ #else err or; #endif +#endif /* 7.18.3. Limits of other integer types */ @@ -293,74 +294,68 @@ verify_same_types (SIZE_MAX, (size_t) 0 + 0); err or; #endif +#if HAVE_WCHAR_T verify (TYPE_MINIMUM (wchar_t) == WCHAR_MIN); verify (TYPE_MAXIMUM (wchar_t) == WCHAR_MAX); verify_same_types (WCHAR_MIN, (wchar_t) 0 + 0); verify_same_types (WCHAR_MAX, (wchar_t) 0 + 0); -#if WCHAR_MIN != 17 && WCHAR_MAX +# if WCHAR_MIN != 17 && WCHAR_MAX /* ok */ -#else +# else err or; +# endif #endif -#include -#include -#include +#if HAVE_WINT_T +# include verify (TYPE_MINIMUM (wint_t) == WINT_MIN); verify (TYPE_MAXIMUM (wint_t) == WINT_MAX); verify_same_types (WINT_MIN, (wint_t) 0 + 0); verify_same_types (WINT_MAX, (wint_t) 0 + 0); -#if WINT_MIN != 17 && WINT_MAX +# if WINT_MIN != 17 && WINT_MAX /* ok */ -#else +# else err or; +# endif #endif /* 7.18.4. Macros for integer constants */ verify (INT8_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (INT8_C (17), (int_least8_t)0); -#endif +verify_same_types (INT8_C (17), (int_least8_t)0 + 0); verify (UINT8_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (UINT8_C (17), (uint_least8_t)0); -#endif +verify_same_types (UINT8_C (17), (uint_least8_t)0 + 0); verify (INT16_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (INT16_C (17), (int_least16_t)0); -#endif +verify_same_types (INT16_C (17), (int_least16_t)0 + 0); verify (UINT16_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (UINT16_C (17), (uint_least16_t)0); -#endif +verify_same_types (UINT16_C (17), (uint_least16_t)0 + 0); verify (INT32_C (17) == 17); -verify_same_types (INT32_C (17), (int_least32_t)0); +verify_same_types (INT32_C (17), (int_least32_t)0 + 0); verify (UINT32_C (17) == 17); -verify_same_types (UINT32_C (17), (uint_least32_t)0); +verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0); -#if HAVE_INT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64 +#ifdef INT64_C verify (INT64_C (17) == 17); -verify_same_types (INT64_C (17), (int_least64_t)0); +verify_same_types (INT64_C (17), (int_least64_t)0 + 0); #endif -#if HAVE_UINT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64 +#ifdef UINT64_C verify (UINT64_C (17) == 17); -verify_same_types (UINT64_C (17), (uint_least64_t)0); +verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0); #endif verify (INTMAX_C (17) == 17); -verify_same_types (INTMAX_C (17), (intmax_t)0); +verify_same_types (INTMAX_C (17), (intmax_t)0 + 0); verify (UINTMAX_C (17) == 17); -verify_same_types (UINTMAX_C (17), (uintmax_t)0); +verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0); int -main () +main (void) { return 0; }