struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bitcount.c.in
blobb60615adfc9ae7dfc645afde5107edc39c32df95
1 /* Test count operations from stdbit.h
3 type: unsigned short, unsigned int, unsigned long, unsigned long long
4 */
6 #include <testfwk.h>
8 #ifdef __SDCC // Todo: Enable for all C23 implementations
9 #pragma std_c23
10 #include <stdbit.h>
11 #endif
13 volatile {type} i, j;
15 void
16 testCount(void)
18 #ifdef __SDCC // Todo: Enable for all C23 implementations
19 i = 0x10;
20 j = ~i;
21 ASSERT (stdc_count_ones(i) == 1);
22 ASSERT (stdc_count_zeros(j) == 1);
23 ASSERT (stdc_has_single_bit(i));
24 ASSERT (!stdc_has_single_bit(j));
26 i = 0xff;
27 j = ~i;
28 ASSERT (stdc_count_ones(i) == 8);
29 ASSERT (stdc_count_zeros(j) == 8);
30 ASSERT (!stdc_has_single_bit(i));
31 ASSERT (!stdc_has_single_bit(j));
32 #endif