BitVecStartsWith

Table of Contents

BitVecStartsWith

Description

Check if bitvector starts with the given bit pattern.

Parameters

NameDirectionDescription
bvinBitvector to check
prefixinPattern to match at the beginning

Usage example (from documentation)

  bool starts = BitVecStartsWith(&flags, &pattern);

Usage example (Cross-references)

    // Missing Pattern functions implementation
    
    bool BitVecStartsWith(BitVec *bv, BitVec *prefix) {
    ValidateBitVec(bv);
    ValidateBitVec(prefix);
    
    VecForeachPtrIdx(patterns, pattern, i) {
    if (BitVecStartsWith(bv, pattern)) {
    return i;
    }
    
    bool test_bitvec_starts_with_null_source(void) {
    WriteFmt("Testing BitVecStartsWith(NULL, prefix) - should fatal\n");
    BitVec prefix = BitVecInit();
    BitVecPush(&prefix, true);
    BitVec prefix = BitVecInit();
    BitVecPush(&prefix, true);
    BitVecStartsWith(NULL, &prefix);
    BitVecDeinit(&prefix);
    return true;
    
    bool test_bitvec_starts_with_null_prefix(void) {
    WriteFmt("Testing BitVecStartsWith(source, NULL) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecStartsWith(&source, NULL);
    BitVecDeinit(&source);
    return true;
    // BitVecStartsWith tests
    bool test_bitvec_starts_with_basic(void) {
    WriteFmt("Testing BitVecStartsWith basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&prefix, false);
    
    result = result && BitVecStartsWith(&source, &prefix);
    
    // Test non-matching prefix: 101
    BitVecPush(&prefix, true);
    
    result = result && !BitVecStartsWith(&source, &prefix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_starts_with_edge_cases(void) {
    WriteFmt("Testing BitVecStartsWith edge cases\n");
    
    BitVec source = BitVecInit();
    // Test empty prefix (should always match)
    BitVecPush(&source, true);
    result = result && BitVecStartsWith(&source, &prefix);
    
    // Test prefix longer than source
    BitVecPush(&prefix, true);
    BitVecPush(&prefix, false);
    result = result && !BitVecStartsWith(&source, &prefix);
    
    // Test equal length
    BitVecPush(&prefix, true);
    BitVecPush(&prefix, false);
    result = result && BitVecStartsWith(&source, &prefix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_starts_with_null_source(void) {
    WriteFmt("Testing BitVecStartsWith(NULL, prefix) - should fatal\n");
    BitVec prefix = BitVecInit();
    BitVecPush(&prefix, true);
    BitVec prefix = BitVecInit();
    BitVecPush(&prefix, true);
    BitVecStartsWith(NULL, &prefix);
    BitVecDeinit(&prefix);
    return true;
    
    bool test_bitvec_starts_with_null_prefix(void) {
    WriteFmt("Testing BitVecStartsWith(source, NULL) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecStartsWith(&source, NULL);
    BitVecDeinit(&source);
    return true;
    // BitVecStartsWith tests
    bool test_bitvec_starts_with_basic(void) {
    WriteFmt("Testing BitVecStartsWith basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&prefix, false);
    
    result = result && BitVecStartsWith(&source, &prefix);
    
    // Test non-matching prefix: 101
    BitVecPush(&prefix, true);
    
    result = result && !BitVecStartsWith(&source, &prefix);
    
    BitVecDeinit(&source);
    
    bool test_bitvec_starts_with_edge_cases(void) {
    WriteFmt("Testing BitVecStartsWith edge cases\n");
    
    BitVec source = BitVecInit();
    // Test empty prefix (should always match)
    BitVecPush(&source, true);
    result = result && BitVecStartsWith(&source, &prefix);
    
    // Test prefix longer than source
    BitVecPush(&prefix, true);
    BitVecPush(&prefix, false);
    result = result && !BitVecStartsWith(&source, &prefix);
    
    // Test equal length
    BitVecPush(&prefix, true);
    BitVecPush(&prefix, false);
    result = result && BitVecStartsWith(&source, &prefix);
    
    BitVecDeinit(&source);

Share :

Related Posts

BitVecRemoveFirst

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

Read More

BitVecResize

BitVecResize Description Reu64 bitvector to hold exactly n bits. May grow or shrink the bitvector.

Read More

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