BitVecEndsWith

Table of Contents

BitVecEndsWith

Description

Check if bitvector ends with the given bit pattern.

Parameters

NameDirectionDescription
bvinBitvector to check
suffixinPattern to match at the end

Usage example (from documentation)

  bool ends = BitVecEndsWith(&flags, &pattern);

Usage example (Cross-references)

    }
    
    bool BitVecEndsWith(BitVec *bv, BitVec *suffix) {
    ValidateBitVec(bv);
    ValidateBitVec(suffix);
    
    VecForeachPtrIdx(patterns, pattern, i, {
    if (BitVecEndsWith(bv, pattern)) {
    return i;
    }
    
    bool test_bitvec_ends_with_null_source(void) {
    printf("Testing BitVecEndsWith(NULL, suffix) - should fatal\n");
    BitVec suffix = BitVecInit();
    BitVecPush(&suffix, true);
    BitVec suffix = BitVecInit();
    BitVecPush(&suffix, true);
    BitVecEndsWith(NULL, &suffix);
    BitVecDeinit(&suffix);
    return true;
    
    bool test_bitvec_ends_with_null_suffix(void) {
    printf("Testing BitVecEndsWith(source, NULL) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecEndsWith(&source, NULL);
    BitVecDeinit(&source);
    return true;
    // BitVecEndsWith tests
    bool test_bitvec_ends_with_basic(void) {
    printf("Testing BitVecEndsWith basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&suffix, true);
    
    result = result && BitVecEndsWith(&source, &suffix);
    
    // Test non-matching suffix: 110
    BitVecPush(&suffix, false);
    
    result = result && !BitVecEndsWith(&source, &suffix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_ends_with_edge_cases(void) {
    printf("Testing BitVecEndsWith edge cases\n");
    
    BitVec source = BitVecInit();
    // Test empty suffix (should always match)
    BitVecPush(&source, true);
    result = result && BitVecEndsWith(&source, &suffix);
    
    // Test suffix longer than source
    BitVecPush(&suffix, true);
    BitVecPush(&suffix, false);
    result = result && !BitVecEndsWith(&source, &suffix);
    
    BitVecDeinit(&source);
    // BitVecEndsWith tests
    bool test_bitvec_ends_with_basic(void) {
    printf("Testing BitVecEndsWith basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&suffix, true);
    
    result = result && BitVecEndsWith(&source, &suffix);
    
    // Test non-matching suffix: 110
    BitVecPush(&suffix, false);
    
    result = result && !BitVecEndsWith(&source, &suffix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_ends_with_edge_cases(void) {
    printf("Testing BitVecEndsWith edge cases\n");
    
    BitVec source = BitVecInit();
    // Test empty suffix (should always match)
    BitVecPush(&source, true);
    result = result && BitVecEndsWith(&source, &suffix);
    
    // Test suffix longer than source
    BitVecPush(&suffix, true);
    BitVecPush(&suffix, false);
    result = result && !BitVecEndsWith(&source, &suffix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_ends_with_null_source(void) {
    printf("Testing BitVecEndsWith(NULL, suffix) - should fatal\n");
    BitVec suffix = BitVecInit();
    BitVecPush(&suffix, true);
    BitVec suffix = BitVecInit();
    BitVecPush(&suffix, true);
    BitVecEndsWith(NULL, &suffix);
    BitVecDeinit(&suffix);
    return true;
    
    bool test_bitvec_ends_with_null_suffix(void) {
    printf("Testing BitVecEndsWith(source, NULL) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecEndsWith(&source, NULL);
    BitVecDeinit(&source);
    return true;

Share :

Related Posts

BitVecToBytes

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

Read More

BitVecFromBytes

BitVecFromBytes Description Create bitvector from byte array. Reads the specified number of bits from the byte array.

Read More

BitVecIsSorted

BitVecIsSorted Description Check if bits in bitvector are in sorted order. Useful for certain algorithms and data structures.

Read More