BitVecEqualsRange

Table of Contents

BitVecEqualsRange

Description

Compare specific ranges of two bitvectors for equality.

Parameters

NameDirectionDescription
bv1inFirst bitvector
start1inStarting position in first bitvector
bv2inSecond bitvector
start2inStarting position in second bitvector
leninNumber of bits to compare

Usage example (from documentation)

  bool equal = BitVecEqualsRange(&bv1, 5, &bv2, 10, 8);

Usage example (Cross-references)

    }
    
    return BitVecEqualsRange(bv1, 0, bv2, 0, bv1->length);
    }
    }
    
    bool BitVecEqualsRange(BitVec *bv1, u64 start1, BitVec *bv2, u64 start2, u64 len) {
    ValidateBitVec(bv1);
    ValidateBitVec(bv2);
    // Test BitVecEqualsRange function
    bool test_bitvec_equals_range(void) {
    WriteFmt("Testing BitVecEqualsRange\n");
    
    BitVec bv1 = BitVecInit();
    // Test unequal ranges
    // bv1[3:5] = 000, bv2[1:3] = 010, should be false
    bool result = !BitVecEqualsRange(&bv1, 3, &bv2, 1, 3);
    
    // Test equal ranges that actually match
    
    // Test equal ranges that actually match
    result = result && BitVecEqualsRange(&bv1, 0, &bv1, 0, 8); // Self-equality
    
    // Test equal ranges with same pattern
    // Test equal ranges with same pattern
    // bv1[3:5] = 000, bv2[3:5] = 001, should be false
    result = result && !BitVecEqualsRange(&bv1, 3, &bv2, 3, 3);
    
    // Test actually equal ranges: bv1[3:4] = 00, bv2[0:1] = 00
    
    // Test actually equal ranges: bv1[3:4] = 00, bv2[0:1] = 00
    result = result && BitVecEqualsRange(&bv1, 3, &bv2, 0, 2);
    
    // Test boundary conditions
    
    // Test boundary conditions
    result = result && BitVecEqualsRange(&bv1, 0, &bv2, 0, 0); // Zero length (should be true)
    
    // Clean up
    
    // Test range operations on large vectors
    result = result && BitVecEqualsRange(&large1, 100, &large1, 100, 500); // Self-range equality
    
    // Test set operations on large vectors
    
    // Test NULL pointer in range operations - should abort
    BitVecEqualsRange(NULL, 0, &bv, 0, 1);
    
    BitVecDeinit(&bv);
    
    // Test out-of-bounds range - should abort
    BitVecEqualsRange(&bv1, 0, &bv2, 0, 5); // Range exceeds length
    
    BitVecDeinit(&bv1);

Share :

Related Posts

BitVecToBytes

BitVecToBytes Description Export bitvector to byte array. Copies the internal bit representation to the provided byte array.

Read More

BitVecBestAlignment

BitVecBestAlignment Description Find best overlapping alignment between two bitvectors. Returns the offset that gives the best alignment score.

Read More

BitVecRunLengths

BitVecRunLengths Description Analyze run lengths in a bitvector. A run is a sequence of consecutive identical bits. Results array must be pre-allocated with sufficient space.

Read More