1 /* It is important that this comes first to not hide effects introduced
12 long long int val
= 0;
24 #define TEST(name, format, expected) \
25 printf ("%-12s expected = %-20" format " actual = %" format "\n", \
26 #name ":", expected, name); \
27 result |= name != expected
29 /* The limits from ISO C99. */
31 /* We cannot support anything but 8-bit chars. */
32 TEST (CHAR_BIT
, "d", 8);
33 TEST (SCHAR_MIN
, "d", -128);
34 TEST (SCHAR_MAX
, "d", 127);
35 TEST (UCHAR_MAX
, "d", 255);
37 TEST (SHRT_MIN
, "d", -(1 << (sizeof (short int) * CHAR_BIT
- 1)));
38 TEST (SHRT_MAX
, "d", (1 << (sizeof (short int) * CHAR_BIT
- 1)) - 1);
39 TEST (USHRT_MAX
, "d", (1 << sizeof (short int) * CHAR_BIT
) - 1);
41 TEST (INT_MIN
, "d", (int) -bitval (sizeof (int) * CHAR_BIT
- 1) - 1);
42 TEST (INT_MAX
, "d", (int) bitval (sizeof (int) * CHAR_BIT
- 1));
44 (unsigned int) bitval (sizeof (unsigned int) * CHAR_BIT
));
47 (long int) -bitval (sizeof (long int) * CHAR_BIT
- 1) - 1);
48 TEST (LONG_MAX
, "ld", (long int) bitval (sizeof (long int) * CHAR_BIT
- 1));
49 TEST (ULONG_MAX
, "lu",
50 (unsigned long int) bitval (sizeof (unsigned long int) * CHAR_BIT
));
52 TEST (LLONG_MIN
, "lld", -bitval (sizeof (long long int) * CHAR_BIT
- 1) - 1);
53 TEST (LLONG_MAX
, "lld", bitval (sizeof (long long int) * CHAR_BIT
- 1));
54 TEST (ULLONG_MAX
, "llu",
55 (unsigned long long int) bitval (sizeof (unsigned long long int)
58 /* Values from POSIX and Unix. */
60 TEST (PAGESIZE
, "d", getpagesize ());
61 #elif defined (PAGE_SIZE)
62 TEST (PAGE_SIZE
, "d", getpagesize ());
65 TEST (WORD_BIT
, "d", (int) sizeof (int) * CHAR_BIT
);
66 TEST (LONG_BIT
, "d", (int) sizeof (long int) * CHAR_BIT
);
71 #define TEST_FUNCTION do_test ()
72 #include "../test-skeleton.c"