BitVecGet
Description
Get the value of bit at given index in bitvector.
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in | Bitvector to get bit from. |
idx |
in | Index of bit to get (0-based), in [0, length). |
Usage example (from documentation)
bool flag = BitVecGet(&flags, 5);Success
Returns true when the bit is set, false when it is clear. The bitvector is not modified.
Failure
Function cannot fail. An out-of-range idx is a caller bug and aborts via LOG_FATAL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Foreach.h:32:
if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0) \
for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--) \
for (bool var = 0; idx < UNPL(pbv)->length && (var = BitVecGet(UNPL(pbv), idx), 1); idx++)
///
- In
Foreach.h:54:
for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;) \
for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0) \
for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(run_once); UNPL(run_once) = 0)
///
- In
Foreach.h:112:
UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e); \
++idx, UNPL(d) = 1) \
for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(d); UNPL(d) = 0)
- In
Int.c:249:
static bool int_is_odd(const Int *value) {
ValidateInt(value);
return BitVecLen(INT_BITS(value)) > 0 && BitVecGet(INT_BITS(value), 0);
}- In
Int.c:254:
static bool int_is_one(const Int *value) {
ValidateInt(value);
return IntBitLength(value) == 1 && BitVecGet(INT_BITS(value), 0);
}- In
Int.c:430:
for (u64 i = 0; i < BitVecLen(INT_BITS(value)); i++) {
if (BitVecGet(INT_BITS(value), i)) {
return i;
}- In
Int.c:580:
u64 bit_idx = i * 8 + bit;
if (bit_idx < BitVecLen(INT_BITS(value)) && BitVecGet(INT_BITS(value), bit_idx)) {
byte |= (u8)(1u << bit);
}- In
Int.c:634:
u64 bit_idx = i * 8 + bit;
if (bit_idx < BitVecLen(INT_BITS(value)) && BitVecGet(INT_BITS(value), bit_idx)) {
byte |= (u8)(1u << bit);
}- In
BitVec.c:284:
}
bool BitVecGet(const BitVec *bitvec, u64 idx) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:342:
LOG_FATAL("Cannot pop from empty bitvector");
}
bool value = BitVecGet(bitvec, bitvec->length - 1);
BitVecResize(bitvec, bitvec->length - 1);
return value;- In
BitVec.c:357:
for (u64 i = bitvec->length - 1; i > idx; i--) {
bool bit = BitVecGet(bitvec, i - 1);
BitVecSet(bitvec, i, bit);
}- In
BitVec.c:381:
for (u64 i = old_length; i > idx;) {
i--;
bool bit = BitVecGet(bv, i);
BitVecSet(bv, i + count, bit);
}- In
BitVec.c:409:
for (u64 i = old_length; i > idx;) {
i--;
bool bit = BitVecGet(bv, i);
BitVecSet(bv, i + other->length, bit);
}- In
BitVec.c:414:
for (u64 i = 0; i < other->length; i++) {
bool bit = BitVecGet(other, i);
BitVecSet(bv, idx + i, bit);
}- In
BitVec.c:437:
for (u64 i = old_length; i > idx;) {
i--;
bool bit = BitVecGet(bv, i);
BitVecSet(bv, i + pattern_bits, bit);
}- In
BitVec.c:457:
}
bool removed_bit = BitVecGet(bv, idx);
for (u64 i = idx; i < bv->length - 1; i++) {- In
BitVec.c:460:
for (u64 i = idx; i < bv->length - 1; i++) {
bool bit = BitVecGet(bv, i + 1);
BitVecSet(bv, i, bit);
}- In
BitVec.c:485:
for (u64 i = idx + count; i < bv->length; i++) {
bool bit = BitVecGet(bv, i);
BitVecSet(bv, i - count, bit);
}- In
BitVec.c:525:
// a survivor, so survivors slide leftward into the gaps left by matches.
for (u64 read_idx = 0; read_idx < bv->length; read_idx++) {
bool bit = BitVecGet(bv, read_idx);
if (bit != value) {
if (write_idx != read_idx) {- In
BitVec.c:674:
for (u64 i = 0; i < len; i++) {
if (BitVecGet(bv1, start1 + i) != BitVecGet(bv2, start2 + i)) {
return false;
}- In
BitVec.c:744:
for (u64 i = 0; i < len; i++) {
bool bit1 = BitVecGet(bv1, start1 + i);
bool bit2 = BitVecGet(bv2, start2 + i);- In
BitVec.c:745:
for (u64 i = 0; i < len; i++) {
bool bit1 = BitVecGet(bv1, start1 + i);
bool bit2 = BitVecGet(bv2, start2 + i);
// 1 sorts after 0; once a position differs the order is fixed
- In
BitVec.c:769:
for (u64 i = max_len; i > 0;) {
i--;
bool bit1 = i < bv1->length ? BitVecGet(bv1, i) : false;
bool bit2 = i < bv2->length ? BitVecGet(bv2, i) : false;- In
BitVec.c:770:
i--;
bool bit1 = i < bv1->length ? BitVecGet(bv1, i) : false;
bool bit2 = i < bv2->length ? BitVecGet(bv2, i) : false;
if (bit1 != bit2) {- In
BitVec.c:806:
// Two's-complement: the top bit is the sign, so a set MSB means
// negative and an unset one means non-negative.
bool sign1 = bv1->length > 0 ? BitVecGet(bv1, bv1->length - 1) : false;
bool sign2 = bv2->length > 0 ? BitVecGet(bv2, bv2->length - 1) : false;- In
BitVec.c:807:
// negative and an unset one means non-negative.
bool sign1 = bv1->length > 0 ? BitVecGet(bv1, bv1->length - 1) : false;
bool sign2 = bv2->length > 0 ? BitVecGet(bv2, bv2->length - 1) : false;
if (sign1 != sign2) {- In
BitVec.c:835:
for (u64 i = 0; i < max_len; i++) {
bool bit1 = i < bv1->length ? BitVecGet(bv1, i) : false;
bool bit2 = i < bv2->length ? BitVecGet(bv2, i) : false;- In
BitVec.c:836:
for (u64 i = 0; i < max_len; i++) {
bool bit1 = i < bv1->length ? BitVecGet(bv1, i) : false;
bool bit2 = i < bv2->length ? BitVecGet(bv2, i) : false;
if (bit1 && !bit2) {- In
BitVec.c:857:
for (u64 i = 0; i < min_len; i++) {
if (BitVecGet(bv1, i) && BitVecGet(bv2, i)) {
return false;
}- In
BitVec.c:875:
for (u64 i = 0; i < bv->length; i++) {
bool bit = BitVecGet(bv, i);
if (bit) {- In
BitVec.c:903:
for (u64 i = 0; i < bv->length; i++) {
char bit_char = BitVecGet(bv, i) ? '1' : '0';
if (!StrPushBackR(out, bit_char)) {
StrDeinit(out);- In
BitVec.c:1013:
for (u64 i = 0; i < bv->length && i / 8 < bytes_to_copy; i++) {
if (BitVecGet(bv, i)) {
u64 byte_idx = i / 8;
u64 bit_offset = i % 8;- In
BitVec.c:1073:
for (u64 i = 0; i < max_bits; i++) {
if (BitVecGet(bv, i)) {
result |= (1ULL << i);
}- In
BitVec.c:1133:
// by an earlier iteration writing into a higher index.
for (u64 i = bv->length - 1; i >= positions; i--) {
bool bit = BitVecGet(bv, i - positions);
BitVecSet(bv, i, bit);
}- In
BitVec.c:1154:
for (u64 i = 0; i < bv->length - positions; i++) {
bool bit = BitVecGet(bv, i + positions);
BitVecSet(bv, i, bit);
}- In
BitVec.c:1182:
for (u64 i = 0; i < bv->length; i++) {
u64 src_idx = (i + positions) % bv->length;
bool bit = BitVecGet(&temp, src_idx);
BitVecSet(bv, i, bit);
}- In
BitVec.c:1208:
for (u64 i = 0; i < bv->length; i++) {
u64 src_idx = (i + bv->length - positions) % bv->length;
bool bit = BitVecGet(&temp, src_idx);
BitVecSet(bv, i, bit);
}- In
BitVec.c:1223:
for (u64 i = 0; i < bv->length / 2; i++) {
u64 j = bv->length - 1 - i;
bool bit_i = BitVecGet(bv, i);
bool bit_j = BitVecGet(bv, j);
BitVecSet(bv, i, bit_j);- In
BitVec.c:1224:
u64 j = bv->length - 1 - i;
bool bit_i = BitVecGet(bv, i);
bool bit_j = BitVecGet(bv, j);
BitVecSet(bv, i, bit_j);
BitVecSet(bv, j, bit_i);- In
BitVec.c:1234:
for (u64 i = 0; i < bv->length; i++) {
if (BitVecGet(bv, i) == value) {
return i;
}- In
BitVec.c:1251:
// wraps to SIZE_MAX, which fails the loop condition.
for (u64 i = bv->length - 1; i < bv->length; i--) {
if (BitVecGet(bv, i) == value) {
return i;
}- In
BitVec.c:1264:
for (u64 i = 0; i < bv->length; i++) {
if (BitVecGet(bv, i) != value) {
return false;
}- In
BitVec.c:1291:
for (u64 i = 0; i < bv->length; i++) {
if (BitVecGet(bv, i) == value) {
current_run++;
if (current_run > max_run) {- In
BitVec.c:1396:
u64 run_count = 0;
u64 current_run_length = 1;
bool current_value = BitVecGet(bv, 0);
for (u64 i = 1; i < bv->length; i++) {- In
BitVec.c:1399:
for (u64 i = 1; i < bv->length; i++) {
bool bit = BitVecGet(bv, i);
if (bit == current_value) {
current_run_length++;- In
BitVec.c:1437:
u64 current_run_length = 1;
bool current_value = BitVecGet(bv, 0);
for (u64 i = 1; i < bv->length; i++) {- In
BitVec.c:1440:
for (u64 i = 1; i < bv->length; i++) {
bool bit = BitVecGet(bv, i);
if (bit == current_value) {
current_run_length++;- In
BitVec.c:1466:
for (u64 i = 0; i < min_length; i++) {
if (BitVecGet(bv1, i) != BitVecGet(bv2, i)) {
distance++;
}- In
BitVec.c:1494:
for (u64 i = 0; i < max_length; i++) {
bool bit1 = (i < bv1->length) ? BitVecGet(bv1, i) : false;
bool bit2 = (i < bv2->length) ? BitVecGet(bv2, i) : false;- In
BitVec.c:1495:
for (u64 i = 0; i < max_length; i++) {
bool bit1 = (i < bv1->length) ? BitVecGet(bv1, i) : false;
bool bit2 = (i < bv2->length) ? BitVecGet(bv2, i) : false;
if (bit1 || bit2) {- In
BitVec.c:1531:
for (u64 i = 0; i < min_length; i++) {
if (BitVecGet(bv1, i) && BitVecGet(bv2, i)) {
product++;
}- In
BitVec.c:1583:
for (u64 j = 1; j <= len2; j++) {
u64 cost = BitVecGet(bv1, i - 1) == BitVecGet(bv2, j - 1) ? 0 : 1;
u64 deletion = prev_row[j] + 1;- In
BitVec.c:1629:
for (u64 i = 0; i < max_length; i++) {
double val1 = (i < bv1->length && BitVecGet(bv1, i)) ? 1.0 : 0.0;
double val2 = (i < bv2->length && BitVecGet(bv2, i)) ? 1.0 : 0.0;- In
BitVec.c:1630:
for (u64 i = 0; i < max_length; i++) {
double val1 = (i < bv1->length && BitVecGet(bv1, i)) ? 1.0 : 0.0;
double val2 = (i < bv2->length && BitVecGet(bv2, i)) ? 1.0 : 0.0;
sum1 += val1;- In
BitVec.c:1672:
for (u64 i = 0; i < min_length; i++) {
if (BitVecGet(bv1, i) == BitVecGet(bv2, i)) {
score += match;
} else {- In
BitVec.c:1698:
for (u64 i = 0; i < bv2->length && (offset + i) < bv1->length; i++) {
if (BitVecGet(bv1, offset + i) == BitVecGet(bv2, i)) {
score++;
} else {- In
BitVec.c:1750:
for (u64 i = 0; i < pattern->length; i++) {
if (BitVecGet(bv, idx + i) != BitVecGet(pattern, i)) {
return false;
}- In
BitVec.c:1809:
for (u64 i = 0; i < new_pattern->length; i++) {
if (!BitVecInsert(bv, pos + i, BitVecGet(new_pattern, i))) {
return false;
}- In
BitVec.c:1845:
for (u64 i = 0; i < new_pattern->length; i++) {
if (!BitVecInsert(bv, match_pos + i, BitVecGet(new_pattern, i))) {
return replacements;
}- In
BitVec.c:1868:
for (u64 i = 0; i < bv->length; i++) {
// wildcard bit clear = position is fixed; the pattern must match.
if (!BitVecGet(wildcard, i)) {
if (BitVecGet(bv, i) != BitVecGet(pattern, i)) {
return false;- In
BitVec.c:1869:
// wildcard bit clear = position is fixed; the pattern must match.
if (!BitVecGet(wildcard, i)) {
if (BitVecGet(bv, i) != BitVecGet(pattern, i)) {
return false;
}- In
BitVec.c:1889:
u64 errors = 0;
for (u64 j = 0; j < pattern->length; j++) {
if (BitVecGet(bv, i + j) != BitVecGet(pattern, j)) {
errors++;
if (errors > max_errors) {- In
Memory.c:64:
// Check that data is still intact
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Memory.c:65:
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Memory.c:66:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
// Clean up
- In
Memory.c:94:
// Check that data is still intact
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);- In
Memory.c:95:
// Check that data is still intact
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
// Try to set capacity smaller than current length (should not shrink below length)
- In
Memory.c:105:
// Data should still be intact
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);- In
Memory.c:106:
// Data should still be intact
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
// Clean up
- In
Memory.c:176:
// Check bv1 (should now have bv2's original content)
result = result && (BitVecLen(&bv1) == 2);
result = result && (BitVecGet(&bv1, 0) == false);
result = result && (BitVecGet(&bv1, 1) == false);- In
Memory.c:177:
result = result && (BitVecLen(&bv1) == 2);
result = result && (BitVecGet(&bv1, 0) == false);
result = result && (BitVecGet(&bv1, 1) == false);
// Check bv2 (should now have bv1's original content)
- In
Memory.c:181:
// Check bv2 (should now have bv1's original content)
result = result && (BitVecLen(&bv2) == 3);
result = result && (BitVecGet(&bv2, 0) == true);
result = result && (BitVecGet(&bv2, 1) == false);
result = result && (BitVecGet(&bv2, 2) == true);- In
Memory.c:182:
result = result && (BitVecLen(&bv2) == 3);
result = result && (BitVecGet(&bv2, 0) == true);
result = result && (BitVecGet(&bv2, 1) == false);
result = result && (BitVecGet(&bv2, 2) == true);- In
Memory.c:183:
result = result && (BitVecGet(&bv2, 0) == true);
result = result && (BitVecGet(&bv2, 1) == false);
result = result && (BitVecGet(&bv2, 2) == true);
// Clean up
- In
Memory.c:215:
for (u64 i = 0; i < BitVecLen(&original); i++) {
result = result && (BitVecGet(&clone, i) == BitVecGet(&original, i));
}- In
Memory.c:223:
// Clone should remain unchanged
result = result && (BitVecLen(&clone) == 4) && (BitVecLen(&original) == 5);
result = result && (BitVecGet(&clone, 0) == true);
result = result && (BitVecGet(&clone, 1) == false);
result = result && (BitVecGet(&clone, 2) == true);- In
Memory.c:224:
result = result && (BitVecLen(&clone) == 4) && (BitVecLen(&original) == 5);
result = result && (BitVecGet(&clone, 0) == true);
result = result && (BitVecGet(&clone, 1) == false);
result = result && (BitVecGet(&clone, 2) == true);
result = result && (BitVecGet(&clone, 3) == false);- In
Memory.c:225:
result = result && (BitVecGet(&clone, 0) == true);
result = result && (BitVecGet(&clone, 1) == false);
result = result && (BitVecGet(&clone, 2) == true);
result = result && (BitVecGet(&clone, 3) == false);- In
Memory.c:226:
result = result && (BitVecGet(&clone, 1) == false);
result = result && (BitVecGet(&clone, 2) == true);
result = result && (BitVecGet(&clone, 3) == false);
// Modify clone to verify independence
- In
Memory.c:232:
// Original should remain unchanged at index 0
result = result && (BitVecGet(&original, 0) == true);
result = result && (BitVecGet(&clone, 0) == false);- In
Memory.c:233:
// Original should remain unchanged at index 0
result = result && (BitVecGet(&original, 0) == true);
result = result && (BitVecGet(&clone, 0) == false);
// Clean up
- In
Memory.c:271:
BitVecAllocator(&clone)->effort == BitVecAllocator(&original)->effort &&
BitVecAllocator(&clone)->retry_limit == BitVecAllocator(&original)->retry_limit &&
BitVecGet(&clone, 0) == true && BitVecGet(&clone, 1) == false && BitVecGet(&clone, 2) == true;
BitVecDeinit(&original);- In
Memory.c:296:
BitVecShrinkToFit(&bv);
result = result && (BitVecLen(&bv) == 1) && (BitVecCapacity(&bv) >= 1);
result = result && (BitVecGet(&bv, 0) == true);
// Test multiple shrinks (should be safe)
- In
Memory.c:337:
result = result && (BitVecLen(&bv) == original_length);
for (u64 i = 0; i < BitVecLen(&bv); i++) {
result = result && (BitVecGet(&bv, i) == (i % 2 == 0));
}- In
Memory.c:369:
result = result && (BitVecLen(&bv1) == 0);
result = result && (BitVecLen(&bv2) == 2);
result = result && (BitVecGet(&bv2, 0) == true);
result = result && (BitVecGet(&bv2, 1) == false);- In
Memory.c:370:
result = result && (BitVecLen(&bv2) == 2);
result = result && (BitVecGet(&bv2, 0) == true);
result = result && (BitVecGet(&bv2, 1) == false);
// Test swap with large data
- In
Memory.c:380:
BitVecSwap(&bv1, &bv2);
result = result && (BitVecLen(&bv1) == 2) && (BitVecLen(&bv2) == 1000);
result = result && (BitVecGet(&bv2, 0) == true); // 0 % 3 == 0
result = result && (BitVecGet(&bv2, 999) == (999 % 3 == 0));- In
Memory.c:381:
result = result && (BitVecLen(&bv1) == 2) && (BitVecLen(&bv2) == 1000);
result = result && (BitVecGet(&bv2, 0) == true); // 0 % 3 == 0
result = result && (BitVecGet(&bv2, 999) == (999 % 3 == 0));
// Test swapping with itself (should be safe)
- In
Memory.c:410:
BitVec clone2 = BitVecClone(&bv);
result = result && (BitVecLen(&clone2) == 1);
result = result && (BitVecGet(&clone2, 0) == true);
BitVecDeinit(&clone2);- In
Memory.c:424:
// Verify all bits match
for (u64 i = 0; i < 1000; i++) {
result = result && (BitVecGet(&clone3, i) == BitVecGet(&bv, i));
}- In
Memory.c:428:
// Test independence - modify original
BitVecSet(&bv, 0, !BitVecGet(&bv, 0));
result = result && (BitVecGet(&clone3, 0) != BitVecGet(&bv, 0));- In
Memory.c:429:
// Test independence - modify original
BitVecSet(&bv, 0, !BitVecGet(&bv, 0));
result = result && (BitVecGet(&clone3, 0) != BitVecGet(&bv, 0));
BitVecDeinit(&clone3);- In
Memory.c:464:
result = result && (BitVecLen(&clone) == cycle * 10);
if (cycle > 0) {
result = result && (BitVecGet(&clone, 0) == true); // 0 % 2 == 0
}- In
Memory.c:540:
bool result = (BitVecLen(&bv) == 8);
result = result && (BitVecGet(&bv, 5) == false);
result = result && (BitVecGet(&bv, 6) == false);
result = result && (BitVecGet(&bv, 7) == false);- In
Memory.c:541:
bool result = (BitVecLen(&bv) == 8);
result = result && (BitVecGet(&bv, 5) == false);
result = result && (BitVecGet(&bv, 6) == false);
result = result && (BitVecGet(&bv, 7) == false);- In
Memory.c:542:
result = result && (BitVecGet(&bv, 5) == false);
result = result && (BitVecGet(&bv, 6) == false);
result = result && (BitVecGet(&bv, 7) == false);
BitVecDeinit(&bv);- In
Memory.c:618:
// Every bit, including the high bits in the last byte, must survive.
for (int i = 0; i < 400 && result; i++) {
result = result && (BitVecGet(&bv, (u64)i) == (i % 2 == 0));
}- In
Memory.c:646:
// structural validator. On real code this returns the bit; under the
// mutant it aborts.
bool result = (BitVecGet(&bv, 399) == (399 % 3 == 0));
result = result && (BitVecCountOnes(&bv) == BitVecCountOnes(&bv));- In
Memory.c:680:
// structural validator. Real code passes; the mutant aborts.
bool result = (BitVecLen(&small) == 400);
result = result && (BitVecGet(&small, 399) == (399 % 2 == 0));
result = result && (BitVecGet(&small, 0) == true);- In
Memory.c:681:
bool result = (BitVecLen(&small) == 400);
result = result && (BitVecGet(&small, 399) == (399 % 2 == 0));
result = result && (BitVecGet(&small, 0) == true);
BitVecDeinit(&small);- In
Init.c:143:
BitVecPush(&bv, true);
result = result && (BitVecLen(&bv) == 1);
result = result && (BitVecGet(&bv, 0) == true);
// Clean up
- In
Init.c:171:
// Check that length was increased and new bits have the default value
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == true); // Original data
result = result && (BitVecGet(&bv, 1) == false); // Original data
result = result && (BitVecGet(&bv, 2) == true); // Original data
- In
Init.c:172:
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == true); // Original data
result = result && (BitVecGet(&bv, 1) == false); // Original data
result = result && (BitVecGet(&bv, 2) == true); // Original data
result = result && (BitVecGet(&bv, 3) == false); // New data (likely default to false)
- In
Init.c:173:
result = result && (BitVecGet(&bv, 0) == true); // Original data
result = result && (BitVecGet(&bv, 1) == false); // Original data
result = result && (BitVecGet(&bv, 2) == true); // Original data
result = result && (BitVecGet(&bv, 3) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 4) == false); // New data (likely default to false)
- In
Init.c:174:
result = result && (BitVecGet(&bv, 1) == false); // Original data
result = result && (BitVecGet(&bv, 2) == true); // Original data
result = result && (BitVecGet(&bv, 3) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 4) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 5) == false); // New data (likely default to false)
- In
Init.c:175:
result = result && (BitVecGet(&bv, 2) == true); // Original data
result = result && (BitVecGet(&bv, 3) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 4) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 5) == false); // New data (likely default to false)
- In
Init.c:176:
result = result && (BitVecGet(&bv, 3) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 4) == false); // New data (likely default to false)
result = result && (BitVecGet(&bv, 5) == false); // New data (likely default to false)
// Test resizing to smaller size
- In
Init.c:183:
// Check that length was decreased and data was truncated
result = result && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true); // Original data preserved
result = result && (BitVecGet(&bv, 1) == false); // Original data preserved
- In
Init.c:184:
result = result && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true); // Original data preserved
result = result && (BitVecGet(&bv, 1) == false); // Original data preserved
// Test resizing to same size (should be no-op)
- In
Init.c:272:
// New bits should be false
for (u64 i = 0; i < 5; i++) {
result = result && (BitVecGet(&bv, i) == false);
}
// Test NULL bitvec pointer - should abort
BitVecGet(NULL, 0);
return false;
// Test get from empty bitvec - should abort
BitVecGet(&bv, 0);
BitVecDeinit(&bv);
// Test with index way beyond length (3) - should abort
BitVecGet(&bv, 1000);
BitVecDeinit(&bv);
// Test with maximum possible index value - should abort
BitVecGet(&bv, SIZE_MAX);
BitVecDeinit(&bv);- In
Insert.c:46:
// Check each bit
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Insert.c:47:
// Check each bit
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Insert.c:48:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:49:
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:50:
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);
// Clean up
- In
Insert.c:72:
// Check first bit
bool result = (BitVecLen(&bv) == 1 && BitVecGet(&bv, 0) == true);
// Insert at the end
- In
Insert.c:79:
// Check bits
result = result && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);- In
Insert.c:80:
result = result && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
// Insert in the middle
- In
Insert.c:87:
// Check all bits
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);- In
Insert.c:88:
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);- In
Insert.c:89:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
// Clean up
- In
Insert.c:116:
// Check result: false, true, true, true, false
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);- In
Insert.c:117:
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Insert.c:118:
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:119:
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:120:
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);
// Clean up
- In
Insert.c:153:
// Check result: true, true, true, true, false
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);- In
Insert.c:154:
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Insert.c:155:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:156:
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);- In
Insert.c:157:
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);
// Clean up
- In
Insert.c:187:
// Pattern 1011 gets inserted as individual bits
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == false); // original
result = result && (BitVecGet(&bv, 1) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv, 2) == true); // bit 1 of pattern
- In
Insert.c:188:
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == false); // original
result = result && (BitVecGet(&bv, 1) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv, 2) == true); // bit 1 of pattern
result = result && (BitVecGet(&bv, 3) == false); // bit 2 of pattern
- In
Insert.c:189:
result = result && (BitVecGet(&bv, 0) == false); // original
result = result && (BitVecGet(&bv, 1) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv, 2) == true); // bit 1 of pattern
result = result && (BitVecGet(&bv, 3) == false); // bit 2 of pattern
result = result && (BitVecGet(&bv, 4) == true); // bit 3 of pattern (MSB)
- In
Insert.c:190:
result = result && (BitVecGet(&bv, 1) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv, 2) == true); // bit 1 of pattern
result = result && (BitVecGet(&bv, 3) == false); // bit 2 of pattern
result = result && (BitVecGet(&bv, 4) == true); // bit 3 of pattern (MSB)
result = result && (BitVecGet(&bv, 5) == false); // original
- In
Insert.c:191:
result = result && (BitVecGet(&bv, 2) == true); // bit 1 of pattern
result = result && (BitVecGet(&bv, 3) == false); // bit 2 of pattern
result = result && (BitVecGet(&bv, 4) == true); // bit 3 of pattern (MSB)
result = result && (BitVecGet(&bv, 5) == false); // original
- In
Insert.c:192:
result = result && (BitVecGet(&bv, 3) == false); // bit 2 of pattern
result = result && (BitVecGet(&bv, 4) == true); // bit 3 of pattern (MSB)
result = result && (BitVecGet(&bv, 5) == false); // original
// Test with different pattern - 0x05 (0101 in binary) using only 3 bits
- In
Insert.c:203:
// Check result: true, false, true, true (3 bits: 101)
result = result && (BitVecLen(&bv2) == 4);
result = result && (BitVecGet(&bv2, 0) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv2, 1) == false); // bit 1 of pattern
result = result && (BitVecGet(&bv2, 2) == true); // bit 2 of pattern
- In
Insert.c:204:
result = result && (BitVecLen(&bv2) == 4);
result = result && (BitVecGet(&bv2, 0) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv2, 1) == false); // bit 1 of pattern
result = result && (BitVecGet(&bv2, 2) == true); // bit 2 of pattern
result = result && (BitVecGet(&bv2, 3) == true); // original
- In
Insert.c:205:
result = result && (BitVecGet(&bv2, 0) == true); // bit 0 of pattern (LSB)
result = result && (BitVecGet(&bv2, 1) == false); // bit 1 of pattern
result = result && (BitVecGet(&bv2, 2) == true); // bit 2 of pattern
result = result && (BitVecGet(&bv2, 3) == true); // original
- In
Insert.c:206:
result = result && (BitVecGet(&bv2, 1) == false); // bit 1 of pattern
result = result && (BitVecGet(&bv2, 2) == true); // bit 2 of pattern
result = result && (BitVecGet(&bv2, 3) == true); // original
// Clean up
- In
Insert.c:234:
BitVecInsertRange(&bv, 1, 2, false);
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);- In
Insert.c:235:
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);
// Test large range insertion
- In
Insert.c:241:
BitVecInsertRange(&bv, 0, 1000, true);
result = result && (BitVecLen(&bv) == 1000);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 999) == true);- In
Insert.c:242:
result = result && (BitVecLen(&bv) == 1000);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 999) == true);
BitVecDeinit(&bv);- In
Insert.c:266:
BitVecPush(&source, true);
BitVecInsertMultiple(&bv, 0, &source);
result = result && (BitVecLen(&bv) == 1) && (BitVecGet(&bv, 0) == true);
// Test inserting large bitvec
- In
Insert.c:275:
BitVecInsertMultiple(&bv, 1, &source);
result = result && (BitVecLen(&bv) == 501);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 500) == false);- In
Insert.c:276:
result = result && (BitVecLen(&bv) == 501);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 500) == false);
BitVecDeinit(&bv);- In
Insert.c:305:
BitVecInsertPattern(&bv, 0, 0xAA, 8); // 10101010 pattern
result = result && (BitVecLen(&bv) == 8);
result = result && (BitVecGet(&bv, 0) == false); // First bit of 0xAA
result = result && (BitVecGet(&bv, 1) == true); // Second bit
- In
Insert.c:306:
result = result && (BitVecLen(&bv) == 8);
result = result && (BitVecGet(&bv, 0) == false); // First bit of 0xAA
result = result && (BitVecGet(&bv, 1) == true); // Second bit
BitVecDeinit(&bv);- In
Insert.c:367:
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false); // inserted
result = result && (BitVecGet(&bv, 2) == false); // inserted
- In
Insert.c:368:
bool result = (BitVecLen(&bv) == 6);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false); // inserted
result = result && (BitVecGet(&bv, 2) == false); // inserted
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
- In
Insert.c:369:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false); // inserted
result = result && (BitVecGet(&bv, 2) == false); // inserted
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
- In
Insert.c:370:
result = result && (BitVecGet(&bv, 1) == false); // inserted
result = result && (BitVecGet(&bv, 2) == false); // inserted
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
result = result && (BitVecGet(&bv, 5) == true); // shifted orig[3]
- In
Insert.c:371:
result = result && (BitVecGet(&bv, 2) == false); // inserted
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
result = result && (BitVecGet(&bv, 5) == true); // shifted orig[3]
- In
Insert.c:372:
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
result = result && (BitVecGet(&bv, 5) == true); // shifted orig[3]
BitVecDeinit(&bv);- In
Insert.c:402:
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == true); // other[0]
result = result && (BitVecGet(&bv, 2) == true); // other[1]
- In
Insert.c:403:
bool result = (BitVecLen(&bv) == 5);
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == true); // other[0]
result = result && (BitVecGet(&bv, 2) == true); // other[1]
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
- In
Insert.c:404:
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == true); // other[0]
result = result && (BitVecGet(&bv, 2) == true); // other[1]
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
- In
Insert.c:405:
result = result && (BitVecGet(&bv, 1) == true); // other[0]
result = result && (BitVecGet(&bv, 2) == true); // other[1]
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
- In
Insert.c:406:
result = result && (BitVecGet(&bv, 2) == true); // other[1]
result = result && (BitVecGet(&bv, 3) == false); // shifted orig[1]
result = result && (BitVecGet(&bv, 4) == true); // shifted orig[2]
BitVecDeinit(&bv); // Expected result: 1000 (1101 AND 1010)
bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == false);
test_result = test_result && (BitVecGet(&result, 2) == false); bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == false);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == false);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 1) == false);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == false);
// Clean up
// Expected result: 1110 (1100 OR 1010)
bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true); bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 0) == true);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false);
// Clean up
// Expected result: 0110 (1100 XOR 1010)
bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true); bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false); test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == true);
test_result = test_result && (BitVecGet(&result, 3) == false);
// Clean up
// Expected result: 0101 (NOT 1010)
bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == false); bool test_result = (BitVecLen(&result) == 4);
test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == true); test_result = test_result && (BitVecGet(&result, 0) == false);
test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == true); test_result = test_result && (BitVecGet(&result, 1) == true);
test_result = test_result && (BitVecGet(&result, 2) == false);
test_result = test_result && (BitVecGet(&result, 3) == true);
// Clean up
// New bit[1] = 0 (filled)
// Expected result: 0010
test_result = test_result && (BitVecGet(&bv, 0) == false);
test_result = test_result && (BitVecGet(&bv, 1) == false);
test_result = test_result && (BitVecGet(&bv, 2) == true); // Expected result: 0010
test_result = test_result && (BitVecGet(&bv, 0) == false);
test_result = test_result && (BitVecGet(&bv, 1) == false);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 0) == false);
test_result = test_result && (BitVecGet(&bv, 1) == false);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 1) == false);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false);
// Clean up
bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false); bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == false);
// Clean up
// Expected result: 1110 (1011 rotated left by 2)
bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == true); bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false); test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == true);
test_result = test_result && (BitVecGet(&bv, 3) == false);
// Clean up
// Expected result: 1101 (1011 rotated right by 1)
bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false); bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true); test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true); test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true);
// Clean up
// Expected result: 1101 (1011 reversed)
bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false); bool test_result = (BitVecLen(&bv) == 4);
test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true); test_result = test_result && (BitVecGet(&bv, 0) == true);
test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true); test_result = test_result && (BitVecGet(&bv, 1) == true);
test_result = test_result && (BitVecGet(&bv, 2) == false);
test_result = test_result && (BitVecGet(&bv, 3) == true);
// Clean up
BitVecShiftLeft(&bv, 0);
result = result && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
// Test shift larger than length (should clear all bits)
BitVecPush(&bv, true);
BitVecRotateRight(&bv, 0);
result = result && (BitVecGet(&bv, 0) == true);
// Test rotate by length (should be no-op)
BitVecPush(&bv1, true);
BitVecNot(&result_bv, &bv1);
result = result && (BitVecGet(&result_bv, 0) == false);
BitVecDeinit(&result_bv); BitVecReverse(&bv);
result = result && (BitVecLen(&bv) == 1);
result = result && (BitVecGet(&bv, 0) == true);
// Test reverse even length
BitVecPush(&bv, false);
BitVecReverse(&bv);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true); BitVecReverse(&bv);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
// Test double reverse (should restore original)
// Test double reverse (should restore original)
BitVecReverse(&bv);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false); BitVecReverse(&bv);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
BitVecDeinit(&bv); BitVecAnd(&result, &bv1, &bv2);
test_result = test_result && (BitVecLen(&result) == 1);
test_result = test_result && (BitVecGet(&result, 0) == false);
BitVecOr(&result, &bv1, &bv2);
BitVecOr(&result, &bv1, &bv2);
test_result = test_result && (BitVecGet(&result, 0) == true);
// Test NOT on large bitvector
// Verify NOT correctness
for (int i = 0; i < 100; i++) {
bool original = BitVecGet(&bv1, i);
bool inverted = BitVecGet(&result, i);
test_result = test_result && (original != inverted); for (int i = 0; i < 100; i++) {
bool original = BitVecGet(&bv1, i);
bool inverted = BitVecGet(&result, i);
test_result = test_result && (original != inverted);
} bool changed = false;
for (int i = 0; i < (int)BitVecLen(&original); i++) {
if (BitVecGet(&bv, i) != BitVecGet(&original, i)) {
changed = true;
break; BitVecShiftLeft(&bv, 2);
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == false); // filled with 0
result = result && (BitVecGet(&bv, 1) == false); // filled with 0
result = result && (BitVecGet(&bv, 2) == true); // original bit 0
result = result && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == false); // filled with 0
result = result && (BitVecGet(&bv, 1) == false); // filled with 0
result = result && (BitVecGet(&bv, 2) == true); // original bit 0
result = result && (BitVecGet(&bv, 0) == false); // filled with 0
result = result && (BitVecGet(&bv, 1) == false); // filled with 0
result = result && (BitVecGet(&bv, 2) == true); // original bit 0
BitVecDeinit(&bv); bool restored = true;
for (int i = 0; i < 8; i++) {
if (BitVecGet(&bv, i) != BitVecGet(&original, i)) {
restored = false;
break; bool unchanged = true;
for (int i = 0; i < 8; i++) {
if (BitVecGet(&bv, i) != BitVecGet(&original, i)) {
unchanged = false;
break; BitVecRotateLeft(&bv, 2);
// 10101 -> 10110 (rotated left by 2)
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true); // 10101 -> 10110 (rotated left by 2)
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true); result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false); result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false); result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
result = result && (BitVecGet(&bv, 4) == false);
BitVecDeinit(&bv); bool and_identity = true;
for (int i = 0; i < 16; i++) {
if (BitVecGet(&result, i) != BitVecGet(&bv1, i)) {
and_identity = false;
break; bool or_identity = true;
for (int i = 0; i < 16; i++) {
if (BitVecGet(&result, i) != BitVecGet(&bv1, i)) {
or_identity = false;
break; test_result = test_result && (BitVecLen(&result) == 16);
for (int i = 0; i < 16; i++) {
test_result = test_result && (BitVecGet(&result, i) == false);
} bool double_not = true;
for (int i = 0; i < 16; i++) {
if (BitVecGet(&result, i) != BitVecGet(&bv1, i)) {
double_not = false;
break; bool and_zero = true;
for (int i = 0; i < 16; i++) {
if (BitVecGet(&result, i) != false) {
and_zero = false;
break; bool or_ones = true;
for (int i = 0; i < 16; i++) {
if (BitVecGet(&result, i) != true) {
or_ones = false;
break; bool and_commutative = true;
for (int i = 0; i < 12; i++) {
if (BitVecGet(&result1, i) != BitVecGet(&result2, i)) {
and_commutative = false;
break; bool or_commutative = true;
for (int i = 0; i < 12; i++) {
if (BitVecGet(&result1, i) != BitVecGet(&result2, i)) {
or_commutative = false;
break; bool xor_commutative = true;
for (int i = 0; i < 12; i++) {
if (BitVecGet(&result1, i) != BitVecGet(&result2, i)) {
xor_commutative = false;
break; for (int i = 0; i < 1000; i += 77) { // Check every 77th bit
bool expected = (i % 7 == 0) && (i % 11 == 0);
bool actual = BitVecGet(&result, i);
test_result = test_result && (expected == actual);
} // Verify NOT correctness on sample
for (int i = 0; i < 1000; i += 123) {
bool original = BitVecGet(&bv1, i);
bool inverted = BitVecGet(&result, i);
test_result = test_result && (original != inverted); for (int i = 0; i < 1000; i += 123) {
bool original = BitVecGet(&bv1, i);
bool inverted = BitVecGet(&result, i);
test_result = test_result && (original != inverted);
} // First 100 bits should be 0
for (int i = 0; i < 100; i++) {
test_result = test_result && (BitVecGet(&result, i) == false);
} // Expected OR (a padded with zeros): 1110
bool ok = (BitVecLen(&result) == 4);
ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true); bool ok = (BitVecLen(&result) == 4);
ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false); ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false); ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false);
BitVecDeinit(&a); // Expected XOR (a padded with zeros): 1110
bool ok = (BitVecLen(&result) == 4);
ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true); bool ok = (BitVecLen(&result) == 4);
ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false); ok = ok && (BitVecGet(&result, 0) == true);
ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false); ok = ok && (BitVecGet(&result, 1) == true);
ok = ok && (BitVecGet(&result, 2) == true);
ok = ok && (BitVecGet(&result, 3) == false);
BitVecDeinit(&a);
bool result = (BitVecCountOnes(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false); bool result = (BitVecCountOnes(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 7) == false); result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 7) == false); result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 7) == false);
BitVecDeinit(&bv); bool result = true;
for (int i = 0; i < 5; i++) {
result = result && (BitVecGet(&bv, i) == pat[(i + 5 - 2) % 5]);
} // Correctness sanity: 1011 rotated right by 1 -> 1101.
bool ok = (BitVecLen(&bv) == 4);
ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == false); bool ok = (BitVecLen(&bv) == 4);
ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == false);
ok = ok && (BitVecGet(&bv, 3) == true); ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == false);
ok = ok && (BitVecGet(&bv, 3) == true); ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == false);
ok = ok && (BitVecGet(&bv, 3) == true);
BitVecDeinit(&bv); // Correctness sanity: 1011 rotated left by 2 -> 1110.
bool ok = (BitVecLen(&bv) == 4);
ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == true); bool ok = (BitVecLen(&bv) == 4);
ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == true);
ok = ok && (BitVecGet(&bv, 3) == false); ok = ok && (BitVecGet(&bv, 0) == true);
ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == true);
ok = ok && (BitVecGet(&bv, 3) == false); ok = ok && (BitVecGet(&bv, 1) == true);
ok = ok && (BitVecGet(&bv, 2) == true);
ok = ok && (BitVecGet(&bv, 3) == false);
BitVecDeinit(&bv); // Check result should be: 101110
result = result && (BitVecLen(&source) == 6);
result = result && (BitVecGet(&source, 0) == true);
result = result && (BitVecGet(&source, 1) == false);
result = result && (BitVecGet(&source, 2) == true); result = result && (BitVecLen(&source) == 6);
result = result && (BitVecGet(&source, 0) == true);
result = result && (BitVecGet(&source, 1) == false);
result = result && (BitVecGet(&source, 2) == true); result = result && (BitVecGet(&source, 0) == true);
result = result && (BitVecGet(&source, 1) == false);
result = result && (BitVecGet(&source, 2) == true);
BitVecDeinit(&source); result = result && (replacements == 0);
result = result && (BitVecLen(&source) == 4);
result = result && (BitVecGet(&source, 0) == false);
result = result && (BitVecGet(&source, 3) == false); result = result && (BitVecLen(&source) == 4);
result = result && (BitVecGet(&source, 0) == false);
result = result && (BitVecGet(&source, 3) == false);
BitVecDeinit(&source); result = result && (BitVecLen(&source) == 4);
for (u64 i = 0; i < 4; i++)
result = result && (BitVecGet(&source, i) == false);
BitVecDeinit(&source); result = result && (BitVecLen(&source) == 6);
// result 010101: position 0 must be 0 (false), position 1 must be 1.
result = result && (BitVecGet(&source, 0) == false);
result = result && (BitVecGet(&source, 1) == true); // result 010101: position 0 must be 0 (false), position 1 must be 1.
result = result && (BitVecGet(&source, 0) == false);
result = result && (BitVecGet(&source, 1) == true);
BitVecDeinit(&source);- In
Remove.c:51:
// Check result
bool result = (popped == true) && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);- In
Remove.c:52:
bool result = (popped == true) && (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
// Pop another bit
- In
Remove.c:57:
popped = BitVecPop(&bv);
result = result && (popped == false) && (BitVecLen(&bv) == 1);
result = result && (BitVecGet(&bv, 0) == true);
// Pop the last bit
- In
Remove.c:91:
// Check result: true, false, false, true
bool result = (removed == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);- In
Remove.c:92:
bool result = (removed == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:93:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:94:
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);
// Remove bit at index 0 (first bit)
- In
Remove.c:99:
removed = BitVecRemove(&bv, 0);
result = result && (removed == true) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:100:
result = result && (removed == true) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:101:
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
// Clean up
- In
Remove.c:132:
// Check result: true, false, true (removed false, true, true)
bool result = (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:133:
bool result = (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:134:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
// Clean up
- In
Remove.c:164:
// Check result: true, true, false, true (removed first false at index 1)
bool result = (found == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);- In
Remove.c:165:
bool result = (found == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:166:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:167:
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == false);
result = result && (BitVecGet(&bv, 3) == true);
// Try to remove first occurrence of a value that doesn't exist (after removal)
- In
Remove.c:205:
// Check result: true, false, true, true (removed last false at index 3)
bool result = (found == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:206:
bool result = (found == true) && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:207:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Remove.c:208:
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
// Remove last occurrence of true
- In
Remove.c:215:
// Check result: true, false, true (removed last true at index 3)
result = result && (found == true) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:216:
result = result && (found == true) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:217:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
// Clean up
- In
Remove.c:248:
// Check result: true, true, true (all false bits removed)
bool result = (removed_count == 3) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:249:
bool result = (removed_count == 3) && (BitVecLen(&bv) == 3);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);- In
Remove.c:250:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 2) == true);
// Try to remove all false bits again (should return 0)
- In
Remove.c:534:
bool result = (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);- In
Remove.c:535:
bool result = (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
BitVecDeinit(&bv);- In
Remove.c:565:
bool result = (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);- In
Remove.c:566:
bool result = (BitVecLen(&bv) == 2);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == true);
BitVecDeinit(&bv);- In
Remove.c:594:
bool result = (BitVecLen(&bv) == 7);
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == false); // orig[1]
result = result && (BitVecGet(&bv, 2) == true); // orig[5]
- In
Remove.c:595:
bool result = (BitVecLen(&bv) == 7);
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == false); // orig[1]
result = result && (BitVecGet(&bv, 2) == true); // orig[5]
result = result && (BitVecGet(&bv, 3) == false); // orig[6]
- In
Remove.c:596:
result = result && (BitVecGet(&bv, 0) == true); // orig[0]
result = result && (BitVecGet(&bv, 1) == false); // orig[1]
result = result && (BitVecGet(&bv, 2) == true); // orig[5]
result = result && (BitVecGet(&bv, 3) == false); // orig[6]
result = result && (BitVecGet(&bv, 4) == true); // orig[7]
- In
Remove.c:597:
result = result && (BitVecGet(&bv, 1) == false); // orig[1]
result = result && (BitVecGet(&bv, 2) == true); // orig[5]
result = result && (BitVecGet(&bv, 3) == false); // orig[6]
result = result && (BitVecGet(&bv, 4) == true); // orig[7]
result = result && (BitVecGet(&bv, 5) == true); // orig[8]
- In
Remove.c:598:
result = result && (BitVecGet(&bv, 2) == true); // orig[5]
result = result && (BitVecGet(&bv, 3) == false); // orig[6]
result = result && (BitVecGet(&bv, 4) == true); // orig[7]
result = result && (BitVecGet(&bv, 5) == true); // orig[8]
result = result && (BitVecGet(&bv, 6) == false); // orig[9]
- In
Remove.c:599:
result = result && (BitVecGet(&bv, 3) == false); // orig[6]
result = result && (BitVecGet(&bv, 4) == true); // orig[7]
result = result && (BitVecGet(&bv, 5) == true); // orig[8]
result = result && (BitVecGet(&bv, 6) == false); // orig[9]
- In
Remove.c:600:
result = result && (BitVecGet(&bv, 4) == true); // orig[7]
result = result && (BitVecGet(&bv, 5) == true); // orig[8]
result = result && (BitVecGet(&bv, 6) == false); // orig[9]
BitVecDeinit(&bv);- In
Convert.c:84:
// Check result
bool result = ok && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);- In
Convert.c:85:
bool result = ok && (BitVecLen(&bv) == 4);
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Convert.c:86:
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);- In
Convert.c:87:
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == true);
// Test with empty string
- In
Convert.c:158:
for (u64 i = 0; i < BitVecLen(&bv); i++) {
if (BitVecGet(&bv, i)) {
true_count++;
} else {- In
Convert.c:234:
for (u64 i = 0; i < BitVecLen(&bv); i++) {
if (BitVecGet(&bv, i)) {
true_count++;
} else {- In
Convert.c:252:
bool all_false = true;
for (u64 i = 0; i < BitVecLen(&zero_bv); i++) {
if (BitVecGet(&zero_bv, i)) {
all_false = false;
break;- In
Convert.c:362:
BitVec bv2 = BitVecFromStr("1", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv2) == 1);
result = result && (BitVecGet(&bv2, 0) == true);
BitVecDeinit(&bv2);- In
Convert.c:374:
BitVec bv3 = BitVecFromStr(long_str, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv3) == 1000);
result = result && (BitVecGet(&bv3, 0) == true);
result = result && (BitVecGet(&bv3, 1) == false);
BitVecDeinit(&bv3);- In
Convert.c:375:
result = result && (BitVecLen(&bv3) == 1000);
result = result && (BitVecGet(&bv3, 0) == true);
result = result && (BitVecGet(&bv3, 1) == false);
BitVecDeinit(&bv3);- In
Convert.c:681:
for (u64 i = 0; i < BitVecLen(&recovered_bv); i++) {
bool expected = (i % 3) == 0;
bool actual = BitVecGet(&recovered_bv, i);
if (expected != actual) {
recovered_pattern_correct = false;- In
Convert.c:706:
for (u64 i = 0; i < BitVecLen(&large_from_str); i++) {
bool expected = (i % 7) == 0;
bool actual = BitVecGet(&large_from_str, i);
if (expected != actual) {
large_pattern_correct = false;- In
Convert.c:903:
bool result = (BitVecLen(&bv) == 9) && (BitVecCountOnes(&bv) == 6);
for (int i = 0; i < 9; i++) {
result = result && (BitVecGet(&bv, i) == ((i / 3) % 2 == 0));
} DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecGet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test getting bits
bool result = (BitVecGet(&bv, 0) == true) && (BitVecGet(&bv, 1) == false) && (BitVecGet(&bv, 2) == true) &&
(BitVecGet(&bv, 3) == false); // Test getting bits
bool result = (BitVecGet(&bv, 0) == true) && (BitVecGet(&bv, 1) == false) && (BitVecGet(&bv, 2) == true) &&
(BitVecGet(&bv, 3) == false);
BitVecDeinit(&bv);
// Test getting the set bits
bool result = (BitVecGet(&bv, 0) == true) && (BitVecGet(&bv, 1) == false) && (BitVecGet(&bv, 2) == true) &&
(BitVecGet(&bv, 3) == false); // Test getting the set bits
bool result = (BitVecGet(&bv, 0) == true) && (BitVecGet(&bv, 1) == false) && (BitVecGet(&bv, 2) == true) &&
(BitVecGet(&bv, 3) == false);
BitVecDeinit(&bv);
// Test the flipped bits
bool result = (BitVecGet(&bv, 0) == false) && // was true, now false
(BitVecGet(&bv, 1) == true) && // was false, now true
(BitVecGet(&bv, 2) == true) && // unchanged
// Test the flipped bits
bool result = (BitVecGet(&bv, 0) == false) && // was true, now false
(BitVecGet(&bv, 1) == true) && // was false, now true
(BitVecGet(&bv, 2) == true) && // unchanged
(BitVecGet(&bv, 3) == false); // unchanged
bool result = (BitVecGet(&bv, 0) == false) && // was true, now false
(BitVecGet(&bv, 1) == true) && // was false, now true
(BitVecGet(&bv, 2) == true) && // unchanged
(BitVecGet(&bv, 3) == false); // unchanged
(BitVecGet(&bv, 1) == true) && // was false, now true
(BitVecGet(&bv, 2) == true) && // unchanged
(BitVecGet(&bv, 3) == false); // unchanged
BitVecDeinit(&bv); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecGet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); // Test with single bit
BitVecPush(&bv, true);
result = result && (BitVecGet(&bv, 0) == true);
// Test with larger index
}
result = result && (BitVecGet(&bv, 63) == false); // 63 % 2 == 1, so i%2==0 is false for i=63
BitVecDeinit(&bv); BitVecResize(&bv, 1);
BitVecSet(&bv, 0, true);
bool result = (BitVecGet(&bv, 0) == true);
// Set same bit to false
// Set same bit to false
BitVecSet(&bv, 0, false);
result = result && (BitVecGet(&bv, 0) == false);
BitVecDeinit(&bv); BitVecPush(&bv, false);
BitVecFlip(&bv, 0);
bool result = (BitVecGet(&bv, 0) == true);
// Flip it again
// Flip it again
BitVecFlip(&bv, 0);
result = result && (BitVecGet(&bv, 0) == false);
BitVecDeinit(&bv);
// Verify pattern: T F T F T
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true); // Verify pattern: T F T F T
result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == false); result = result && (BitVecGet(&bv, 0) == true);
result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == false);
result = result && (BitVecGet(&bv, 4) == true); result = result && (BitVecGet(&bv, 1) == false);
result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == false);
result = result && (BitVecGet(&bv, 4) == true); result = result && (BitVecGet(&bv, 2) == true);
result = result && (BitVecGet(&bv, 3) == false);
result = result && (BitVecGet(&bv, 4) == true);
// Count and verify
// Verify some positions
result = result && (BitVecGet(&bv, 0) == true); // 0 % 2 == 0
result = result && (BitVecGet(&bv, 1) == false); // 1 % 2 != 0
result = result && (BitVecGet(&bv, 500) == true); // 500 % 2 == 0
// Verify some positions
result = result && (BitVecGet(&bv, 0) == true); // 0 % 2 == 0
result = result && (BitVecGet(&bv, 1) == false); // 1 % 2 != 0
result = result && (BitVecGet(&bv, 500) == true); // 500 % 2 == 0
result = result && (BitVecGet(&bv, 999) == false); // 999 % 2 != 0
result = result && (BitVecGet(&bv, 0) == true); // 0 % 2 == 0
result = result && (BitVecGet(&bv, 1) == false); // 1 % 2 != 0
result = result && (BitVecGet(&bv, 500) == true); // 500 % 2 == 0
result = result && (BitVecGet(&bv, 999) == false); // 999 % 2 != 0
result = result && (BitVecGet(&bv, 1) == false); // 1 % 2 != 0
result = result && (BitVecGet(&bv, 500) == true); // 500 % 2 == 0
result = result && (BitVecGet(&bv, 999) == false); // 999 % 2 != 0
// Verify counts
BitVecSet(&bv, 1, true);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
result = result && (BitVecGet(&bv, 0) == false);
result = result && (BitVecGet(&bv, 1) == true);
// Test count operations
// Verify pattern
for (int i = 0; i < size && result; i++) {
result = result && (BitVecGet(&bv, i) == (i % 3 == 0));
} expected = !expected; // Flipped
}
result = result && (BitVecGet(&bv, i) == expected);
} for (int i = 0; i < 100 && result; i++) {
bool expected = (i * 17 + 3) % 7 < 3;
result = result && (BitVecGet(&bv, i) == expected);
}- In
Type.c:96:
IntAllocator(&clone)->effort == IntAllocator(&original)->effort &&
IntAllocator(&clone)->retry_limit == IntAllocator(&original)->retry_limit &&
BitVecGet(&clone.bits, 0) == true && BitVecGet(&clone.bits, 1) == false && BitVecGet(&clone.bits, 2) == true;
IntDeinit(&original);
Last updated on