BitVecFindLastPattern
BitVecFindLastPattern
Description
Find last occurrence of a bit pattern in the bitvector.
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in | Bitvector to search in |
pattern |
in | Pattern to search for |
Usage example (from documentation)
u64 index = BitVecFindLastPattern(&flags, &pattern);Returns
Index of last occurrence, or SIZE_MAX if not found
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1070:
}
u64 BitVecFindLastPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern); // Deadend test 3: BitVecFindLastPattern with NULL source
bool test_bitvec_find_last_pattern_null_source(void) {
WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(); BitVecPush(&pattern, true);
BitVecFindLastPattern(NULL, &pattern); // Should cause LOG_FATAL
BitVecDeinit(&pattern); // Deadend test 4: BitVecFindLastPattern with NULL pattern
bool test_bitvec_find_last_pattern_null_pattern(void) {
WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(); BitVecPush(&source, false);
BitVecFindLastPattern(&source, NULL); // Should cause LOG_FATAL
BitVecDeinit(&source); // Test BitVecFindLastPattern function
bool test_bitvec_find_last_pattern(void) {
WriteFmt("Testing BitVecFindLastPattern function\n");
BitVec source = BitVecInit(); BitVecPush(&pattern, false);
u64 index = BitVecFindLastPattern(&source, &pattern);
result = result && (index == 6); // Last occurrence of "10" should be at index 6
BitVecPush(&pattern, true);
index = BitVecFindLastPattern(&source, &pattern);
result = result && (index == 2); // Only occurrence at index 2
// Deadend test 3: BitVecFindLastPattern with NULL source
bool test_bitvec_find_last_pattern_null_source(void) {
WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(); BitVecPush(&pattern, true);
BitVecFindLastPattern(NULL, &pattern); // Should cause LOG_FATAL
BitVecDeinit(&pattern); // Deadend test 4: BitVecFindLastPattern with NULL pattern
bool test_bitvec_find_last_pattern_null_pattern(void) {
WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(); BitVecPush(&source, false);
BitVecFindLastPattern(&source, NULL); // Should cause LOG_FATAL
BitVecDeinit(&source); // Test BitVecFindLastPattern function
bool test_bitvec_find_last_pattern(void) {
WriteFmt("Testing BitVecFindLastPattern function\n");
BitVec source = BitVecInit(); BitVecPush(&pattern, false);
u64 index = BitVecFindLastPattern(&source, &pattern);
result = result && (index == 6); // Last occurrence of "10" should be at index 6
BitVecPush(&pattern, true);
index = BitVecFindLastPattern(&source, &pattern);
result = result && (index == 2); // Only occurrence at index 2
Last updated on