BitVecEquals
- Function
- August 22, 2025
Table of Contents
BitVecEquals
BitVecEquals
Description
Test equality between two bitvectors. Two bitvectors are equal if they have the same length and all bits match.
Parameters
Name | Direction | Description |
---|---|---|
bv1 | in | First bitvector |
bv2 | in | Second bitvector |
Usage example (from documentation)
bool equal = BitVecEquals(&flags1, &flags2);
Usage example (Cross-references)
- In
BitVec.c:512
:
// Comparison functions
bool BitVecEquals(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);
// Test BitVecEquals function
bool test_bitvec_equals(void) {
printf("Testing BitVecEquals\n");
BitVec bv1 = BitVecInit();
// Test equal empty bitvectors
bool result = BitVecEquals(&bv1, &bv2);
// Add same pattern to both
// Should be equal
result = result && BitVecEquals(&bv1, &bv2);
// Add different pattern to third
// Should not be equal
result = result && !BitVecEquals(&bv1, &bv3);
// Test different lengths
// Test different lengths
BitVecPush(&bv3, true);
result = result && !BitVecEquals(&bv1, &bv3);
// Clean up
// Test compare empty bitvecs
result = result && BitVecEquals(&bv1, &bv2);
result = result && (BitVecCompare(&bv1, &bv2) == 0);
// Test compare empty vs non-empty
BitVecPush(&bv1, true);
result = result && !BitVecEquals(&bv1, &bv2);
result = result && (BitVecCompare(&bv1, &bv2) != 0);
BitVecPush(&bv2, bit);
}
result = result && BitVecEquals(&bv1, &bv2);
// Test subset operations on empty sets
// Test large-scale comparison performance and correctness
result = result && (BitVecEquals(&large1, &large1)); // Self-equality
result = result && !BitVecEquals(&large1, &large2); // Different patterns
// Test large-scale comparison performance and correctness
result = result && (BitVecEquals(&large1, &large1)); // Self-equality
result = result && !BitVecEquals(&large1, &large2); // Different patterns
// Test range operations on large vectors
// Test NULL pointer - should abort
BitVecEquals(NULL, &bv);
BitVecDeinit(&bv);