Skip to content
BitVecEndsWith

BitVecEndsWith

BitVecEndsWith

Description

Check if bitvector ends with the given bit pattern.

Parameters

Name Direction Description
bv in Bitvector to check
suffix in Pattern to match at the end

Usage example (from documentation)

  bool ends = BitVecEndsWith(&flags, &pattern);

Returns

true if bitvector ends with the pattern

Usage example (Cross-references)

Usage examples (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);
Last updated on