annotate tests/test-intprops.c @ 14773:ee797efcd830

intprops-tests: work around HP-UX 11.23 cc bug with constants * tests/test-intprops.c (VERIFY): New macro. (main): Use it, instead of verify, to work around the compiler bug; see <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 19 May 2011 19:16:43 -0700
parents 05ca371c9c6e
children 82b7de24fe12
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
14773
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
29 /* 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
30 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
31 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
32 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
33 <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
34 #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
35 # 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
36 #else
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
37 # define VERIFY(x) ASSERT (x)
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
38 #endif
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
39
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
40 int
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 main (void)
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 {
14773
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
43 /* 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
44 ASSERT otherwise. */
14761
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
45
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
46 /* TYPE_IS_INTEGER. */
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
63 /* 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
64 /* 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 ASSERT (TYPE_SIGNED (float));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
76 ASSERT (TYPE_SIGNED (double));
6c5502aeb486 intprop-tests: port to older and more-pedantic compilers
Paul Eggert <eggert@cs.ucla.edu>
parents: 14741
diff changeset
77 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
78
14773
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
79 /* 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
80 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
81 ? (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
82 && ! 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
83 : (! 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
84 && (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
85
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
86 /* 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
110 /* 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
111 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
112 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
113
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
114 /* 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
115 #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
116 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
117 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
118 #endif
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
119 #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
120 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
121 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
122 #endif
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
123
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
124 /* 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
125 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
126 #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
127 (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
128 && 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
129 #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
130 (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
131 && 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
132
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, 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142
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 (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
144 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
145 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
146 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
147 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
148 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
149
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_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
151 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
152 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
153 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
154 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
155 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
156 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
157
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_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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166
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 (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
168 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
169 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
170 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
171 -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
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 (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
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 (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
176 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
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 (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
180 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
181 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
182
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
183 /* 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
184 #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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
199 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
200 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
201 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
202 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
203 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
204 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
205
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
206 #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
207 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
208 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
209
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240
ee797efcd830 intprops-tests: work around HP-UX 11.23 cc bug with constants
Paul Eggert <eggert@cs.ucla.edu>
parents: 14771
diff changeset
241 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
242 == (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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252
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_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
254 == (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
255 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
256 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
257 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
258 == (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
259 && - (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
260 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
261 == (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
262 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
263 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
264 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
265 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
266 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
267
14741
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
268 return 0;
eb6ac457b650 intprops-tests: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
269 }