BitVecStartsWith
- Function
- August 22, 2025
Table of Contents
BitVecStartsWith
BitVecStartsWith
Description
Check if bitvector starts with the given bit pattern.
Parameters
Name | Direction | Description |
---|---|---|
bv | in | Bitvector to check |
prefix | in | Pattern to match at the beginning |
Usage example (from documentation)
bool starts = BitVecStartsWith(&flags, &pattern);
Usage example (Cross-references)
- In
BitVec.c:1399
:
// Missing Pattern functions implementation
bool BitVecStartsWith(BitVec *bv, BitVec *prefix) {
ValidateBitVec(bv);
ValidateBitVec(prefix);
- In
BitVec.c:1617
:
VecForeachPtrIdx(patterns, pattern, i, {
if (BitVecStartsWith(bv, pattern)) {
return i;
}
bool test_bitvec_starts_with_null_source(void) {
printf("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) {
printf("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) {
printf("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) {
printf("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);
// BitVecStartsWith tests
bool test_bitvec_starts_with_basic(void) {
printf("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) {
printf("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) {
printf("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) {
printf("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;