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);Success
true if bitvectors are equal
Failure
false when lengths differ or any bit position differs.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:651:
}
bool BitVecEquals(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
Compare.c:52:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecEquals\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:59:
// Test equal empty bitvectors
bool result = BitVecEquals(&bv1, &bv2);
// Add same pattern to both
- In
Compare.c:71:
// Should be equal
result = result && BitVecEquals(&bv1, &bv2);
// Add different pattern to third
- In
Compare.c:79:
// Should not be equal
result = result && !BitVecEquals(&bv1, &bv3);
// Test different lengths
- In
Compare.c:83:
// Test different lengths
BitVecPush(&bv3, true);
result = result && !BitVecEquals(&bv1, &bv3);
// Clean up
- In
Compare.c:687:
// Test compare empty bitvecs
result = result && BitVecEquals(&bv1, &bv2);
result = result && (BitVecCompare(&bv1, &bv2) == 0);- In
Compare.c:692:
// Test compare empty vs non-empty
BitVecPush(&bv1, true);
result = result && !BitVecEquals(&bv1, &bv2);
result = result && (BitVecCompare(&bv1, &bv2) != 0);- In
Compare.c:703:
BitVecPush(&bv2, bit);
}
result = result && BitVecEquals(&bv1, &bv2);
// Test subset operations on empty sets
- In
Compare.c:847:
// Test large-scale comparison performance and correctness
result = result && (BitVecEquals(&large1, &large1)); // Self-equality
result = result && !BitVecEquals(&large1, &large2); // Different patterns
- In
Compare.c:848:
// 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
- In
Compare.c:901:
// Test NULL pointer - should abort
BitVecEquals(NULL, &bv);
BitVecDeinit(&bv);- In
Compare.c:1118:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecEquals rejects bad second operand\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:1125:
BitVecPush(&bv1, true);
BitVecEquals(&bv1, &bad);
BitVecDeinit(&bv1);
Last updated on