BitVecFindLastPattern

Table of Contents

BitVecFindLastPattern

Description

Find last occurrence of a bit pattern in the bitvector.

Parameters

NameDirectionDescription
bvinBitvector to search in
patterninPattern to search for

Usage example (from documentation)

  u64 index = BitVecFindLastPattern(&flags, &pattern);

Usage example (Cross-references)

    }
    
    u64 BitVecFindLastPattern(BitVec *bv, BitVec *pattern) {
    ValidateBitVec(bv);
    ValidateBitVec(pattern);
    // Test BitVecFindLastPattern function
    bool test_bitvec_find_last_pattern(void) {
    WriteFmt("Testing BitVecFindLastPattern function\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, false);
    
    u64 index = BitVecFindLastPattern(&source, &pattern);
    result    = result && (index == 6); // Last occurrence of "10" should be at index 6
    BitVecPush(&pattern, true);
    
    index  = BitVecFindLastPattern(&source, &pattern);
    result = result && (index == 2); // Only occurrence at index 2
    // Deadend test 3: BitVecFindLastPattern with NULL source
    bool test_bitvec_find_last_pattern_null_source(void) {
    WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
    
    BitVec pattern = BitVecInit();
    BitVecPush(&pattern, true);
    
    BitVecFindLastPattern(NULL, &pattern); // Should cause LOG_FATAL
    
    BitVecDeinit(&pattern);
    // Deadend test 4: BitVecFindLastPattern with NULL pattern
    bool test_bitvec_find_last_pattern_null_pattern(void) {
    WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&source, false);
    
    BitVecFindLastPattern(&source, NULL); // Should cause LOG_FATAL
    
    BitVecDeinit(&source);
    // Deadend test 3: BitVecFindLastPattern with NULL source
    bool test_bitvec_find_last_pattern_null_source(void) {
    WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
    
    BitVec pattern = BitVecInit();
    BitVecPush(&pattern, true);
    
    BitVecFindLastPattern(NULL, &pattern); // Should cause LOG_FATAL
    
    BitVecDeinit(&pattern);
    // Deadend test 4: BitVecFindLastPattern with NULL pattern
    bool test_bitvec_find_last_pattern_null_pattern(void) {
    WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&source, false);
    
    BitVecFindLastPattern(&source, NULL); // Should cause LOG_FATAL
    
    BitVecDeinit(&source);
    // Test BitVecFindLastPattern function
    bool test_bitvec_find_last_pattern(void) {
    WriteFmt("Testing BitVecFindLastPattern function\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, false);
    
    u64 index = BitVecFindLastPattern(&source, &pattern);
    result    = result && (index == 6); // Last occurrence of "10" should be at index 6
    BitVecPush(&pattern, true);
    
    index  = BitVecFindLastPattern(&source, &pattern);
    result = result && (index == 2); // Only occurrence at index 2

Share :

Related Posts

BitVecFindPattern

BitVecFindPattern Description Find first occurrence of a bit pattern in the bitvector.

Read More

BitVecToInteger

BitVecToInteger Description Convert bitvector to integer (up to 64 bits). Treats the bitvector as an unsigned integer with LSB first.

Read More

BitVecFindLast

BitVecFindLast Description Find index of last occurrence of a specific bit value.

Read More