<sys/socket.h>: turn off MSG_NOSIGNAL
[minix3.git] / test / test49.c
bloba5c69dfc88c034853e5bdb6e023142737ab76b09
1 #include <assert.h>
2 #include <inttypes.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
9 #define TEST_64_BIT
11 #define ERR e(__LINE__)
13 int max_error = 4;
14 #include "common.h"
17 #define TEST_PRINTF(type, macro, value, result) \
18 { \
19 char buffer[256]; \
20 snprintf(buffer, sizeof(buffer), "%" macro, (type) value); \
21 if (strcmp(buffer, result) != 0) ERR; \
24 int main(void)
26 start(49);
28 /* test integer sizes */
29 if (sizeof(int8_t) != 1) ERR;
30 if (sizeof(uint8_t) != 1) ERR;
31 if (sizeof(int_fast8_t) < 1) ERR;
32 if (sizeof(uint_fast8_t) < 1) ERR;
33 if (sizeof(int_least8_t) < 1) ERR;
34 if (sizeof(uint_least8_t) < 1) ERR;
35 if (sizeof(int16_t) != 2) ERR;
36 if (sizeof(uint16_t) != 2) ERR;
37 if (sizeof(int_fast16_t) < 2) ERR;
38 if (sizeof(uint_fast16_t) < 2) ERR;
39 if (sizeof(int_least16_t) < 2) ERR;
40 if (sizeof(uint_least16_t) < 2) ERR;
41 if (sizeof(int32_t) != 4) ERR;
42 if (sizeof(uint32_t) != 4) ERR;
43 if (sizeof(int_fast32_t) < 4) ERR;
44 if (sizeof(uint_fast32_t) < 4) ERR;
45 if (sizeof(int_least32_t) < 4) ERR;
46 if (sizeof(uint_least32_t) < 4) ERR;
47 #ifdef TEST_64_BIT
48 if (sizeof(int64_t) != 8) ERR;
49 if (sizeof(uint64_t) != 8) ERR;
50 if (sizeof(int_fast64_t) < 8) ERR;
51 if (sizeof(uint_fast64_t) < 8) ERR;
52 if (sizeof(int_least64_t) < 8) ERR;
53 if (sizeof(uint_least64_t) < 8) ERR;
54 #endif
55 if (sizeof(intptr_t) != sizeof(void *)) ERR;
56 if (sizeof(uintptr_t) != sizeof(void *)) ERR;
57 #ifdef TEST_64_BIT
58 if (sizeof(intmax_t) < 8) ERR;
59 if (sizeof(uintmax_t) < 8) ERR;
60 #else
61 if (sizeof(intmax_t) < 4) ERR;
62 if (sizeof(uintmax_t) < 4) ERR;
63 #endif
65 /* test integer signedness */
66 if ((int8_t) (-1) >= 0) ERR;
67 if ((uint8_t) (-1) <= 0) ERR;
68 if ((int_fast8_t) (-1) >= 0) ERR;
69 if ((uint_fast8_t) (-1) <= 0) ERR;
70 if ((int_least8_t) (-1) >= 0) ERR;
71 if ((uint_least8_t) (-1) <= 0) ERR;
72 if ((int16_t) (-1) >= 0) ERR;
73 if ((uint16_t) (-1) <= 0) ERR;
74 if ((int_fast16_t) (-1) >= 0) ERR;
75 if ((uint_fast16_t) (-1) <= 0) ERR;
76 if ((int_least16_t) (-1) >= 0) ERR;
77 if ((uint_least16_t) (-1) <= 0) ERR;
78 if ((int32_t) (-1) >= 0) ERR;
79 if ((uint32_t) (-1) <= 0) ERR;
80 if ((int_fast32_t) (-1) >= 0) ERR;
81 if ((uint_fast32_t) (-1) <= 0) ERR;
82 if ((int_least32_t) (-1) >= 0) ERR;
83 if ((uint_least32_t) (-1) <= 0) ERR;
84 #ifdef TEST_64_BIT
85 if ((int64_t) (-1) >= 0) ERR;
86 if ((uint64_t) (-1) <= 0) ERR;
87 if ((int_fast64_t) (-1) >= 0) ERR;
88 if ((uint_fast64_t) (-1) <= 0) ERR;
89 if ((int_least64_t) (-1) >= 0) ERR;
90 if ((uint_least64_t) (-1) <= 0) ERR;
91 #endif
92 if ((intptr_t) (-1) >= 0) ERR;
93 if ((uintptr_t) (-1) <= 0) ERR;
94 if ((intptr_t) (-1) >= 0) ERR;
95 if ((uintptr_t) (-1) <= 0) ERR;
97 /* test printf */
98 TEST_PRINTF(int32_t, PRId32, INT32_MIN, "-2147483648");
99 TEST_PRINTF(int32_t, PRId32, INT32_MAX, "2147483647");
100 TEST_PRINTF(int32_t, PRIi32, INT32_MIN, "-2147483648");
101 TEST_PRINTF(int32_t, PRIi32, INT32_MAX, "2147483647");
102 TEST_PRINTF(uint32_t, PRIu32, UINT32_MAX, "4294967295");
103 TEST_PRINTF(uint32_t, PRIX32, UINT32_MAX, "FFFFFFFF");
104 TEST_PRINTF(uint32_t, PRIx32, UINT32_MAX, "ffffffff");
105 TEST_PRINTF(uint32_t, PRIo32, UINT32_MAX, "37777777777");
107 TEST_PRINTF(int_fast32_t, PRIdFAST32, INT32_MIN, "-2147483648");
108 TEST_PRINTF(int_fast32_t, PRIdFAST32, INT32_MAX, "2147483647");
109 TEST_PRINTF(int_fast32_t, PRIiFAST32, INT32_MIN, "-2147483648");
110 TEST_PRINTF(int_fast32_t, PRIiFAST32, INT32_MAX, "2147483647");
111 TEST_PRINTF(uint_fast32_t, PRIuFAST32, UINT32_MAX, "4294967295");
112 TEST_PRINTF(uint_fast32_t, PRIXFAST32, UINT32_MAX, "FFFFFFFF");
113 TEST_PRINTF(uint_fast32_t, PRIxFAST32, UINT32_MAX, "ffffffff");
114 TEST_PRINTF(uint_fast32_t, PRIoFAST32, UINT32_MAX, "37777777777");
116 TEST_PRINTF(int_least32_t, PRIdLEAST32, INT32_MIN, "-2147483648");
117 TEST_PRINTF(int_least32_t, PRIdLEAST32, INT32_MAX, "2147483647");
118 TEST_PRINTF(int_least32_t, PRIiLEAST32, INT32_MIN, "-2147483648");
119 TEST_PRINTF(int_least32_t, PRIiLEAST32, INT32_MAX, "2147483647");
120 TEST_PRINTF(uint_least32_t, PRIuLEAST32, UINT32_MAX, "4294967295");
121 TEST_PRINTF(uint_least32_t, PRIXLEAST32, UINT32_MAX, "FFFFFFFF");
122 TEST_PRINTF(uint_least32_t, PRIxLEAST32, UINT32_MAX, "ffffffff");
123 TEST_PRINTF(uint_least32_t, PRIoLEAST32, UINT32_MAX, "37777777777");
125 #ifdef TEST_64_BIT
126 TEST_PRINTF(int64_t, PRId64, INT64_MIN, "-9223372036854775808");
127 TEST_PRINTF(int64_t, PRId64, INT64_MAX, "9223372036854775807");
128 TEST_PRINTF(int64_t, PRIi64, INT64_MIN, "-9223372036854775808");
129 TEST_PRINTF(int64_t, PRIi64, INT64_MAX, "9223372036854775807");
130 TEST_PRINTF(uint64_t, PRIu64, UINT64_MAX, "18446744073709551615");
131 TEST_PRINTF(uint64_t, PRIX64, UINT64_MAX, "FFFFFFFFFFFFFFFF");
132 TEST_PRINTF(uint64_t, PRIx64, UINT64_MAX, "ffffffffffffffff");
133 TEST_PRINTF(uint64_t, PRIo64, UINT64_MAX, "1777777777777777777777");
135 TEST_PRINTF(int_fast64_t, PRIdFAST64, INT64_MIN, "-9223372036854775808");
136 TEST_PRINTF(int_fast64_t, PRIdFAST64, INT64_MAX, "9223372036854775807");
137 TEST_PRINTF(int_fast64_t, PRIiFAST64, INT64_MIN, "-9223372036854775808");
138 TEST_PRINTF(int_fast64_t, PRIiFAST64, INT64_MAX, "9223372036854775807");
139 TEST_PRINTF(uint_fast64_t, PRIuFAST64, UINT64_MAX, "18446744073709551615");
140 TEST_PRINTF(uint_fast64_t, PRIXFAST64, UINT64_MAX, "FFFFFFFFFFFFFFFF");
141 TEST_PRINTF(uint_fast64_t, PRIxFAST64, UINT64_MAX, "ffffffffffffffff");
142 TEST_PRINTF(uint_fast64_t, PRIoFAST64, UINT64_MAX, "1777777777777777777777");
144 TEST_PRINTF(int_least64_t, PRIdLEAST64, INT64_MIN, "-9223372036854775808");
145 TEST_PRINTF(int_least64_t, PRIdLEAST64, INT64_MAX, "9223372036854775807");
146 TEST_PRINTF(int_least64_t, PRIiLEAST64, INT64_MIN, "-9223372036854775808");
147 TEST_PRINTF(int_least64_t, PRIiLEAST64, INT64_MAX, "9223372036854775807");
148 TEST_PRINTF(uint_least64_t, PRIuLEAST64, UINT64_MAX, "18446744073709551615");
149 TEST_PRINTF(uint_least64_t, PRIXLEAST64, UINT64_MAX, "FFFFFFFFFFFFFFFF");
150 TEST_PRINTF(uint_least64_t, PRIxLEAST64, UINT64_MAX, "ffffffffffffffff");
151 TEST_PRINTF(uint_least64_t, PRIoLEAST64, UINT64_MAX, "1777777777777777777777");
153 TEST_PRINTF(intmax_t, PRIdMAX, INT64_MIN, "-9223372036854775808");
154 TEST_PRINTF(intmax_t, PRIdMAX, INT64_MAX, "9223372036854775807");
155 TEST_PRINTF(intmax_t, PRIiMAX, INT64_MIN, "-9223372036854775808");
156 TEST_PRINTF(intmax_t, PRIiMAX, INT64_MAX, "9223372036854775807");
157 TEST_PRINTF(uintmax_t, PRIuMAX, UINT64_MAX, "18446744073709551615");
158 TEST_PRINTF(uintmax_t, PRIXMAX, UINT64_MAX, "FFFFFFFFFFFFFFFF");
159 TEST_PRINTF(uintmax_t, PRIxMAX, UINT64_MAX, "ffffffffffffffff");
160 TEST_PRINTF(uintmax_t, PRIoMAX, UINT64_MAX, "1777777777777777777777");
161 #else
162 TEST_PRINTF(intmax_t, PRIdMAX, INT32_MIN, "-2147483648");
163 TEST_PRINTF(intmax_t, PRIdMAX, INT32_MAX, "2147483647");
164 TEST_PRINTF(intmax_t, PRIiMAX, INT32_MIN, "-2147483648");
165 TEST_PRINTF(intmax_t, PRIiMAX, INT32_MAX, "2147483647");
166 TEST_PRINTF(uintmax_t, PRIuMAX, UINT32_MAX, "4294967295");
167 TEST_PRINTF(uintmax_t, PRIXMAX, UINT32_MAX, "FFFFFFFF");
168 TEST_PRINTF(uintmax_t, PRIxMAX, UINT32_MAX, "ffffffff");
169 TEST_PRINTF(uintmax_t, PRIoMAX, UINT32_MAX, "37777777777");
170 #endif
172 TEST_PRINTF(intptr_t, PRIdPTR, INT32_MIN, "-2147483648");
173 TEST_PRINTF(intptr_t, PRIdPTR, INT32_MAX, "2147483647");
174 TEST_PRINTF(intptr_t, PRIiPTR, INT32_MIN, "-2147483648");
175 TEST_PRINTF(intptr_t, PRIiPTR, INT32_MAX, "2147483647");
176 TEST_PRINTF(uintptr_t, PRIuPTR, UINT32_MAX, "4294967295");
177 TEST_PRINTF(uintptr_t, PRIXPTR, UINT32_MAX, "FFFFFFFF");
178 TEST_PRINTF(uintptr_t, PRIxPTR, UINT32_MAX, "ffffffff");
179 TEST_PRINTF(uintptr_t, PRIoPTR, UINT32_MAX, "37777777777");
181 /* done */
182 quit();
183 return -1;