Add uc_bv_find_first_zero
This commit is contained in:
@@ -79,6 +79,31 @@ START_TEST (test_bitvec_setall_clearall)
|
||||
|
||||
uc_bv_free(v);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
START_TEST (test_bitvec_find_first_zero)
|
||||
{
|
||||
uc_bv_integer buf[8];
|
||||
struct UCBitVec v = UC_BV_STATIC_INIT(buf);
|
||||
uc_bv_set_all(&v);
|
||||
|
||||
int bit = uc_bv_find_first_zero(&v);
|
||||
ck_assert_int_eq(bit, -1);
|
||||
|
||||
uc_bv_clr_bit(&v, 0);
|
||||
bit = uc_bv_find_first_zero(&v);
|
||||
ck_assert_int_eq(bit, 0);
|
||||
|
||||
uc_bv_set_bit(&v, 0);
|
||||
uc_bv_clr_bit(&v, 63);
|
||||
bit = uc_bv_find_first_zero(&v);
|
||||
ck_assert_int_eq(bit, 63);
|
||||
|
||||
uc_bv_set_bit(&v, 63);
|
||||
uc_bv_clr_bit(&v, sizeof buf * CHAR_BIT - 1);
|
||||
bit = uc_bv_find_first_zero(&v);
|
||||
ck_assert_int_eq(bit, sizeof buf * CHAR_BIT - 1);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@@ -91,6 +116,8 @@ Suite *bitvec_suite(void)
|
||||
tcase_add_test(tc, test_bitvec_set_bits_from_array);
|
||||
tcase_add_test(tc, test_bitvec_clearbit);
|
||||
tcase_add_test(tc, test_bitvec_setall_clearall);
|
||||
tcase_add_test(tc, test_bitvec_find_first_zero);
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user