BitVecMatches

Table of Contents

BitVecMatches

Description

Match bitvector against pattern with wildcards. Wildcards allow flexible pattern matching where some positions can be “any bit”.

Parameters

NameDirectionDescription
bvinBitvector to match against
patterninPattern bitvector to match
wildcardinWildcard bitvector (1 = wildcard position, 0 = exact match required)

Usage example (from documentation)

  bool matches = BitVecMatches(&data, &pattern, &wildcard);

Usage example (Cross-references)

    }
    
    bool BitVecMatches(BitVec *bv, BitVec *pattern, BitVec *wildcard) {
    ValidateBitVec(bv);
    ValidateBitVec(pattern);
    // BitVecMatches tests
    bool test_bitvec_matches_basic(void) {
    WriteFmt("Testing BitVecMatches basic functionality\n");
    
    BitVec source   = BitVecInit();
    BitVecPush(&wildcard, false);
    
    result = result && BitVecMatches(&source, &pattern, &wildcard);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_matches_null_source(void) {
    WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
    BitVec pattern  = BitVecInit();
    BitVec wildcard = BitVecInit();
    BitVecPush(&pattern, true);
    BitVecPush(&wildcard, false);
    BitVecMatches(NULL, &pattern, &wildcard);
    BitVecDeinit(&pattern);
    BitVecDeinit(&wildcard);
    
    bool test_bitvec_matches_null_source(void) {
    WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
    BitVec pattern  = BitVecInit();
    BitVec wildcard = BitVecInit();
    BitVecPush(&pattern, true);
    BitVecPush(&wildcard, false);
    BitVecMatches(NULL, &pattern, &wildcard);
    BitVecDeinit(&pattern);
    BitVecDeinit(&wildcard);
    // BitVecMatches tests
    bool test_bitvec_matches_basic(void) {
    WriteFmt("Testing BitVecMatches basic functionality\n");
    
    BitVec source   = BitVecInit();
    BitVecPush(&wildcard, false);
    
    result = result && BitVecMatches(&source, &pattern, &wildcard);
    
    BitVecDeinit(&source);

Share :

Related Posts

BitVecStartsWith

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

Read More

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