annotate tests/test-intprops.c @ 14761:6c5502aeb486

intprop-tests: port to older and more-pedantic compilers * modules/intprops-tests (Files): Add tests/macros.h. * tests/test-intprops.c: Include macros.h. (TYPE_IS_INTEGER): Use ASSERT, not verify, to test this macro, as it's no longer documented to expand to an integer constant expression. (TYPE_SIGNED): Use ASSERT, not verify, to test this macro when the argument is floating point, as it's no longer documented to expand to an integer constant expression in that case. (UINT_MAX, ULONG_MAX, UINTMAX_MAX): Redefine to work around compiler bugs reported by Bruno Haible. See <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. (U0, U1): New constants, to work around the same bugs. Also, in tests, use e.g., "(unsigned int) 39" rather than "39u".
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 19 May 2011 01:43:17 -0700
parents eb6ac457b650
children 05ca371c9c6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* Test intprops.h.
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2 Copyright (C) 2011 Free Software Foundation, Inc.
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 (at your option) any later version.
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 GNU General Public License for more details.
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
16
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17 /* Written by Paul Eggert. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 #include <config.h>
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 #include "intprops.h"
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 #include "verify.h"
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24 #include <stdbool.h>
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25 #include <inttypes.h>
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
27 #include "macros.h"
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
28
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
29 /* Work around compiler bugs in HP-UX 11.23 cc, IRIX 6.5 cc, OSF/1 5.1
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
30 cc, and Solaris 9 cc. See
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
31 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
32 #undef UINT_MAX
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
33 #undef ULONG_MAX
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
34 #undef UINTMAX_MAX
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
35 #define UINT_MAX ((unsigned int) -1)
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
36 #define ULONG_MAX ((unsigned long int) -1)
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
37 #define UINTMAX_MAX ((uintmax_t) -1)
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
38 #define U0 ((unsigned int) 0)
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
39 #define U1 ((unsigned int) 1)
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
40
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 /* Integer representation. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 verify (INT_MIN + INT_MAX < 0
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 ? (TYPE_TWOS_COMPLEMENT (int)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
44 && ! TYPE_ONES_COMPLEMENT (int) && ! TYPE_SIGNED_MAGNITUDE (int))
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 : (! TYPE_TWOS_COMPLEMENT (int)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
46 && (TYPE_ONES_COMPLEMENT (int) || TYPE_SIGNED_MAGNITUDE (int))));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48 /* TYPE_SIGNED. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
49 /* verify (! TYPE_SIGNED (bool)); */ /* not guaranteed by gnulib substitute */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
50 verify (TYPE_SIGNED (signed char));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
51 verify (! TYPE_SIGNED (unsigned char));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52 verify (TYPE_SIGNED (short int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
53 verify (! TYPE_SIGNED (unsigned short int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
54 verify (TYPE_SIGNED (int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
55 verify (! TYPE_SIGNED (unsigned int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
56 verify (TYPE_SIGNED (long int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
57 verify (! TYPE_SIGNED (unsigned long int));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
58 verify (TYPE_SIGNED (intmax_t));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
59 verify (! TYPE_SIGNED (uintmax_t));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
60
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
61 /* TYPE_MINIMUM, TYPE_MAXIMUM. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
62 verify (TYPE_MINIMUM (char) == CHAR_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
63 verify (TYPE_MAXIMUM (char) == CHAR_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
64 verify (TYPE_MINIMUM (unsigned char) == 0);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
65 verify (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
66 verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
67 verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
68 verify (TYPE_MINIMUM (short int) == SHRT_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
69 verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
70 verify (TYPE_MINIMUM (unsigned short int) == 0);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
71 verify (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
72 verify (TYPE_MINIMUM (int) == INT_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
73 verify (TYPE_MAXIMUM (int) == INT_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
74 verify (TYPE_MINIMUM (unsigned int) == 0);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
75 verify (TYPE_MAXIMUM (unsigned int) == UINT_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
76 verify (TYPE_MINIMUM (long int) == LONG_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
77 verify (TYPE_MAXIMUM (long int) == LONG_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
78 verify (TYPE_MINIMUM (unsigned long int) == 0);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
79 verify (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
80 verify (TYPE_MINIMUM (intmax_t) == INTMAX_MIN);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
81 verify (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
82 verify (TYPE_MINIMUM (uintmax_t) == 0);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
83 verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
84
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
85 /* INT_BITS_STRLEN_BOUND. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
86 verify (INT_BITS_STRLEN_BOUND (1) == 1);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
87 verify (INT_BITS_STRLEN_BOUND (2620) == 789);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
88
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
89 /* INT_STRLEN_BOUND, INT_BUFSIZE_BOUND. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
90 #ifdef INT32_MAX /* POSIX guarantees int32_t; this ports to non-POSIX hosts */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
91 verify (INT_STRLEN_BOUND (int32_t) == sizeof ("-2147483648") - 1);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
92 verify (INT_BUFSIZE_BOUND (int32_t) == sizeof ("-2147483648"));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
93 #endif
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
94 #ifdef INT64_MAX
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
95 verify (INT_STRLEN_BOUND (int64_t) == sizeof ("-9223372036854775808") - 1);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
96 verify (INT_BUFSIZE_BOUND (int64_t) == sizeof ("-9223372036854775808"));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
97 #endif
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
98
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
99 /* All the INT_<op>_RANGE_OVERFLOW tests are equally valid as
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
100 INT_<op>_OVERFLOW tests, so define a single macro to do both. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
101 #define check_binop(op, a, b, min, max, overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
102 (INT_##op##_RANGE_OVERFLOW (a, b, min, max) == (overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
103 && INT_##op##_OVERFLOW (a, b) == (overflow))
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
104 #define check_unop(op, a, min, max, overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
105 (INT_##op##_RANGE_OVERFLOW (a, min, max) == (overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
106 && INT_##op##_OVERFLOW (a) == (overflow))
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
107
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
108 /* INT_<op>_RANGE_OVERFLOW, INT_<op>_OVERFLOW. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
109 verify (INT_ADD_RANGE_OVERFLOW (INT_MAX, 1, INT_MIN, INT_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
110 verify (INT_ADD_OVERFLOW (INT_MAX, 1));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
111 verify (check_binop (ADD, INT_MAX, 1, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
112 verify (check_binop (ADD, INT_MAX, -1, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
113 verify (check_binop (ADD, INT_MIN, 1, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
114 verify (check_binop (ADD, INT_MIN, -1, INT_MIN, INT_MAX, true));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
115 verify (check_binop (ADD, UINT_MAX, U1, U0, UINT_MAX, true));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
116 verify (check_binop (ADD, U0, U1, U0, UINT_MAX, false));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
117
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
118 verify (check_binop (SUBTRACT, INT_MAX, 1, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
119 verify (check_binop (SUBTRACT, INT_MAX, -1, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
120 verify (check_binop (SUBTRACT, INT_MIN, 1, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
121 verify (check_binop (SUBTRACT, INT_MIN, -1, INT_MIN, INT_MAX, false));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
122 verify (check_binop (SUBTRACT, UINT_MAX, U1, U0, UINT_MAX, false));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
123 verify (check_binop (SUBTRACT, U0, U1, U0, UINT_MAX, true));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
124
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
125 verify (check_unop (NEGATE, INT_MIN, INT_MIN, INT_MAX,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
126 TYPE_TWOS_COMPLEMENT (int)));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
127 verify (check_unop (NEGATE, 0, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
128 verify (check_unop (NEGATE, INT_MAX, INT_MIN, INT_MAX, false));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
129 verify (check_unop (NEGATE, U0, U0, UINT_MAX, false));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
130 verify (check_unop (NEGATE, U1, U0, UINT_MAX, true));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
131 verify (check_unop (NEGATE, UINT_MAX, U0, UINT_MAX, true));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
132
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
133 verify (check_binop (MULTIPLY, INT_MAX, INT_MAX, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
134 verify (check_binop (MULTIPLY, INT_MAX, INT_MIN, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
135 verify (check_binop (MULTIPLY, INT_MIN, INT_MAX, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
136 verify (check_binop (MULTIPLY, INT_MIN, INT_MIN, INT_MIN, INT_MAX, true));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
137 verify (check_binop (MULTIPLY, -1, INT_MIN, INT_MIN, INT_MAX,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
138 INT_NEGATE_OVERFLOW (INT_MIN)));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
139 verify (check_binop (MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
140 LONG_MIN, LONG_MIN, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
141
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
142 verify (check_binop (DIVIDE, INT_MIN, -1, INT_MIN, INT_MAX,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
143 INT_NEGATE_OVERFLOW (INT_MIN)));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
144 verify (check_binop (DIVIDE, INT_MAX, 1, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
145 verify (check_binop (DIVIDE, (unsigned int) INT_MIN,
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
146 -U1, U0, UINT_MAX, false));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
147
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
148 verify (check_binop (REMAINDER, INT_MIN, -1, INT_MIN, INT_MAX,
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
149 INT_NEGATE_OVERFLOW (INT_MIN)));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
150 verify (check_binop (REMAINDER, INT_MAX, 1, INT_MIN, INT_MAX, false));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
151 verify (check_binop (REMAINDER, (unsigned int) INT_MIN,
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
152 -U1, U0, UINT_MAX, false));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
153
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
154 verify (check_binop (LEFT_SHIFT, UINT_MAX, 1, U0, UINT_MAX, true));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
155 verify (check_binop (LEFT_SHIFT, UINT_MAX / 2 + 1, 1, U0, UINT_MAX, true));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
156 verify (check_binop (LEFT_SHIFT, UINT_MAX / 2, 1, U0, UINT_MAX, false));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
157
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
158 /* INT_<op>_OVERFLOW with mixed types. */
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
159 #define check_sum(a, b, overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
160 verify (INT_ADD_OVERFLOW (a, b) == (overflow)); \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
161 verify (INT_ADD_OVERFLOW (b, a) == (overflow))
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
162 check_sum (-1, LONG_MIN, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
163 check_sum (-1, UINT_MAX, false);
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
164 check_sum (- (long) 1, INT_MIN, INT_MIN == LONG_MIN);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
165 check_sum (U0, -1, true);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
166 check_sum (U0, 0, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
167 check_sum (U0, 1, false);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
168 check_sum (1, LONG_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
169 check_sum (1, UINT_MAX, true);
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
170 check_sum ((long) 1, INT_MAX, INT_MAX == LONG_MAX);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
171 check_sum (U1, INT_MAX, INT_MAX == UINT_MAX);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
172 check_sum (U1, INT_MIN, true);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
173
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
174 verify (! INT_SUBTRACT_OVERFLOW (INT_MAX, U1));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
175 verify (! INT_SUBTRACT_OVERFLOW (UINT_MAX, 1));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
176 verify (! INT_SUBTRACT_OVERFLOW (U0, -1));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
177 verify (INT_SUBTRACT_OVERFLOW (UINT_MAX, -1));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
178 verify (INT_SUBTRACT_OVERFLOW (INT_MIN, U1));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
179 verify (INT_SUBTRACT_OVERFLOW (-1, U0));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
180
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
181 #define check_product(a, b, overflow) \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
182 verify (INT_MULTIPLY_OVERFLOW (a, b) == (overflow)); \
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
183 verify (INT_MULTIPLY_OVERFLOW (b, a) == (overflow))
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
184
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
185 check_product (-1, U1, true);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
186 check_product (-1, INT_MIN, INT_NEGATE_OVERFLOW (INT_MIN));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
187 check_product (-1, UINT_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
188 check_product (-12345, LONG_MAX / -12345 - 1, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
189 check_product (-12345, LONG_MAX / -12345, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
190 check_product (0, -1, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
191 check_product (0, 0, false);
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
192 check_product (0, U0, false);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
193 check_product (0, 1, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
194 check_product (0, INT_MAX, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
195 check_product (0, INT_MIN, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
196 check_product (0, UINT_MAX, false);
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
197 check_product (U0, -1, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
198 check_product (U0, 0, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
199 check_product (U0, U0, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
200 check_product (U0, 1, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
201 check_product (U0, INT_MAX, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
202 check_product (U0, INT_MIN, false);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
203 check_product (U0, UINT_MAX, false);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
204 check_product (1, INT_MAX, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
205 check_product (1, INT_MIN, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
206 check_product (1, UINT_MAX, false);
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
207 check_product (U1, INT_MIN, true);
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
208 check_product (U1, INT_MAX, UINT_MAX < INT_MAX);
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
209 check_product (INT_MAX, UINT_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
210 check_product (INT_MAX, ULONG_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
211 check_product (INT_MIN, LONG_MAX / INT_MIN - 1, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
212 check_product (INT_MIN, LONG_MAX / INT_MIN, false);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
213 check_product (INT_MIN, UINT_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
214 check_product (INT_MIN, ULONG_MAX, true);
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
215
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
216 verify (INT_DIVIDE_OVERFLOW (INT_MIN, - (long) 1)
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
217 == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
218 verify (! INT_DIVIDE_OVERFLOW (INT_MIN, UINT_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
219 verify (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINTMAX_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
220 verify (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINT_MAX));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
221 verify (INT_DIVIDE_OVERFLOW (-11, (unsigned int) 10));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
222 verify (INT_DIVIDE_OVERFLOW (-10, (unsigned int) 10));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
223 verify (! INT_DIVIDE_OVERFLOW (-9, (unsigned int) 10));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
224 verify (INT_DIVIDE_OVERFLOW ((unsigned int) 11, -10));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
225 verify (INT_DIVIDE_OVERFLOW ((unsigned int) 10, -10));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
226 verify (! INT_DIVIDE_OVERFLOW (9u, -10));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
227
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
228 verify (INT_REMAINDER_OVERFLOW (INT_MIN, - (long) 1)
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
229 == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
230 verify (INT_REMAINDER_OVERFLOW (-1, UINT_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
231 verify (INT_REMAINDER_OVERFLOW ((intmax_t) -1, UINTMAX_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
232 verify (INT_REMAINDER_OVERFLOW (INTMAX_MIN, UINT_MAX)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
233 == (INTMAX_MAX < UINT_MAX
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
234 && - (unsigned int) INTMAX_MIN % UINT_MAX != 0));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
235 verify (INT_REMAINDER_OVERFLOW (INT_MIN, ULONG_MAX)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
236 == (INT_MIN % ULONG_MAX != 1));
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
237 verify (! INT_REMAINDER_OVERFLOW (U1, -1));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
238 verify (! INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39, -39));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
239 verify (INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39 + 1, -39));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
240 verify (INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39 - 1, -39));
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
241 verify (! INT_REMAINDER_OVERFLOW (LONG_MAX, -INT_MAX));
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
242
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
243 int
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
244 main (void)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
245 {
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
246 /* Test expressions that might not be integer constant expressions. */
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
247
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
248 /* TYPE_IS_INTEGER. */
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
249 ASSERT (TYPE_IS_INTEGER (bool));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
250 ASSERT (TYPE_IS_INTEGER (char));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
251 ASSERT (TYPE_IS_INTEGER (signed char));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
252 ASSERT (TYPE_IS_INTEGER (unsigned char));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
253 ASSERT (TYPE_IS_INTEGER (short int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
254 ASSERT (TYPE_IS_INTEGER (unsigned short int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
255 ASSERT (TYPE_IS_INTEGER (int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
256 ASSERT (TYPE_IS_INTEGER (unsigned int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
257 ASSERT (TYPE_IS_INTEGER (long int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
258 ASSERT (TYPE_IS_INTEGER (unsigned long int));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
259 ASSERT (TYPE_IS_INTEGER (intmax_t));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
260 ASSERT (TYPE_IS_INTEGER (uintmax_t));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
261 ASSERT (! TYPE_IS_INTEGER (float));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
262 ASSERT (! TYPE_IS_INTEGER (double));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
263 ASSERT (! TYPE_IS_INTEGER (long double));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
264
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
265 /* TYPE_SIGNED. */
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
266 ASSERT (TYPE_SIGNED (float));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
267 ASSERT (TYPE_SIGNED (double));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
268 ASSERT (TYPE_SIGNED (long double));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
269
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
270 return 0;
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
271 }