hawk/t/t-002.c

35 lines
722 B
C
Raw Permalink Normal View History

2019-12-13 04:29:58 +00:00
/* test bit position functions */
#include <hawk-utl.h>
#include <stdio.h>
#include "tap.h"
2019-12-13 04:29:58 +00:00
int main ()
{
int i, j;
hawk_oow_t v;
no_plan ();
/*printf ("QSE_OOW_BITS => %d, sizeof(hawk_oow_t)=%d\n", (int)HAWK_OOW_BITS, (int)sizeof(hawk_oow_t));*/
2019-12-13 04:29:58 +00:00
for (i = 0; i < HAWK_OOW_BITS; i++)
{
v = ((hawk_oow_t)1 << i);
j = hawk_get_pos_of_msb_set_pow2(v);
/*printf ("msb(pow2) %d %d ==> %llx\n", i, j, (long long int)v);*/
OK (i == j, "msb(pow2) position tester");
2019-12-13 04:29:58 +00:00
}
for (i = 0; i < HAWK_OOW_BITS; i++)
{
v = ((hawk_oow_t)1 << i);
v |= 1;
j = hawk_get_pos_of_msb_set(v);
/*printf ("msb %d %d ==> %llx\n", i, j, (long long int)v);*/
OK (i == j, "msb position tester");
2019-12-13 04:29:58 +00:00
}
return exit_status();
2019-12-13 04:29:58 +00:00
}