|
|
1.1 root 1: /* The Plum Hall Validation Suite for C
2: * Unpublished copyright (c) 1986-1991, Chiron Systems Inc and Plum Hall Inc.
3: * VERSION: 4
4: * DATE: 1993-01-01
5: * The "ANSI" mode of this suite corresponds to official ANSI C, X3.159-1989.
6: * As per your license agreement, your distribution is not to be moved or copied outside the Designated Site
7: * without specific permission from Plum Hall Inc.
8: */
9:
10: #define LIB_TEST 1
11: #include "defs.h"
12: #if !ANSI || !HAS_PROTOTYPES
13: #define SKIP41 1
14: #endif
15:
16: #include "flags.h"
17: #ifndef SKIP41
18: #include <limits.h>
19: /*
20: * 4.1.4 - Limits <limits.h>
21: */
22: void d41_4a()
23: {
24: Filename = "d41b.c";
25:
26: /* All of these must be restricted constant expresions. */
27: if (CHAR_BIT < 8)
28: complain(__LINE__);
29: if (SCHAR_MIN > -127)
30: complain(__LINE__);
31: if (SCHAR_MAX < 127)
32: complain(__LINE__);
33: if (UCHAR_MAX < 255U)
34: complain(__LINE__);
35: if (CHAR_MIN != SCHAR_MIN && CHAR_MIN != 0)
36: complain(__LINE__);
37: if (CHAR_MAX != SCHAR_MAX && CHAR_MAX != UCHAR_MAX)
38: complain(__LINE__);
39: if (SHRT_MIN > -32767)
40: complain(__LINE__);
41: if (SHRT_MAX < 32767)
42: complain(__LINE__);
43: if (USHRT_MAX < 65535U)
44: complain(__LINE__);
45: if (INT_MIN > -32767)
46: complain(__LINE__);
47: if (INT_MAX < 32767)
48: complain(__LINE__);
49: if (UINT_MAX < 65535U)
50: complain(__LINE__);
51: if (LONG_MIN > -2147483647)
52: complain(__LINE__);
53: if (LONG_MAX < 2147483647)
54: complain(__LINE__);
55: if (ULONG_MAX < 0xffffffff)
56: complain(__LINE__);
57:
58: #ifndef SKIP_1992_PENDING
59: /* Review Board meeting August 1992 approved update item #461:
60: * ... d41b.c ought to contain some
61: * tests to verify that these are all restricted constant expressions,
62: * suitable to being tested by #if . If you try to implement them
63: * with casts, they won't be testable by #if .
64: * As of now, this conformance test is in the "Pending" category.
65: * It will not become a formal certification requirement until the
66: * 1993 Review Board meeting.
67: */
68: /* All of these must be restricted constant expresions. */
69: #if (CHAR_BIT < 8)
70: complain(__LINE__);
71: #endif
72: #if (SCHAR_MIN > -127)
73: complain(__LINE__);
74: #endif
75: #if (SCHAR_MAX < 127)
76: complain(__LINE__);
77: #endif
78: #if (UCHAR_MAX < 255U)
79: complain(__LINE__);
80: #endif
81: #if (CHAR_MIN != SCHAR_MIN && CHAR_MIN != 0)
82: complain(__LINE__);
83: #endif
84: #if (CHAR_MAX != SCHAR_MAX && CHAR_MAX != UCHAR_MAX)
85: complain(__LINE__);
86: #endif
87: #if (SHRT_MIN > -32767)
88: complain(__LINE__);
89: #endif
90: #if (SHRT_MAX < 32767)
91: complain(__LINE__);
92: #endif
93: #if (USHRT_MAX < 65535U)
94: complain(__LINE__);
95: #endif
96: #if (INT_MIN > -32767)
97: complain(__LINE__);
98: #endif
99: #if (INT_MAX < 32767)
100: complain(__LINE__);
101: #endif
102: #if (UINT_MAX < 65535U)
103: complain(__LINE__);
104: #endif
105: #if (LONG_MIN > -2147483647)
106: complain(__LINE__);
107: #endif
108: #if (LONG_MAX < 2147483647)
109: complain(__LINE__);
110: #endif
111: #if (ULONG_MAX < 0xffffffff)
112: complain(__LINE__);
113: #endif
114: #endif /* SKIP_1992_PENDING */
115:
116: #ifndef SKIP_1992_PENDING
117: /* Review Board meeting August 1992 approved update item #511:
118: * "There should be explicit tests that the type of the <limits.h>
119: * constants is the appropriate type. This probably means a set of
120: * sizeof tests."
121: * As of now, this conformance test is in the "Pending" category.
122: * It will not become a formal certification requirement until the
123: * 1993 Review Board meeting.
124: */
125: if(sizeof(SCHAR_MIN) != sizeof(int))
126: complain(__LINE__);
127: if(sizeof(SCHAR_MAX) != sizeof(int))
128: complain(__LINE__);
129: if(sizeof(UCHAR_MAX) != sizeof(int))
130: complain(__LINE__);
131: if(sizeof(CHAR_MIN) != sizeof(int))
132: complain(__LINE__);
133: if(sizeof(CHAR_MAX) != sizeof(int))
134: complain(__LINE__);
135: if(sizeof(SHRT_MIN) != sizeof(int))
136: complain(__LINE__);
137: if(sizeof(SHRT_MAX) != sizeof(int))
138: complain(__LINE__);
139: if(sizeof(USHRT_MAX) != sizeof(int))
140: complain(__LINE__);
141: if(sizeof(INT_MIN) != sizeof(int))
142: complain(__LINE__);
143: if(sizeof(INT_MAX) != sizeof(int))
144: complain(__LINE__);
145: if(sizeof(UINT_MAX) != sizeof(int))
146: complain(__LINE__);
147: if(sizeof(LONG_MIN) != sizeof(long))
148: complain(__LINE__);
149: if(sizeof(LONG_MAX) != sizeof(long))
150: complain(__LINE__);
151: if(sizeof(ULONG_MAX) != sizeof(unsigned long))
152: complain(__LINE__);
153: #endif /* SKIP_1992_PENDING */
154:
155:
156: #if !defined(CHAR_BIT) || !defined(SCHAR_MIN) || !defined(SCHAR_MAX) || !defined(UCHAR_MAX) || !defined(CHAR_MIN)
157: complain(__LINE__);
158: #endif
159: #if !defined(CHAR_MAX) || !defined(SHRT_MIN) || !defined(SHRT_MAX) || !defined(USHRT_MAX) || !defined(INT_MIN)
160: complain(__LINE__);
161: #endif
162: #if !defined(INT_MAX) || !defined(UINT_MAX) || !defined(LONG_MIN) || !defined(LONG_MAX) || !defined(ULONG_MAX)
163: complain(__LINE__);
164: #endif
165:
166: /* ANSI8809 - Each limit must be properly represented to equal its value stored in appropriate object */
167: #if ANSI8809
168: {
169: char cmin = CHAR_MIN; char c = CHAR_MAX;
170: signed char scmin = SCHAR_MIN; signed char sc = SCHAR_MAX; unsigned char uc = UCHAR_MAX;
171: short smin = SHRT_MIN; short s = SHRT_MAX; unsigned short us = USHRT_MAX;
172: int imin = INT_MIN; int i = INT_MAX; unsigned int ui = UINT_MAX;
173: long Lmin = LONG_MIN; long L = LONG_MAX; unsigned long uL = ULONG_MAX;
174:
175: if (CHAR_MIN != cmin)
176: complain(__LINE__);
177: if (CHAR_MAX != c)
178: complain(__LINE__);
179: if (SCHAR_MIN != scmin)
180: complain(__LINE__);
181: if (SCHAR_MAX != sc)
182: complain(__LINE__);
183: if (UCHAR_MAX != uc)
184: complain(__LINE__);
185: if (SHRT_MIN != smin)
186: complain(__LINE__);
187: if (SHRT_MAX != s)
188: complain(__LINE__);
189: if (USHRT_MAX != us)
190: complain(__LINE__);
191: if (INT_MIN != imin)
192: complain(__LINE__);
193: if (INT_MAX != i)
194: complain(__LINE__);
195:
196:
197:
198: if (UINT_MAX != ui)
199: complain(__LINE__);
200: if (LONG_MIN != Lmin)
201: complain(__LINE__);
202: if (LONG_MAX != L)
203: complain(__LINE__);
204: if (ULONG_MAX != uL)
205: complain(__LINE__);
206: }
207: #endif /* ANSI8809 */
208: }
209: #else /* SKIP41 */
210: int skp41b = 1; /* must have one def */
211: #endif /* SKIP41 */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.