Namespace the bitvec functions

This commit is contained in:
Nils O. Selåsdal
2013-03-07 18:15:20 +01:00
parent 8badeaf857
commit 5e376d47fc
3 changed files with 52 additions and 52 deletions
+21 -21
View File
@@ -4,67 +4,67 @@
START_TEST (test_bitvec_1)
unsigned long s[3] = {0};
struct bitvec v = BITVEC_STATIC_INIT(s);
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
for (i = 0; i < sizeof s * 8; i++)
fail_if(get_bit(&v, i), "bit %zu is not 0", i);
fail_if(uc_bv_get_bit(&v, i), "bit %zu is not 0", i);
END_TEST
START_TEST (test_bitvec_2)
unsigned long s[3] = {0};
struct bitvec v = BITVEC_STATIC_INIT(s);
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
for (i = 0; i < sizeof s * 8; i++)
set_bit(&v, i);
uc_bv_set_bit(&v, i);
for (i = 0; i < sizeof s * 8; i++)
fail_if(get_bit(&v, i) != 1 , "bit %zu is not 1", i);
fail_if(uc_bv_get_bit(&v, i) != 1 , "bit %zu is not 1", i);
END_TEST
START_TEST (test_bitvec_clearbit)
unsigned long s[3] = {-1, -1, -1};
struct bitvec v = BITVEC_STATIC_INIT(s);
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
for (i = 0; i < sizeof(unsigned long) * 8; i++)
fail_if(get_bit(&v, i) != 1 , "bit %zu is not 1", i);
fail_if(uc_bv_get_bit(&v, i) != 1 , "bit %zu is not 1", i);
for (i = 0; i < sizeof(unsigned long) * 8; i++)
clear_bit(&v, i);
uc_bv_clr_bit(&v, i);
for (i = 0; i < sizeof(unsigned long) * 8; i++)
fail_if(get_bit(&v, i) != 0 , "bit %zu is not 0", i);
fail_if(uc_bv_get_bit(&v, i) != 0 , "bit %zu is not 0", i);
END_TEST
START_TEST (test_bitvec_set_bits_from_array)
struct bitvec *v = bitvec_new(5);
struct UCBitVec *v = uc_bv_new(5);
char a[] = {1, 0,1 ,0, 1};
set_bits_from_array(v,a , 5);
fail_if(get_bit(v, 0) != 1 , "bit 0 is wrong");
fail_if(get_bit(v, 1) != 0 , "bit 1 is wrong");
fail_if(get_bit(v, 2) != 1 , "bit 2 is wrong");
fail_if(get_bit(v, 3) != 0 , "bit 3 is wrong");
fail_if(get_bit(v, 4) != 1 , "bit 4 is wrong");
uc_bv_set_bits_from_array(v,a , 5);
fail_if(uc_bv_get_bit(v, 0) != 1 , "bit 0 is wrong");
fail_if(uc_bv_get_bit(v, 1) != 0 , "bit 1 is wrong");
fail_if(uc_bv_get_bit(v, 2) != 1 , "bit 2 is wrong");
fail_if(uc_bv_get_bit(v, 3) != 0 , "bit 3 is wrong");
fail_if(uc_bv_get_bit(v, 4) != 1 , "bit 4 is wrong");
END_TEST
START_TEST (test_bitvec_setall_clearall)
struct bitvec *v = bitvec_new(511);
struct UCBitVec *v = uc_bv_new(511);
size_t i;
set_all(v);
uc_bv_set_all(v);
for (i = 0; i < 511; i++)
fail_if(get_bit(v, i) != 1 , "bit %zu is not 1", i);
fail_if(uc_bv_get_bit(v, i) != 1 , "bit %zu is not 1", i);
clear_all(v);
uc_bv_clr_all(v);
for (i = 0; i < sizeof(unsigned long) * 8; i++)
fail_if(get_bit(v, i) != 0 , "bit %zu is not 0", i);
fail_if(uc_bv_get_bit(v, i) != 0 , "bit %zu is not 0", i);
END_TEST