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);Returns
true if bitvector starts with the pattern
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1397:
// Missing Pattern functions implementation
bool BitVecStartsWith(BitVec *bv, BitVec *prefix) {
ValidateBitVec(bv);
ValidateBitVec(prefix);- In
BitVec.c:1615:
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);
Last updated on