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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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) {
    WriteFmt("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);

Share :

Related Posts

BitVecRemoveLast

BitVecRemoveLast Description Remove the last occurrence of a specific bit value. Returns true if a bit was found and removed, false otherwise.

Read More

BitVecReserve

BitVecReserve Description Reserve space for at least n bits in bitvector. Does not change the length, only ensures capacity.

Read More

BitVecDeinit

BitVecDeinit Description Deinitialize bitvector and free all allocated memory. After calling this, the bitvector should not be used unless re-initialized.

Read More