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);
    // 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
    // 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

BitVecContainsAt

BitVecContainsAt Description Check if bitvector contains the given pattern at a specific position.

Read More

BitVecStartsWith

BitVecStartsWith Description Check if bitvector starts with the given bit pattern.

Read More