Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bitfirst.c.in
blob78586787529e2c62bdaa40e70506d7db73c0bb51
1 /* Test first bit 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 #include <limits.h>
15 volatile {type} i;
17 void
18 testTrailing(void)
20 #ifdef __SDCC // Todo: Enable for all C23 implementations
21 i = 0x0;
22 ASSERT (stdc_first_trailing_one(i) == 0);
23 ASSERT (stdc_first_trailing_zero(i) == 1);
25 i = 0x1;
26 ASSERT (stdc_first_trailing_one(i) == 1);
27 ASSERT (stdc_first_trailing_zero(i) == 2);
29 i = 0x2;
30 ASSERT (stdc_first_trailing_one(i) == 2);
31 ASSERT (stdc_first_trailing_zero(i) == 1);
33 i = 0x3;
34 ASSERT (stdc_first_trailing_one(i) == 1);
35 ASSERT (stdc_first_trailing_zero(i) == 3);
37 i = 0x7;
38 ASSERT (stdc_first_trailing_one(i) == 1);
39 ASSERT (stdc_first_trailing_zero(i) == 4);
41 i = 0x8;
42 ASSERT (stdc_first_trailing_one(i) == 4);
43 ASSERT (stdc_first_trailing_zero(i) == 1);
45 i = 0x9;
46 ASSERT (stdc_first_trailing_one(i) == 1);
47 ASSERT (stdc_first_trailing_zero(i) == 2);
48 #endif