Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-intprops.c @ 17249:e542fd46ad6f
maint: update all copyright year number ranges
Run "make update-copyright". Compare to commit 1602f0a from last year.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Tue, 01 Jan 2013 00:50:58 +0000 |
parents | 8250f2777afc |
children |
rev | line source |
---|---|
14741 | 1 /* Test intprops.h. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. |
14741 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
16 | |
17 /* Written by Paul Eggert. */ | |
18 | |
14825
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
19 /* Tell gcc not to warn about the many (X < 0) expressions that |
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
20 the overflow macros expand to. */ |
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
21 #if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ |
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
22 # pragma GCC diagnostic ignored "-Wtype-limits" |
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
23 #endif |
82b7de24fe12
test-intprops: disable -Wtype-limits diagnostics
Paul Eggert <eggert@cs.ucla.edu>
parents:
14773
diff
changeset
|
24 |
14741 | 25 #include <config.h> |
26 | |
27 #include "intprops.h" | |
28 #include "verify.h" | |
29 | |
30 #include <stdbool.h> | |
31 #include <inttypes.h> | |
32 | |
14761
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
33 #include "macros.h" |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
34 |
14773
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
35 /* VERIFY (X) uses a static assertion for compilers that are known to work, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
36 and falls back on a dynamic assertion for other compilers. |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
37 These tests should be checkable via 'verify' rather than 'ASSERT', but |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
38 using 'verify' would run into a bug with HP-UX 11.23 cc; see |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
39 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
40 #if __GNUC__ || __SUNPRO_C |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
41 # define VERIFY(x) do { verify (x); } while (0) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
42 #else |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
43 # define VERIFY(x) ASSERT (x) |
14741 | 44 #endif |
45 | |
46 int | |
47 main (void) | |
48 { | |
14773
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
49 /* Use VERIFY for tests that must be integer constant expressions, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
50 ASSERT otherwise. */ |
14761
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
51 |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
52 /* TYPE_IS_INTEGER. */ |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
69 /* TYPE_SIGNED. */ |
14773
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
70 /* VERIFY (! TYPE_SIGNED (bool)); // not guaranteed by gnulib substitute */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
71 VERIFY (TYPE_SIGNED (signed char)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
72 VERIFY (! TYPE_SIGNED (unsigned char)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
73 VERIFY (TYPE_SIGNED (short int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
74 VERIFY (! TYPE_SIGNED (unsigned short int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
75 VERIFY (TYPE_SIGNED (int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
76 VERIFY (! TYPE_SIGNED (unsigned int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
77 VERIFY (TYPE_SIGNED (long int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
78 VERIFY (! TYPE_SIGNED (unsigned long int)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
79 VERIFY (TYPE_SIGNED (intmax_t)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
80 VERIFY (! TYPE_SIGNED (uintmax_t)); |
14761
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
81 ASSERT (TYPE_SIGNED (float)); |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
82 ASSERT (TYPE_SIGNED (double)); |
6c5502aeb486
intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents:
14741
diff
changeset
|
83 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
|
84 |
14773
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
85 /* Integer representation. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
86 VERIFY (INT_MIN + INT_MAX < 0 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
87 ? (TYPE_TWOS_COMPLEMENT (int) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
88 && ! TYPE_ONES_COMPLEMENT (int) && ! TYPE_SIGNED_MAGNITUDE (int)) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
89 : (! TYPE_TWOS_COMPLEMENT (int) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
90 && (TYPE_ONES_COMPLEMENT (int) || TYPE_SIGNED_MAGNITUDE (int)))); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
91 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
92 /* TYPE_MINIMUM, TYPE_MAXIMUM. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
93 VERIFY (TYPE_MINIMUM (char) == CHAR_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
94 VERIFY (TYPE_MAXIMUM (char) == CHAR_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
95 VERIFY (TYPE_MINIMUM (unsigned char) == 0); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
96 VERIFY (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
97 VERIFY (TYPE_MINIMUM (signed char) == SCHAR_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
98 VERIFY (TYPE_MAXIMUM (signed char) == SCHAR_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
99 VERIFY (TYPE_MINIMUM (short int) == SHRT_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
100 VERIFY (TYPE_MAXIMUM (short int) == SHRT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
101 VERIFY (TYPE_MINIMUM (unsigned short int) == 0); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
102 VERIFY (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
103 VERIFY (TYPE_MINIMUM (int) == INT_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
104 VERIFY (TYPE_MAXIMUM (int) == INT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
105 VERIFY (TYPE_MINIMUM (unsigned int) == 0); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
106 VERIFY (TYPE_MAXIMUM (unsigned int) == UINT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
107 VERIFY (TYPE_MINIMUM (long int) == LONG_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
108 VERIFY (TYPE_MAXIMUM (long int) == LONG_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
109 VERIFY (TYPE_MINIMUM (unsigned long int) == 0); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
110 VERIFY (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
111 VERIFY (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
112 VERIFY (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
113 VERIFY (TYPE_MINIMUM (uintmax_t) == 0); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
114 VERIFY (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
115 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
116 /* INT_BITS_STRLEN_BOUND. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
117 VERIFY (INT_BITS_STRLEN_BOUND (1) == 1); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
118 VERIFY (INT_BITS_STRLEN_BOUND (2620) == 789); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
119 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
120 /* INT_STRLEN_BOUND, INT_BUFSIZE_BOUND. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
121 #ifdef INT32_MAX /* POSIX guarantees int32_t; this ports to non-POSIX. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
122 VERIFY (INT_STRLEN_BOUND (int32_t) == sizeof ("-2147483648") - 1); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
123 VERIFY (INT_BUFSIZE_BOUND (int32_t) == sizeof ("-2147483648")); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
124 #endif |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
125 #ifdef INT64_MAX |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
126 VERIFY (INT_STRLEN_BOUND (int64_t) == sizeof ("-9223372036854775808") - 1); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
127 VERIFY (INT_BUFSIZE_BOUND (int64_t) == sizeof ("-9223372036854775808")); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
128 #endif |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
129 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
130 /* All the INT_<op>_RANGE_OVERFLOW tests are equally valid as |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
131 INT_<op>_OVERFLOW tests, so define a single macro to do both. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
132 #define CHECK_BINOP(op, a, b, min, max, overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
133 (INT_##op##_RANGE_OVERFLOW (a, b, min, max) == (overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
134 && INT_##op##_OVERFLOW (a, b) == (overflow)) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
135 #define CHECK_UNOP(op, a, min, max, overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
136 (INT_##op##_RANGE_OVERFLOW (a, min, max) == (overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
137 && INT_##op##_OVERFLOW (a) == (overflow)) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
138 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
139 /* INT_<op>_RANGE_OVERFLOW, INT_<op>_OVERFLOW. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
140 VERIFY (INT_ADD_RANGE_OVERFLOW (INT_MAX, 1, INT_MIN, INT_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
141 VERIFY (INT_ADD_OVERFLOW (INT_MAX, 1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
142 VERIFY (CHECK_BINOP (ADD, INT_MAX, 1, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
143 VERIFY (CHECK_BINOP (ADD, INT_MAX, -1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
144 VERIFY (CHECK_BINOP (ADD, INT_MIN, 1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
145 VERIFY (CHECK_BINOP (ADD, INT_MIN, -1, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
146 VERIFY (CHECK_BINOP (ADD, UINT_MAX, 1u, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
147 VERIFY (CHECK_BINOP (ADD, 0u, 1u, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
148 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
149 VERIFY (CHECK_BINOP (SUBTRACT, INT_MAX, 1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
150 VERIFY (CHECK_BINOP (SUBTRACT, INT_MAX, -1, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
151 VERIFY (CHECK_BINOP (SUBTRACT, INT_MIN, 1, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
152 VERIFY (CHECK_BINOP (SUBTRACT, INT_MIN, -1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
153 VERIFY (CHECK_BINOP (SUBTRACT, UINT_MAX, 1u, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
154 VERIFY (CHECK_BINOP (SUBTRACT, 0u, 1u, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
155 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
156 VERIFY (CHECK_UNOP (NEGATE, INT_MIN, INT_MIN, INT_MAX, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
157 TYPE_TWOS_COMPLEMENT (int))); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
158 VERIFY (CHECK_UNOP (NEGATE, 0, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
159 VERIFY (CHECK_UNOP (NEGATE, INT_MAX, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
160 VERIFY (CHECK_UNOP (NEGATE, 0u, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
161 VERIFY (CHECK_UNOP (NEGATE, 1u, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
162 VERIFY (CHECK_UNOP (NEGATE, UINT_MAX, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
163 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
164 VERIFY (CHECK_BINOP (MULTIPLY, INT_MAX, INT_MAX, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
165 VERIFY (CHECK_BINOP (MULTIPLY, INT_MAX, INT_MIN, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
166 VERIFY (CHECK_BINOP (MULTIPLY, INT_MIN, INT_MAX, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
167 VERIFY (CHECK_BINOP (MULTIPLY, INT_MIN, INT_MIN, INT_MIN, INT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
168 VERIFY (CHECK_BINOP (MULTIPLY, -1, INT_MIN, INT_MIN, INT_MAX, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
169 INT_NEGATE_OVERFLOW (INT_MIN))); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
170 VERIFY (CHECK_BINOP (MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
171 LONG_MIN, LONG_MIN, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
172 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
173 VERIFY (CHECK_BINOP (DIVIDE, INT_MIN, -1, INT_MIN, INT_MAX, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
174 INT_NEGATE_OVERFLOW (INT_MIN))); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
175 VERIFY (CHECK_BINOP (DIVIDE, INT_MAX, 1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
176 VERIFY (CHECK_BINOP (DIVIDE, (unsigned int) INT_MIN, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
177 -1u, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
178 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
179 VERIFY (CHECK_BINOP (REMAINDER, INT_MIN, -1, INT_MIN, INT_MAX, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
180 INT_NEGATE_OVERFLOW (INT_MIN))); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
181 VERIFY (CHECK_BINOP (REMAINDER, INT_MAX, 1, INT_MIN, INT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
182 VERIFY (CHECK_BINOP (REMAINDER, (unsigned int) INT_MIN, |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
183 -1u, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
184 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
185 VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX, 1, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
186 VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX / 2 + 1, 1, 0u, UINT_MAX, true)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
187 VERIFY (CHECK_BINOP (LEFT_SHIFT, UINT_MAX / 2, 1, 0u, UINT_MAX, false)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
188 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
189 /* INT_<op>_OVERFLOW with mixed types. */ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
190 #define CHECK_SUM(a, b, overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
191 VERIFY (INT_ADD_OVERFLOW (a, b) == (overflow)); \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
192 VERIFY (INT_ADD_OVERFLOW (b, a) == (overflow)) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
193 CHECK_SUM (-1, LONG_MIN, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
194 CHECK_SUM (-1, UINT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
195 CHECK_SUM (-1L, INT_MIN, INT_MIN == LONG_MIN); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
196 CHECK_SUM (0u, -1, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
197 CHECK_SUM (0u, 0, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
198 CHECK_SUM (0u, 1, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
199 CHECK_SUM (1, LONG_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
200 CHECK_SUM (1, UINT_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
201 CHECK_SUM (1L, INT_MAX, INT_MAX == LONG_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
202 CHECK_SUM (1u, INT_MAX, INT_MAX == UINT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
203 CHECK_SUM (1u, INT_MIN, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
204 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
205 VERIFY (! INT_SUBTRACT_OVERFLOW (INT_MAX, 1u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
206 VERIFY (! INT_SUBTRACT_OVERFLOW (UINT_MAX, 1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
207 VERIFY (! INT_SUBTRACT_OVERFLOW (0u, -1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
208 VERIFY (INT_SUBTRACT_OVERFLOW (UINT_MAX, -1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
209 VERIFY (INT_SUBTRACT_OVERFLOW (INT_MIN, 1u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
210 VERIFY (INT_SUBTRACT_OVERFLOW (-1, 0u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
211 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
212 #define CHECK_PRODUCT(a, b, overflow) \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
213 VERIFY (INT_MULTIPLY_OVERFLOW (a, b) == (overflow)); \ |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
214 VERIFY (INT_MULTIPLY_OVERFLOW (b, a) == (overflow)) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
215 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
216 CHECK_PRODUCT (-1, 1u, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
217 CHECK_PRODUCT (-1, INT_MIN, INT_NEGATE_OVERFLOW (INT_MIN)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
218 CHECK_PRODUCT (-1, UINT_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
219 CHECK_PRODUCT (-12345, LONG_MAX / -12345 - 1, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
220 CHECK_PRODUCT (-12345, LONG_MAX / -12345, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
221 CHECK_PRODUCT (0, -1, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
222 CHECK_PRODUCT (0, 0, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
223 CHECK_PRODUCT (0, 0u, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
224 CHECK_PRODUCT (0, 1, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
225 CHECK_PRODUCT (0, INT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
226 CHECK_PRODUCT (0, INT_MIN, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
227 CHECK_PRODUCT (0, UINT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
228 CHECK_PRODUCT (0u, -1, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
229 CHECK_PRODUCT (0u, 0, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
230 CHECK_PRODUCT (0u, 0u, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
231 CHECK_PRODUCT (0u, 1, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
232 CHECK_PRODUCT (0u, INT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
233 CHECK_PRODUCT (0u, INT_MIN, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
234 CHECK_PRODUCT (0u, UINT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
235 CHECK_PRODUCT (1, INT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
236 CHECK_PRODUCT (1, INT_MIN, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
237 CHECK_PRODUCT (1, UINT_MAX, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
238 CHECK_PRODUCT (1u, INT_MIN, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
239 CHECK_PRODUCT (1u, INT_MAX, UINT_MAX < INT_MAX); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
240 CHECK_PRODUCT (INT_MAX, UINT_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
241 CHECK_PRODUCT (INT_MAX, ULONG_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
242 CHECK_PRODUCT (INT_MIN, LONG_MAX / INT_MIN - 1, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
243 CHECK_PRODUCT (INT_MIN, LONG_MAX / INT_MIN, false); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
244 CHECK_PRODUCT (INT_MIN, UINT_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
245 CHECK_PRODUCT (INT_MIN, ULONG_MAX, true); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
246 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
247 VERIFY (INT_DIVIDE_OVERFLOW (INT_MIN, -1L) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
248 == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
249 VERIFY (! INT_DIVIDE_OVERFLOW (INT_MIN, UINT_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
250 VERIFY (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINTMAX_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
251 VERIFY (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINT_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
252 VERIFY (INT_DIVIDE_OVERFLOW (-11, 10u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
253 VERIFY (INT_DIVIDE_OVERFLOW (-10, 10u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
254 VERIFY (! INT_DIVIDE_OVERFLOW (-9, 10u)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
255 VERIFY (INT_DIVIDE_OVERFLOW (11u, -10)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
256 VERIFY (INT_DIVIDE_OVERFLOW (10u, -10)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
257 VERIFY (! INT_DIVIDE_OVERFLOW (9u, -10)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
258 |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
259 VERIFY (INT_REMAINDER_OVERFLOW (INT_MIN, -1L) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
260 == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
261 VERIFY (INT_REMAINDER_OVERFLOW (-1, UINT_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
262 VERIFY (INT_REMAINDER_OVERFLOW ((intmax_t) -1, UINTMAX_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
263 VERIFY (INT_REMAINDER_OVERFLOW (INTMAX_MIN, UINT_MAX) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
264 == (INTMAX_MAX < UINT_MAX |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
265 && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
266 VERIFY (INT_REMAINDER_OVERFLOW (INT_MIN, ULONG_MAX) |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
267 == (INT_MIN % ULONG_MAX != 1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
268 VERIFY (! INT_REMAINDER_OVERFLOW (1u, -1)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
269 VERIFY (! INT_REMAINDER_OVERFLOW (37*39u, -39)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
270 VERIFY (INT_REMAINDER_OVERFLOW (37*39u + 1, -39)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
271 VERIFY (INT_REMAINDER_OVERFLOW (37*39u - 1, -39)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
272 VERIFY (! INT_REMAINDER_OVERFLOW (LONG_MAX, -INT_MAX)); |
ee797efcd830
intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents:
14771
diff
changeset
|
273 |
14741 | 274 return 0; |
275 } |