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