BitVec
Description
Bit vector definition. This is a specialized container for efficiently storing boolean values as bits.
Each bit represents a boolean value, with 8 bits packed into each byte. This provides significant memory savings over storing booleans as separate bytes.
Fields
| Name | Description |
|---|---|
length |
Number of bits currently in bitvector (always <= capacity) |
capacity |
Max number of bits this bitvector can hold before doing a resize |
data |
Bit data stored as bytes. Don’t access directly. Use BitVecGet/Set |
byte_size |
Size of data array in bytes |
Usage example (from documentation)
BitVec flags; // Bit vector for boolean flags
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:24:
#if FEATURE_BITVEC
# include <Misra/Std/Container/BitVec.h>
#endif
#if FEATURE_INT- In
Io.c:2904:
#if FEATURE_BITVEC
bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
if (!o || !fmt_info || !bv) {
LOG_FATAL("Invalid arguments");- In
Io.c:3042:
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv) {
(void)fmt_info; // Unused parameter
if (!i || !bv) {- In
BitVec.c:7:
/// Bit vector implementation - efficient storage for boolean values
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>- In
BitVec.c:48:
static double log2_f64(double x) {
if (x <= 0.0) {
return 0.0; // BitVec entropy: never called on non-positives in practice
}
union {- In
BitVec.c:73:
#define BYTES_FOR_BITS(bits) (((bits) + BITS_PER_BYTE - 1) / BITS_PER_BYTE)
BitVec bitvec_init_with_capacity(u64 cap, Allocator *alloc) {
BitVec result = BitVecInit(alloc);- In
BitVec.c:74:
BitVec bitvec_init_with_capacity(u64 cap, Allocator *alloc) {
BitVec result = BitVecInit(alloc);
if (cap == 0) {- In
BitVec.c:90:
}
void BitVecDeinit(BitVec *bitvec) {
ValidateBitVec(bitvec);
if (bitvec->data) {- In
BitVec.c:98:
}
void BitVecClear(BitVec *bitvec) {
ValidateBitVec(bitvec);
bitvec->length = 0;- In
BitVec.c:106:
}
bool BitVecResize(BitVec *bitvec, u64 new_size) {
ValidateBitVec(bitvec);
if (new_size > bitvec->capacity) {- In
BitVec.c:138:
}
bool BitVecReserve(BitVec *bitvec, u64 n) {
ValidateBitVec(bitvec);
if (n <= bitvec->capacity)- In
BitVec.c:161:
}
void BitVecShrinkToFit(BitVec *bv) {
ValidateBitVec(bv);
if (bv->length == 0) {- In
BitVec.c:199:
}
void BitVecSwap(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:222:
}
bool BitVecTryClone(BitVec *out, BitVec *bv) {
ValidateBitVec(bv);
if (!out) {- In
BitVec.c:247:
}
BitVec BitVecClone(BitVec *bv) {
BitVec clone;- In
BitVec.c:248:
BitVec BitVecClone(BitVec *bv) {
BitVec clone;
ValidateBitVec(bv);- In
BitVec.c:256:
}
bool BitVecGet(const BitVec *bitvec, u64 idx) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:267:
}
void BitVecSet(BitVec *bitvec, u64 idx, bool value) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:282:
}
void BitVecFlip(BitVec *bitvec, u64 idx) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:293:
}
bool BitVecPush(BitVec *bitvec, bool value) {
ValidateBitVec(bitvec);
if (bitvec->length >= bitvec->capacity) {- In
BitVec.c:309:
}
bool BitVecPop(BitVec *bitvec) {
ValidateBitVec(bitvec);
if (bitvec->length == 0) {- In
BitVec.c:319:
}
bool BitVecInsert(BitVec *bitvec, u64 idx, bool value) {
ValidateBitVec(bitvec);
if (idx > bitvec->length) {- In
BitVec.c:337:
}
bool BitVecInsertRange(BitVec *bv, u64 idx, u64 count, bool value) {
ValidateBitVec(bv);
if (idx > bv->length) {- In
BitVec.c:364:
}
bool BitVecInsertMultiple(BitVec *bv, u64 idx, BitVec *other) {
ValidateBitVec(bv);
ValidateBitVec(other);- In
BitVec.c:393:
}
bool BitVecInsertPattern(BitVec *bv, u64 idx, u8 pattern, u64 pattern_bits) {
ValidateBitVec(bv);
if (idx > bv->length) {- In
BitVec.c:423:
}
bool BitVecRemove(BitVec *bv, u64 idx) {
ValidateBitVec(bv);
if (idx >= bv->length) {- In
BitVec.c:440:
}
void BitVecRemoveRange(BitVec *bv, u64 idx, u64 count) {
ValidateBitVec(bv);
if (idx >= bv->length) {- In
BitVec.c:464:
}
bool BitVecRemoveFirst(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:476:
}
bool BitVecRemoveLast(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:488:
}
u64 BitVecRemoveAll(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:513:
}
u64 BitVecCountOnes(const BitVec *bitvec) {
ValidateBitVec(bitvec);
if (!bitvec->data)- In
BitVec.c:526:
}
u64 BitVecCountZeros(const BitVec *bitvec) {
ValidateBitVec(bitvec);
return bitvec->length - BitVecCountOnes(bitvec);- In
BitVec.c:531:
}
void BitVecAnd(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:548:
}
void BitVecOr(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:565:
}
void BitVecXor(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:582:
}
void BitVecNot(BitVec *result, BitVec *bitvec) {
ValidateBitVec(result);
ValidateBitVec(bitvec);- In
BitVec.c:596:
}
bool BitVecEquals(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:607:
}
bool BitVecEqualsRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:631:
// to distinct buckets.
u64 bitvec_hash(const void *data, u32 size) {
const BitVec *bv = (const BitVec *)data;
u64 hash = 1469598103934665603ULL;- In
BitVec.c:652:
i32 bitvec_compare(const void *lhs, const void *rhs) {
return (i32)BitVecCompare((const BitVec *)lhs, (const BitVec *)rhs);
}- In
BitVec.c:655:
}
int BitVecCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:677:
}
int BitVecCompareRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:702:
}
int BitVecNumericalCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:725:
}
int BitVecWeightCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:741:
}
int BitVecSignedCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:770:
}
bool BitVecIsSubset(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:791:
}
bool BitVecIsSuperset(const BitVec *bv1, const BitVec *bv2) {
return BitVecIsSubset(bv2, bv1);
}- In
BitVec.c:795:
}
bool BitVecDisjoint(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:810:
}
bool BitVecOverlaps(const BitVec *bv1, const BitVec *bv2) {
return !BitVecDisjoint(bv1, bv2);
}- In
BitVec.c:814:
}
bool BitVecIsSorted(const BitVec *bv) {
ValidateBitVec(bv);- In
BitVec.c:832:
}
bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc) {
ValidateBitVec(bv);
if (!out) {- In
BitVec.c:859:
}
Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
Str result;- In
BitVec.c:869:
}
static bool bitvec_try_from_str_impl(BitVec *out, Zstr str, u64 str_len, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:905:
}
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:912:
}
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:919:
}
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc) {
BitVec result;- In
BitVec.c:920:
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_str_zstr(&result, str, alloc)) {- In
BitVec.c:929:
}
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
BitVec result;- In
BitVec.c:930:
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_str_str(&result, str, alloc)) {- In
BitVec.c:939:
}
u64 BitVecToBytes(BitVec *bv, u8 *bytes, u64 max_len) {
ValidateBitVec(bv);
if (!bytes) {- In
BitVec.c:968:
}
bool bitvec_try_from_bytes(BitVec *out, const u8 *bytes, u64 bit_len, Allocator *alloc) {
if (!bytes) {
LOG_FATAL("bytes is NULL");- In
BitVec.c:998:
}
BitVec bitvec_from_bytes(const u8 *bytes, u64 bit_len, Allocator *alloc) {
BitVec result;- In
BitVec.c:999:
BitVec bitvec_from_bytes(const u8 *bytes, u64 bit_len, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_bytes(&result, bytes, bit_len, alloc)) {- In
BitVec.c:1008:
}
u64 BitVecToInteger(const BitVec *bv) {
ValidateBitVec(bv);
if (bv->length == 0) {- In
BitVec.c:1026:
}
bool bitvec_try_from_integer(BitVec *out, u64 value, u64 bits, Allocator *alloc) {
if (!out) {
LOG_FATAL("out is NULL");- In
BitVec.c:1054:
}
BitVec bitvec_from_integer(u64 value, u64 bits, Allocator *alloc) {
BitVec result;- In
BitVec.c:1055:
BitVec bitvec_from_integer(u64 value, u64 bits, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_integer(&result, value, bits, alloc)) {- In
BitVec.c:1064:
}
void BitVecShiftLeft(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1087:
}
void BitVecShiftRight(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1108:
}
void BitVecRotateLeft(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1119:
}
BitVec temp = BitVecClone(bv);
if (temp.length != bv->length) {
BitVecDeinit(&temp);- In
BitVec.c:1134:
}
void BitVecRotateRight(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1145:
}
BitVec temp = BitVecClone(bv);
if (temp.length != bv->length) {
BitVecDeinit(&temp);- In
BitVec.c:1160:
}
void BitVecReverse(BitVec *bv) {
ValidateBitVec(bv);
if (bv->length <= 1) {- In
BitVec.c:1175:
}
u64 BitVecFind(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1186:
}
u64 BitVecFindLast(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1205:
}
bool BitVecAll(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1216:
}
bool BitVecAny(const BitVec *bv, bool value) {
ValidateBitVec(bv);
return BitVecFind(bv, value) != SIZE_MAX;- In
BitVec.c:1221:
}
bool BitVecNone(const BitVec *bv, bool value) {
return !BitVecAny(bv, value);
}- In
BitVec.c:1225:
}
u64 BitVecLongestRun(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1249:
}
u64 BitVecFindPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1265:
}
u64 BitVecFindLastPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1284:
}
u64 bitvec_find_all_pattern_raw(BitVec *bv, BitVec *pattern, size *results, u64 max_results) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1308:
}
bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1329:
}
u64 bitvec_run_lengths_raw(BitVec *bv, u64 *runs, bool *values, u64 max_runs) {
ValidateBitVec(bv);
if (!runs || !values || max_runs == 0) {- In
BitVec.c:1372:
}
bool bitvec_run_lengths_vec(BitVec *bv, BitVecRuns *out) {
ValidateBitVec(bv);
if (!out || !out->allocator) {- In
BitVec.c:1402:
}
u64 BitVecHammingDistance(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1423:
}
double BitVecJaccardSimilarity(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1450:
}
double BitVecCosineSimilarity(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1468:
}
u64 BitVecDotProduct(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1484:
}
bool BitVecTryEditDistance(BitVec *bv1, BitVec *bv2, u64 *out) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1552:
}
u64 BitVecEditDistanceWithError(BitVec *bv1, BitVec *bv2, bool *error) {
u64 result = 0;
bool ok = BitVecTryEditDistance(bv1, bv2, &result);- In
BitVec.c:1563:
}
double BitVecCorrelation(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1591:
}
double BitVecEntropy(BitVec *bv) {
ValidateBitVec(bv);- In
BitVec.c:1609:
}
int BitVecAlignmentScore(BitVec *bv1, BitVec *bv2, int match, int mismatch) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1627:
}
u64 BitVecBestAlignment(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1660:
}
bool BitVecStartsWith(BitVec *bv, BitVec *prefix) {
ValidateBitVec(bv);
ValidateBitVec(prefix);- In
BitVec.c:1671:
}
bool BitVecEndsWith(BitVec *bv, BitVec *suffix) {
ValidateBitVec(bv);
ValidateBitVec(suffix);- In
BitVec.c:1683:
}
bool BitVecContainsAt(BitVec *bv, BitVec *pattern, u64 idx) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1703:
}
u64 BitVecCountPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1721:
}
u64 BitVecRFindPattern(BitVec *bv, BitVec *pattern, u64 start) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1741:
}
bool BitVecReplace(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
ValidateBitVec(bv);
ValidateBitVec(old_pattern);- In
BitVec.c:1762:
}
u64 BitVecReplaceAll(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
ValidateBitVec(bv);
ValidateBitVec(old_pattern);- In
BitVec.c:1802:
}
bool BitVecMatches(BitVec *bv, BitVec *pattern, BitVec *wildcard) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1823:
}
u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1849:
}
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
BitVec.c:1870:
}
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
BitVec.c:1887:
}
u64 BitVecPrefixMatch(BitVec *bv, BitVecs *patterns) {
ValidateBitVec(bv);
if (!patterns) {- In
BitVec.c:1902:
}
u64 BitVecSuffixMatch(BitVec *bv, BitVecs *patterns) {
ValidateBitVec(bv);
if (!patterns) {- In
BitVec.c:1919:
// Structural body for BitVec. Memoized via MAGIC_VALIDATED_BIT;
// capacity / data / byte_size changes (grow paths) flip the bit.
static void validate_bitvec_structural(const BitVec *bv) {
if (bv->length > bv->capacity) {
LOG_FATAL("Invalid bitvec object: length > capacity.");- In
BitVec.c:1936:
}
void ValidateBitVec(const BitVec *bv) {
if (!bv) {
LOG_FATAL("Invalid bitvec object: NULL.");- In
BitVec.c:1947:
}
validate_bitvec_structural(bv);
((BitVec *)(void *)bv)->__magic &= ~MAGIC_VALIDATED_BIT;
}- In
Int.c:10:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int/Private.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>- In
Int.c:28:
static u64 int_u64_bits(u64 value);
static Int int_wrap(BitVec bits) {
Int value; #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecShrinkToFit\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecSwap\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector
WriteFmt("Testing BitVecClone\n");
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up original bitvector
// Clone the bitvector
BitVec clone = BitVecClone(&original);
// Check that clone has same content as original
alloc.base.retry_limit = 9;
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&original, true); BitVecPush(&original, true);
BitVec clone = BitVecClone(&original);
// Clone should share the same Allocator* and therefore see identical
WriteFmt("Testing BitVecShrinkToFit edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecSwap edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecClone edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test clone empty bitvec
BitVec clone1 = BitVecClone(&bv);
result = result && (BitVecLen(&clone1) == 0);
BitVecDeinit(&clone1); // Test clone single element
BitVecPush(&bv, true);
BitVec clone2 = BitVecClone(&bv);
result = result && (BitVecLen(&clone2) == 1);
result = result && (BitVecGet(&clone2, 0) == true); }
BitVec clone3 = BitVecClone(&bv);
result = result && (BitVecLen(&clone3) == 1000); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec memory stress test\n");
bool result = true;
for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc)); for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Add random-sized data
// Clone and swap
BitVec clone = BitVecClone(&bv1);
BitVecSwap(&bv1, &bv2); // Deadend tests
bool test_bitvec_memory_null_failures(void) {
WriteFmt("Testing BitVec memory NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec swap NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec swap NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
bool test_bitvec_clone_null_failures(void) {
WriteFmt("Testing BitVec clone NULL handling\n");
// Test NULL pointer - should abort
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Memory tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Memory");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecAnd\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1101
WriteFmt("Testing BitVecOr\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmt("Testing BitVecXor\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmt("Testing BitVecNot\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1010
WriteFmt("Testing BitVecShiftLeft\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011 (indices 0,1,2,3)
WriteFmt("Testing BitVecShiftRight\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecRotateLeft\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecRotateRight\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecReverse\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec shift edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec shift edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec rotate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec rotate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bitwise operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bitwise operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test operations on empty bitvecs
BitVec result_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecAnd(&result_bv, &bv1, &bv2);
result = result && (BitVecLen(&result_bv) == 0); WriteFmt("Testing BitVecReverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive bitwise operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive bitwise operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive shift operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive shift operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test various shift amounts
BitVec original = BitVecClone(&bv);
// Shift left by 1, then right by 1 - should NOT restore original (data loss)
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive rotate operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive rotate operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; }
BitVec original = BitVecClone(&bv);
// Rotate left by 3, then right by 3
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bitwise identity operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bitwise identity operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bitwise commutative properties\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bitwise commutative properties\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bitwise operations with large patterns\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bitwise operations with large patterns\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.BitWise tests\n\n");
// Array of normal test functions
// Run simple tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "BitVec.BitWise.Simple");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecRunLengths with NULL runs array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
bool values[5]; WriteFmt("Testing BitVecRunLengths with NULL values array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5]; WriteFmt("Testing BitVecRunLengths with zero max_runs\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5]; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach with invalid bitvec\n");
// Test foreach with invalid bitvec (length > 0 but data is NULL)
// no public setter exists -- the whole point of this test is to plant
// length>0 with data==NULL so ValidateBitVec aborts in the foreach prologue.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bv.length = 5;
bv.capacity = 10; // Main function that runs all deadend tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Foreach.Deadend tests\n\n");
// Array of deadend test functions
// Run all deadend tests using the centralized test driver
return run_test_suite(NULL, 0, deadend_tests, total_deadend_tests, "BitVec.Foreach.Deadend");
}- In
Int.Type.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h> #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecPush\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecInsert (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Insert at index 0 (empty bitvector)
WriteFmt("Testing BitVecInsertRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create target bitvector
WriteFmt("Testing BitVecInsertMultiple\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
WriteFmt("Testing BitVecInsertPattern\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
// Test with different pattern - 0x05 (0101 in binary) using only 3 bits
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true); WriteFmt("Testing BitVecInsertRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecInsertMultiple edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecInsertPattern edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Deadend tests
bool test_bitvec_insert_null_failures(void) {
WriteFmt("Testing BitVec insert NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec insert invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec insert invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test inserting beyond capacity limit - should abort
bool test_bitvec_insert_pattern_null_failures(void) {
WriteFmt("Testing BitVec insert pattern NULL handling\n");
// Test NULL bitvec - should abort
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Insert tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Insert");
}- In
BitVec.Type.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>- In
BitVec.Type.c:16:
// Test basic BitVec type functionality
bool test_bitvec_type_basic(void) {
WriteFmt("Testing basic BitVec type functionality\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
BitVec.Type.c:21:
// Create a bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
BitVec.Type.c:42:
// Create a valid bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// This should not abort
- In
BitVec.Type.c:59:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Type tests\n\n");
// Array of test functions
- In
BitVec.Type.c:67:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "BitVec.Type");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing basic BitVec pattern functions\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing basic BitVec pattern functions\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindLastPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindAllPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindAllPattern Vec form\n");
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true;
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec pattern edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec pattern edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec pattern stress tests\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec pattern stress tests\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecStartsWith basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecStartsWith edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEndsWith basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEndsWith edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecContainsAt basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecContainsAt edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCountPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplace basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplaceAll basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecMatches basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFuzzyMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRegexMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecPrefixMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true; BitVecPush(&source, true);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2); BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true; BitVecPush(&source, true);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2); BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc)); // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Pattern.Simple tests\n\n");
// Array of test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "BitVec.Pattern.Simple");
}- In
Io.Read.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>- In
Io.Read.c:809:
bool test_bitvec_reading(void) {
WriteFmt("Testing BitVec reading\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Io.Read.c:818:
bool success = true;
BitVec bv1 = BitVecInit(alloc_base);
z = "10110";
StrReadFmt(z, "{}", bv1);- In
Io.Read.c:831:
BitVecDeinit(&bv1);
BitVec bv2 = BitVecInit(alloc_base);
z = "0xDEAD";
StrReadFmt(z, "{}", bv2);- In
Io.Read.c:839:
BitVecDeinit(&bv2);
BitVec bv3 = BitVecInit(alloc_base);
z = "0o755";
StrReadFmt(z, "{}", bv3);- In
Io.Read.c:847:
BitVecDeinit(&bv3);
BitVec bv4 = BitVecInit(alloc_base);
z = " 1101";
StrReadFmt(z, "{}", bv4);- In
Io.Read.c:860:
BitVecDeinit(&bv4);
BitVec bv5 = BitVecInit(alloc_base);
z = "0";
StrReadFmt(z, "{}", bv5);- In
Io.Read.c:873:
BitVecDeinit(&bv5);
WriteFmt("Overall BitVec reading success: {}\n", success ? "true" : "false");
DefaultAllocatorDeinit(&alloc);
return success;- In
Io.Write.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>- In
Io.Write.c:522:
bool test_bitvec_formatting(void) {
WriteFmt("Testing BitVec formatting\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Io.Write.c:530:
bool success = true;
BitVec bv1 = BitVecFromStr("10110", alloc_base);
StrAppendFmt(&output, "{}", bv1);
success = success && (ZstrCompare(StrBegin(&output), "10110") == 0);- In
Io.Write.c:535:
StrClear(&output);
BitVec bv_empty = BitVecInit(alloc_base);
StrAppendFmt(&output, "{}", bv_empty);
success = success && (StrLen(&output) == 0);- In
Io.Write.c:540:
StrClear(&output);
BitVec bv2 = BitVecFromInteger(0xABCD, 16, alloc_base);
StrAppendFmt(&output, "{x}", bv2);
success = success && (ZstrCompare(StrBegin(&output), "0xabcd") == 0);- In
Io.Write.c:549:
StrClear(&output);
BitVec bv3 = BitVecFromInteger(0755, 10, alloc_base);
StrAppendFmt(&output, "{o}", bv3);
success = success && (ZstrCompare(StrBegin(&output), "0o755") == 0);- In
Io.Write.c:566:
StrClear(&output);
BitVec bv_zero = BitVecFromInteger(0, 1, alloc_base);
StrAppendFmt(&output, "{x}", bv_zero);
success = success && (ZstrCompare(StrBegin(&output), "0x0") == 0);- In
BitVec.Math.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
BitVec.Math.c:56:
WriteFmt("Testing BitVecHammingDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
BitVec.Math.c:57:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecHammingDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecJaccardSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecJaccardSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCosineSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCosineSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecDotProduct basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecDotProduct edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEditDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEditDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCorrelation basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCorrelation edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAlignmentScore basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAlignmentScore edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecBestAlignment basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecBestAlignment edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec Math stress tests\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec Math stress tests\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test edit distance with smaller vectors (expensive operation)
BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 50; i++) { // Test edit distance with smaller vectors (expensive operation)
BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 50; i++) {
BitVecPush(&small1, i % 2 == 0);
WriteFmt("Testing BitVecHammingDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecHammingDistance(NULL, &bv2);
WriteFmt("Testing BitVecHammingDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecHammingDistance(&bv1, NULL);
WriteFmt("Testing BitVecJaccardSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecJaccardSimilarity(NULL, &bv2);
WriteFmt("Testing BitVecJaccardSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecJaccardSimilarity(&bv1, NULL);
WriteFmt("Testing BitVecCosineSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCosineSimilarity(NULL, &bv2);
WriteFmt("Testing BitVecCosineSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCosineSimilarity(&bv1, NULL);
WriteFmt("Testing BitVecDotProduct(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecDotProduct(NULL, &bv2);
WriteFmt("Testing BitVecDotProduct(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecDotProduct(&bv1, NULL);
WriteFmt("Testing BitVecEditDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecEditDistance(NULL, &bv2);
WriteFmt("Testing BitVecEditDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecEditDistance(&bv1, NULL);
WriteFmt("Testing BitVecCorrelation(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCorrelation(NULL, &bv2);
WriteFmt("Testing BitVecCorrelation(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCorrelation(&bv1, NULL);
WriteFmt("Testing BitVecAlignmentScore(NULL, bv2, 1, -1) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecAlignmentScore(NULL, &bv2, 1, -1);
WriteFmt("Testing BitVecAlignmentScore(bv1, NULL, 1, -1) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecAlignmentScore(&bv1, NULL, 1, -1);
WriteFmt("Testing BitVecBestAlignment(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecBestAlignment(NULL, &bv2);
WriteFmt("Testing BitVecBestAlignment(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecBestAlignment(&bv1, NULL); // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Math tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Math");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>
bool test_bitvec_predicate_deadend_tests(void) {
WriteFmt("Testing BitVec predicate deadend scenarios\n");
// This should cause LOG_FATAL and terminate the program
// Deadend tests
bool test_bitvec_access_null_failures(void) {
WriteFmt("Testing BitVec access NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
bool test_bitvec_set_null_failures(void) {
WriteFmt("Testing BitVec set NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
bool test_bitvec_flip_null_failures(void) {
WriteFmt("Testing BitVec flip NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test get from empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec set bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test set on empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec flip bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec flip bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test flip on empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec set with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec flip with edge case out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec flip with edge case out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&bv, i % 2 == 0);
bool test_bitvec_count_null_failures(void) {
WriteFmt("Testing BitVec count operations with NULL pointer\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get with maximum index value\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get with maximum index value\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); // Main function that runs all deadend tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Access.Deadend tests\n\n");
// Deadend tests that would cause program termination
// Run all deadend tests using the centralized test driver
return run_test_suite(NULL, 0, deadend_tests, total_deadend_tests, "BitVec.Access.Deadend");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> // Deadend tests
bool test_bitvec_bitwise_null_failures(void) {
WriteFmt("Testing BitVec bitwise NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bitwise operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bitwise operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
bool test_bitvec_reverse_null_failures(void) {
WriteFmt("Testing BitVec reverse NULL handling\n");
// Test NULL pointer - should abort
// NEW: Additional deadend tests
bool test_bitvec_shift_ops_null_failures(void) {
WriteFmt("Testing BitVec shift operations NULL handling\n");
// Test NULL pointer for shift right - should abort
bool test_bitvec_rotate_ops_null_failures(void) {
WriteFmt("Testing BitVec rotate operations NULL handling\n");
// Test NULL pointer for rotate - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec AND with NULL result handling\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec AND with NULL result handling\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecPush(&bv2, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec OR with NULL operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec OR with NULL operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec XOR with NULL second operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec XOR with NULL second operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL second operand - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec NOT with NULL handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec NOT with NULL handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
// Main function that runs all deadend tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.BitWise.Deadend tests\n\n");
// Array of deadend test functions
// Run all deadend tests using the centralized test driver
return run_test_suite(NULL, 0, deadend_tests, total_deadend_tests, "BitVec.BitWise.Deadend");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecGet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecSet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Reserve space and set bits
WriteFmt("Testing BitVecFlip\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecLength and BitVecCapacity\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Initially empty
WriteFmt("Testing BitVecCount operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push a pattern: true, false, true, false, true
WriteFmt("Testing BitVecGet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecSet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set first bit
WriteFmt("Testing BitVecFlip edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test flipping single bit
WriteFmt("Testing BitVecCount edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec multiple access operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec multiple access operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec access with large patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec access with large patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec macro functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec macro functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec access stress test\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec access stress test\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive bit patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive bit patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFind functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec predicate functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec predicate functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFind edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec predicate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec predicate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Access.Simple tests\n\n");
// Array of test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "BitVec.Access.Simple");
}- In
BitVec.Init.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
BitVec.Init.c:29:
// Test basic initialization
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
BitVec.Init.c:51:
WriteFmt("Testing BitVecDeinit\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data to make sure deinitialization works with allocated memory
- In
BitVec.Init.c:83:
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Reserve space for 50 bits
WriteFmt("Testing BitVecClear\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
WriteFmt("Testing BitVecResize\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some initial data
// Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); // Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&bv1) == 0) && (BitVecLen(&bv2) == 0) && (BitVecLen(&bv3) == 0); WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReu64 edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecClear edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec multiple init/deinit cycles\n");
bool result = true; // Test multiple init/deinit cycles
for (int cycle = 0; cycle < 100; cycle++) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
// Deadend tests - verify expected failures occur gracefully
bool test_bitvec_null_pointer_failures(void) {
WriteFmt("Testing BitVec NULL pointer handling\n");
// Test NULL pointer passed to functions that should validate
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec invalid operations\n");
// BitVecReserve is now a fallible API that returns bool on allocation
// failure rather than aborting. The Must variant aborts, so use it here
// to validate the deadend abort path.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecMustReserve(&bv, SIZE_MAX); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set operations on invalid indices\n");
// BitVecResize is now a fallible API that returns bool on allocation
// failure rather than aborting. The Must variant aborts, so use it here
// to validate the deadend abort path.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecMustResize(&bv, SIZE_MAX); // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Init tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Init");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecForeachIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeach macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeachReverse macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false, true
WriteFmt("Testing BitVecForeachInRange macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: false, true, true, false, true
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
int count = 0; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach idx edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach idx edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
u64 last_idx = SIZE_MAX; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach reverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach reverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach range edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach range edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach stress test\n");
bool result = true;
for (int sz = 0; sz < 100; sz += 10) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvec of varying sz
WriteFmt("Testing BitVecRunLengths basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRunLengths Vec form\n");
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);
BitVecPush(&bv, true);
// Test 1: Empty bitvector
BitVec empty_bv = BitVecInit(ALLOCATOR_OF(&alloc));
u64 runs[5];
bool values[5];
// Test 2: Single bit (true)
BitVec single_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_bv, true);
count = BitVecRunLengths(&single_bv, runs, values, 5);
// Test 3: Single bit (false)
BitVec single_false_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_false_bv, false);
count = BitVecRunLengths(&single_false_bv, runs, values, 5);
// Test 4: All same bits (all true)
BitVec all_true_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&all_true_bv, true);
// Test 5: Alternating bits (0101010)
BitVec alternating_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 7; i++) {
BitVecPush(&alternating_bv, i % 2 == 0); WriteFmt("Testing BitVecRunLengths boundary conditions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test with large bitvector
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern that results in many runs
// Main function that runs all simple tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Foreach.Simple tests\n\n");
// Array of normal test functions
// Run simple tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "BitVec.Foreach.Simple");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecPop\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecRemove (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, true, false, true
WriteFmt("Testing BitVecRemoveFirst\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveLast\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveAll\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true, false
WriteFmt("Testing BitVecPop edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemove edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveFirst/Last edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveAll edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Deadend tests
bool test_bitvec_remove_null_failures(void) {
WriteFmt("Testing BitVec remove NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
bool test_bitvec_remove_range_null_failures(void) {
WriteFmt("Testing BitVec remove range NULL handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec remove invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test removing beyond capacity limit - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec pop bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec pop bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test pop from empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec remove bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove from empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove range bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec remove range bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove range from empty bitvec - should abort
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Remove tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Remove");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmtLn("Testing BitVecAnd");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1101
WriteFmtLn("Testing BitVecOr");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmtLn("Testing BitVecXor");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmtLn("Testing BitVecNot");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1010
WriteFmtLn("Testing BitVecShiftLeft");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011 (indices 0,1,2,3)
WriteFmtLn("Testing BitVecShiftRight");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmtLn("Testing BitVecRotateLeft");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmtLn("Testing BitVecRotateRight");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmtLn("Testing BitVecReverse");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec shift edge cases");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec shift edge cases");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec rotate edge cases");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec rotate edge cases");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec bitwise operations edge cases");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec bitwise operations edge cases");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test operations on empty bitvecs
BitVec result_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecAnd(&result_bv, &bv1, &bv2);
result = result && (BitVecLen(&result_bv) == 0); WriteFmtLn("Testing BitVecReverse edge cases");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec comprehensive bitwise operations");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec comprehensive bitwise operations");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec comprehensive shift operations");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec comprehensive shift operations");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test various shift amounts
BitVec original = BitVecClone(&bv);
// Shift left by 1, then right by 1 - should NOT restore original (data loss)
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec comprehensive rotate operations");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec comprehensive rotate operations");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; }
BitVec original = BitVecClone(&bv);
// Rotate left by 3, then right by 3
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec bitwise identity operations");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec bitwise identity operations");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec bitwise commutative properties");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec bitwise commutative properties");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec bitwise operations with large patterns");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec bitwise operations with large patterns");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; // Deadend tests
bool test_bitvec_bitwise_null_failures(void) {
WriteFmtLn("Testing BitVec bitwise NULL pointer handling");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec bitwise operations NULL handling");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec bitwise operations NULL handling");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
bool test_bitvec_reverse_null_failures(void) {
WriteFmtLn("Testing BitVec reverse NULL handling");
// Test NULL pointer - should abort
// NEW: Additional deadend tests
bool test_bitvec_shift_ops_null_failures(void) {
WriteFmtLn("Testing BitVec shift operations NULL handling");
// Test NULL pointer for shift right - should abort
bool test_bitvec_rotate_ops_null_failures(void) {
WriteFmtLn("Testing BitVec rotate operations NULL handling");
// Test NULL pointer for rotate - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec AND with NULL result handling");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec AND with NULL result handling");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecPush(&bv2, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec OR with NULL operand handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec OR with NULL operand handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec XOR with NULL second operand handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec XOR with NULL second operand handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL second operand - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmtLn("Testing BitVec NOT with NULL handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmtLn("Testing BitVec NOT with NULL handling");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
// Main function that runs all tests
int main(void) {
WriteFmtLn("[INFO] Starting BitVec.BitWise tests");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.BitWise");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h> WriteFmt("Testing BitVecToStr\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011
// Convert from string
Zstr str = "1011";
BitVec bv;
bool ok = BitVecTryFromStr(&bv, str, ALLOCATOR_OF(&alloc));
// Test with empty string
BitVec empty_bv = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&empty_bv) == 0); WriteFmt("Testing BitVecToBytes\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 10110011 (0xB3)
// Create byte array
u8 bytes[] = {0xB3}; // 10110011 in binary
BitVec bv;
bool ok = BitVecTryFromBytes(&bv, bytes, 8, ALLOCATOR_OF(&alloc)); // 8 bits from the byte
WriteFmt("Testing BitVecToInteger\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011 (decimal 11 if MSB first, 13 if LSB first)
// Test with larger pattern
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 8; i++) {
BitVecPush(&bv2, (i % 2 == 0)); // Alternating pattern
// Convert from integer
u64 value = 11; // 1011 in binary
BitVec bv;
bool ok = BitVecTryFromInteger(&bv, value, 4, ALLOCATOR_OF(&alloc));
// Test with zero
BitVec zero_bv;
result = result && BitVecTryFromInteger(&zero_bv, 0, 8, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&zero_bv) == 8);
bool test_bitvec_try_conversion_allocators(void) {
WriteFmt("Testing BitVec try conversion allocator behavior\n");
DefaultAllocator alloc = DefaultAllocatorInit(); alloc.base.retry_limit = 3;
BitVec bv;
Str str;
bool ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc)); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec convert edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec convert edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test empty string
BitVec bv1 = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv1) == 0);
BitVecDeinit(&bv1);
// Test single character
BitVec bv2 = BitVecFromStr("1", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv2) == 1);
result = result && (BitVecGet(&bv2, 0) == true); long_str[1000] = '\0';
BitVec bv3 = BitVecFromStr(long_str, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv3) == 1000);
result = result && (BitVecGet(&bv3, 0) == true); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bytes conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Test bytes to bitvec with 0 bits (should return empty bitvector)
u8 empty_bytes[1] = {0x05};
BitVec bv2 = BitVecFromBytes(empty_bytes, 0, ALLOCATOR_OF(&alloc)); // 0 bits
result = result && (BitVecLen(&bv2) == 0);
BitVecDeinit(&bv2); // Test single byte
u8 single_byte[1] = {0xFF};
BitVec bv3 = BitVecFromBytes(single_byte, 8, ALLOCATOR_OF(&alloc)); // 8 bits from 1 byte
result = result && (BitVecLen(&bv3) == 8);
BitVecDeinit(&bv3); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec integer conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec integer conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test integer to bitvec with 0
BitVec bv2 = BitVecFromInteger(0, 8, ALLOCATOR_OF(&alloc)); // 8 bits for zero
result = result && (BitVecLen(&bv2) == 8); // Should be 8 bits
BitVecDeinit(&bv2);
// Test large integer
BitVec bv3 = BitVecFromInteger(UINT64_MAX, 64, ALLOCATOR_OF(&alloc)); // 64 bits for max value
result = result && (BitVecLen(&bv3) == 64);
BitVecDeinit(&bv3); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec round-trip conversions\n");
bool result = true;
for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
BitVec bv = BitVecFromStr(patterns[i], ALLOCATOR_OF(&alloc));
Str str = BitVecToStr(&bv); value &= mask;
BitVec bv = BitVecFromInteger(value, bits, ALLOCATOR_OF(&alloc));
u64 recovered = BitVecToInteger(&bv);
for (size i = 0; i < sizeof(test_bytes); i++) {
BitVec bv = BitVecFromBytes(&test_bytes[i], 8, ALLOCATOR_OF(&alloc));
u8 recovered_byte = 0;
u64 written = BitVecToBytes(&bv, &recovered_byte, 1); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec conversion bounds checking\n");
bool result = true;
// Test large integer conversion (should cap at 64 bits)
BitVec large_bv = BitVecFromInteger(0xFFFFFFFFFFFFFFFF, 64, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_bv) == 64);
// Test oversized bitvec to integer (should handle gracefully)
BitVec oversized = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 100; i++) { // 100 bits > 64 bit limit
BitVecPush(&oversized, i % 2 == 0);
// Test zero-length conversions
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
Str empty_str = BitVecToStr(&empty); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive conversion validation\n");
bool result = true;
for (size i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); i++) {
BitVec bv = BitVecFromStr(test_cases[i].pattern, ALLOCATOR_OF(&alloc));
// Test string conversion consistency
// Test cross-format validation
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc)); // Test cross-format validation
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
// All three should produce the same result when converted back
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec large-scale conversions\n");
bool result = true;
// Test with very large bitvectors
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create a 1000-bit pattern
// Test round-trip from bytes
BitVec recovered_bv = BitVecFromBytes(large_bytes, 1000, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&recovered_bv) == 1000); large_pattern[2000] = '\0';
BitVec large_from_str = BitVecFromStr(large_pattern, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_from_str) == 2000); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes bounds failures\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec bytes bounds failures\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); // Test fromBytes with 0 bit length - should return empty bitvec
u8 dummy_bytes[1] = {0xFF};
BitVec empty_bv = BitVecFromBytes(dummy_bytes, 0, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&empty_bv) == 0);
BitVecDeinit(&empty_bv);
bool test_bitvec_integer_bounds_failures(void) {
WriteFmt("Testing BitVec integer bounds failures\n");
// Test BitVecToInteger with NULL pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec convert NULL pointer handling\n");
// Use the explicit-allocator form so the NULL bitvec reaches the
// function-level ValidateBitVec instead of dereferencing NULL
// inside the BitVecAllocator accessor macro.
BitVecToStr((BitVec *)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec from string NULL handling\n");
// Test NULL string - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes NULL handling\n");
// Test NULL bytes - should abort
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Convert tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Convert");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecForeachIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeach macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeachReverse macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false, true
WriteFmt("Testing BitVecForeachInRange macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: false, true, true, false, true
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
int count = 0; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach idx edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach idx edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
u64 last_idx = SIZE_MAX; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach reverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach reverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach range edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec foreach range edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec foreach stress test\n");
bool result = true;
for (int sz = 0; sz < 100; sz += 10) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvec of varying sz
WriteFmt("Testing BitVecRunLengths basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test 1: Empty bitvector
BitVec empty_bv = BitVecInit(ALLOCATOR_OF(&alloc));
u64 runs[5];
bool values[5];
// Test 2: Single bit (true)
BitVec single_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_bv, true);
count = BitVecRunLengths(&single_bv, runs, values, 5);
// Test 3: Single bit (false)
BitVec single_false_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_false_bv, false);
count = BitVecRunLengths(&single_false_bv, runs, values, 5);
// Test 4: All same bits (all true)
BitVec all_true_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&all_true_bv, true);
// Test 5: Alternating bits (0101010)
BitVec alternating_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 7; i++) {
BitVecPush(&alternating_bv, i % 2 == 0); WriteFmt("Testing BitVecRunLengths boundary conditions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test with large bitvector
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern that results in many runs
WriteFmt("Testing BitVecRunLengths with NULL runs array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
bool values[5]; WriteFmt("Testing BitVecRunLengths with NULL values array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5]; WriteFmt("Testing BitVecRunLengths with zero max_runs\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5];
bool test_bitvec_foreach_invalid_usage(void) {
WriteFmt("Testing BitVec foreach with invalid bitvec\n");
// Test foreach with invalid bitvec (length > 0 but data is NULL)
// Test foreach with invalid bitvec (length > 0 but data is NULL)
// intentional bypass: deliberately-corrupt struct for ValidateBitVec deadend check.
BitVec bv = {.length = 5, .capacity = 10, .data = NULL, .byte_size = 0};
// This should abort due to ValidateBitVec check
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Foreach tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Foreach");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Allocator/Default.h> WriteFmt("Testing BitVecEquals\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal empty bitvectors
WriteFmt("Testing BitVecCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal bitvectors
WriteFmt("Testing BitVecLexCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
WriteFmt("Testing BitVecNumericalCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvectors representing different numbers
WriteFmt("Testing BitVecWeightCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1: 111 (3 ones)
WriteFmt("Testing BitVecIsSubset\n");
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
WriteFmt("Testing BitVecSignedCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test positive vs negative (MSB is sign bit)
// Test equal signed values
BitVec bv3 = BitVecClone(&bv1);
result = result && (BitVecSignedCompare(&bv1, &bv3) == 0); WriteFmt("Testing BitVecIsSuperset\n");
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
WriteFmt("Testing BitVecOverlaps\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create overlapping bitvectors
WriteFmt("Testing BitVecDisjoint and BitVecIntersects\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create disjoint bitvectors
WriteFmt("Testing BitVecEqualsRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
WriteFmt("Testing BitVecCompareRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
WriteFmt("Testing BitVecIsLexicographicallyLess and BitVecIsNumericallyLess\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
// Test equal cases
BitVec bv3 = BitVecClone(&bv1);
result = result && !(BitVecCompare(&bv1, &bv3) < 0);
result = result && !(BitVecNumericalCompare(&bv1, &bv3) < 0); WriteFmt("Testing BitVecIsSorted\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test empty bitvector (should be sorted)
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec compare edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec compare edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec set operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive comparison operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive comparison operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test transitivity: if A < B and B < C, then A < C
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv3: larger than bv2
for (int i = 0; i < 8; i++) {
// Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc)); // Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create actual subset/superset relationship
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec large-scale comparison operations\n");
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec large-scale comparison operations\n");
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc)); // Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));
// Positive number (MSB = 0): 01111111
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec compare NULL pointer handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec compare NULL pointer handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
bool test_bitvec_subset_null_failures(void) {
WriteFmt("Testing BitVec subset NULL handling\n");
// Test NULL pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec range operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec range operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer in range operations - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec range operations bounds checking\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec range operations bounds checking\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create small bitvectors
bool test_bitvec_sorted_null_failures(void) {
WriteFmt("Testing BitVec sorted operations NULL handling\n");
// Test NULL pointer - should abort
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
for (int i = 0; i < 11; i++) {
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
for (int i = 0; i < 11; i++) {
BitVecPush(&a, (i % 2) == 0); }
BitVec empty1 = BitVecInit(base);
BitVec empty2 = BitVecInit(base);
BitVec empty1 = BitVecInit(base);
BitVec empty2 = BitVecInit(base);
bool result = (bitvec_hash(&a, 0) == bitvec_hash(&b, 0)); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base); BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base);
BitVecPush(&a, true); // shaped helpers wired in directly -- no per-callsite cast needed.
bool test_bitvec_hash_as_map_key(void) {
WriteFmt("Testing bitvec_hash as Map<BitVec, u64> key\n");
DefaultAllocator alloc = DefaultAllocatorInit(); Allocator *base = ALLOCATOR_OF(&alloc);
Map(BitVec, u64) counts = MapInit(bitvec_hash, bitvec_compare, &alloc);
BitVec k1 = BitVecInit(base); Map(BitVec, u64) counts = MapInit(bitvec_hash, bitvec_compare, &alloc);
BitVec k1 = BitVecInit(base);
BitVecPush(&k1, true);
BitVecPush(&k1, false); BitVecPush(&k1, true);
BitVec k2 = BitVecInit(base);
BitVecPush(&k2, false);
BitVecPush(&k2, true); MapInsertR(&counts, k2, 2u);
BitVec probe = BitVecInit(base);
BitVecPush(&probe, true);
BitVecPush(&probe, false); u64 *got = MapGetFirstPtr(&counts, probe);
BitVec missing = BitVecInit(base);
BitVecPush(&missing, true);
BitVecPush(&missing, true); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVecPush(&a, false);
BitVecPush(&a, true); BitVecPush(&a, true);
BitVec b = BitVecInit(base);
BitVecPush(&b, false);
BitVecPush(&b, true); BitVecPush(&b, true);
BitVec c = BitVecInit(base);
BitVecPush(&c, true);
BitVecPush(&c, false); // Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Compare tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Compare");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecGet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add a pattern: 1010
WriteFmt("Testing BitVecSet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Initialize with some bits
WriteFmt("Testing BitVecFlip\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Initialize with pattern: 101
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec length and capacity operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec length and capacity operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Initially should be empty
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec count operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec count operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1101000
WriteFmt("Testing BitVecGet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecSet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFlip edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec count edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec count edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec multiple access operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec multiple access operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec large pattern access\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec large pattern access\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec macro functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec macro functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec access stress test\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec access stress test\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive bit patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec comprehensive bit patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Deadend tests
bool test_bitvec_access_null_failures(void) {
WriteFmt("Testing BitVec access NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
bool test_bitvec_set_null_failures(void) {
WriteFmt("Testing BitVec set NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
bool test_bitvec_flip_null_failures(void) {
WriteFmt("Testing BitVec flip NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test get from empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec set bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test set on empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec flip bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec flip bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test flip on empty bitvec - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec set with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec flip with edge case out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec flip with edge case out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&bv, i % 2 == 0);
bool test_bitvec_count_null_failures(void) {
WriteFmt("Testing BitVec count operations with NULL pointer\n");
// Test NULL bitvec pointer - should abort
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec get with maximum index value\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec get with maximum index value\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); WriteFmt("Testing BitVecFind and BitVecFindLast functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAll, BitVecAny, BitVecNone functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun function\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFind edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec predicate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); WriteFmt("Testing BitVec predicate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
bool test_bitvec_predicate_deadend_tests(void) {
WriteFmt("Testing BitVec predicate deadend scenarios\n");
// This should cause LOG_FATAL and terminate the program
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Access tests\n\n");
// Array of test functions (adding new tests to existing ones)
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Access");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> WriteFmt("Testing BitVecFindPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecFindPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false); WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false);
// Don't create pattern BitVec since we're testing NULL source validation
BitVecFindAllPattern(NULL, (BitVec *)0x1, results, 10); // Should cause LOG_FATAL
return true; WriteFmt("Testing BitVecFindAllPattern(source, NULL, results, 10) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVecPush(&source, true); WriteFmt("Testing BitVecFindAllPattern(source, pattern, NULL, 10) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false); WriteFmt("Testing BitVecFindAllPattern(source, pattern, results, 0) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVecPush(&source, true);
WriteFmt("Testing BitVecStartsWith(NULL, prefix) - should fatal\n");
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&prefix, true);
BitVecStartsWith(NULL, &prefix);
WriteFmt("Testing BitVecStartsWith(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecStartsWith(&source, NULL);
WriteFmt("Testing BitVecEndsWith(NULL, suffix) - should fatal\n");
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&suffix, true);
BitVecEndsWith(NULL, &suffix);
WriteFmt("Testing BitVecEndsWith(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecEndsWith(&source, NULL);
WriteFmt("Testing BitVecContainsAt(NULL, pattern, 0) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true);
BitVecContainsAt(NULL, &pattern, 0);
WriteFmt("Testing BitVecContainsAt(source, NULL, 0) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecContainsAt(&source, NULL, 0);
// Don't create BitVecs since we're testing NULL source validation
BitVecReplace(NULL, (BitVec *)0x1, (BitVec *)0x1);
return true;
}
WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true);
BitVecPush(&wildcard, false);
WriteFmt("Testing BitVecRegexMatch(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecRegexMatch(&source, (Zstr)NULL);
WriteFmt("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPrefixMatch(&source, NULL);
WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecSuffixMatch(&source, NULL); // Main function that runs all deadend tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Pattern.Deadend tests\n\n");
// Deadend tests that would cause program termination
// Run all deadend tests using the centralized test driver
return run_test_suite(NULL, 0, deadend_tests, total_deadend_tests, "BitVec.Pattern.Deadend");
}- In
Io.h:218:
#if FEATURE_BITVEC
# define IOFMT_BITVEC_CASE_(x, addr) \
BitVec: \
TO_TYPE_SPECIFIC_IO(BitVec, addr),
#else- In
Io.h:219:
# define IOFMT_BITVEC_CASE_(x, addr) \
BitVec: \
TO_TYPE_SPECIFIC_IO(BitVec, addr),
#else
# define IOFMT_BITVEC_CASE_(x, addr)- In
Io.h:748:
#endif
#if FEATURE_BITVEC
bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- In
Io.h:771:
#endif
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- In
Container.h:19:
#if FEATURE_BITVEC
# include <Misra/Std/Container/BitVec.h>
#endif
#if FEATURE_LIST- In
BitVec.h:10:
#define MISRA_STD_CONTAINER_BITVEC_H
#include "BitVec/Type.h"
#include "BitVec/Init.h"
#include "BitVec/Access.h"- In
BitVec.h:11:
#include "BitVec/Type.h"
#include "BitVec/Init.h"
#include "BitVec/Access.h"
#include "BitVec/BitWise.h"- In
BitVec.h:12:
#include "BitVec/Type.h"
#include "BitVec/Init.h"
#include "BitVec/Access.h"
#include "BitVec/BitWise.h"
#include "BitVec/Insert.h"- In
BitVec.h:13:
#include "BitVec/Init.h"
#include "BitVec/Access.h"
#include "BitVec/BitWise.h"
#include "BitVec/Insert.h"
#include "BitVec/Remove.h"- In
BitVec.h:14:
#include "BitVec/Access.h"
#include "BitVec/BitWise.h"
#include "BitVec/Insert.h"
#include "BitVec/Remove.h"
#include "BitVec/Memory.h"- In
BitVec.h:15:
#include "BitVec/BitWise.h"
#include "BitVec/Insert.h"
#include "BitVec/Remove.h"
#include "BitVec/Memory.h"
#include "BitVec/Convert.h"- In
BitVec.h:16:
#include "BitVec/Insert.h"
#include "BitVec/Remove.h"
#include "BitVec/Memory.h"
#include "BitVec/Convert.h"
#include "BitVec/Pattern.h"- In
BitVec.h:17:
#include "BitVec/Remove.h"
#include "BitVec/Memory.h"
#include "BitVec/Convert.h"
#include "BitVec/Pattern.h"
#include "BitVec/Compare.h"- In
BitVec.h:18:
#include "BitVec/Memory.h"
#include "BitVec/Convert.h"
#include "BitVec/Pattern.h"
#include "BitVec/Compare.h"
#include "BitVec/Math.h"- In
BitVec.h:19:
#include "BitVec/Convert.h"
#include "BitVec/Pattern.h"
#include "BitVec/Compare.h"
#include "BitVec/Math.h"
#include "BitVec/Foreach.h"- In
BitVec.h:20:
#include "BitVec/Pattern.h"
#include "BitVec/Compare.h"
#include "BitVec/Math.h"
#include "BitVec/Foreach.h"- In
BitVec.h:21:
#include "BitVec/Compare.h"
#include "BitVec/Math.h"
#include "BitVec/Foreach.h"
#endif // MISRA_STD_CONTAINER_BITVEC_H
- In
Init.h:11:
#include "Type.h"
#include <Misra/Std/Container/BitVec/Init.h>
///
- In
Access.h:10:
#define MISRA_STD_CONTAINER_INT_ACCESS_H
#include <Misra/Std/Container/BitVec/Access.h>
#include "Type.h"- In
Type.h:10:
#define MISRA_STD_CONTAINER_INT_TYPE_H
#include <Misra/Std/Container/BitVec/Type.h>
///
- In
Type.h:25:
///
typedef struct {
BitVec bits;
} Int;- In
Init.h:66:
#ifdef __cplusplus
# define BitVecInit_1(allocator_ptr) \
(BitVec { \
.length = 0, \
.capacity = 0, \- In
Init.h:76:
#else
# define BitVecInit_1(allocator_ptr) \
((BitVec) {.length = 0, \
.capacity = 0, \
.data = NULL, \- In
Init.h:97:
/// TAGS: BitVec, Init, Capacity, Construct
///
BitVec bitvec_init_with_capacity(u64 cap, Allocator *alloc);
#define BitVecInitWithCapacity(...) OVERLOAD(BitVecInitWithCapacity, __VA_ARGS__)
#define BitVecInitWithCapacity_1(cap) bitvec_init_with_capacity((cap), MisraScope)- In
Init.h:112:
/// TAGS: BitVec, Deinit, Memory
///
void BitVecDeinit(BitVec *bv);
///
- In
Init.h:124:
/// TAGS: BitVec, Clear, Reset, Memory
///
void BitVecClear(BitVec *bv);
///
- In
Init.h:137:
/// TAGS: BitVec, Reserve, Capacity, Memory
///
bool BitVecReserve(BitVec *bv, u64 n);
///
- In
Init.h:151:
/// TAGS: BitVec, Resize, Length, Memory
///
bool BitVecResize(BitVec *bv, u64 n);
#ifdef __cplusplus- In
Pattern.h:33:
/// TAGS: BitVec, Pattern, StartsWith, Match
///
bool BitVecStartsWith(BitVec *bv, BitVec *prefix);
///
- In
Pattern.h:49:
/// TAGS: BitVec, Pattern, EndsWith, Match
///
bool BitVecEndsWith(BitVec *bv, BitVec *suffix);
///
- In
Pattern.h:66:
/// TAGS: BitVec, Pattern, ContainsAt, Position
///
bool BitVecContainsAt(BitVec *bv, BitVec *pattern, u64 idx);
///
- In
Pattern.h:84:
/// TAGS: BitVec, Pattern, Find, Search
///
u64 BitVecFindPattern(BitVec *bv, BitVec *pattern);
///
- In
Pattern.h:100:
/// TAGS: BitVec, Pattern, FindLast, Search
///
u64 BitVecFindLastPattern(BitVec *bv, BitVec *pattern);
///
- In
Pattern.h:129:
/// TAGS: BitVec, Pattern, FindAll, Search
///
u64 bitvec_find_all_pattern_raw(BitVec *bv, BitVec *pattern, size *results, u64 max_results);
bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out);- In
Pattern.h:130:
///
u64 bitvec_find_all_pattern_raw(BitVec *bv, BitVec *pattern, size *results, u64 max_results);
bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out);
#define BitVecFindAllPattern(...) OVERLOAD(BitVecFindAllPattern, __VA_ARGS__)- In
Pattern.h:150:
/// TAGS: BitVec, Pattern, Count, Search
///
u64 BitVecCountPattern(BitVec *bv, BitVec *pattern);
///
- In
Pattern.h:167:
/// TAGS: BitVec, Pattern, RFind, Reverse
///
u64 BitVecRFindPattern(BitVec *bv, BitVec *pattern, u64 start);
///
- In
Pattern.h:185:
/// TAGS: BitVec, Pattern, Replace, Modify
///
bool BitVecReplace(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern);
///
- In
Pattern.h:203:
/// TAGS: BitVec, Pattern, ReplaceAll, Modify
///
u64 BitVecReplaceAll(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern);
///
- In
Pattern.h:221:
/// TAGS: BitVec, Pattern, Match, Wildcard
///
bool BitVecMatches(BitVec *bv, BitVec *pattern, BitVec *wildcard);
///
- In
Pattern.h:239:
/// TAGS: BitVec, Pattern, Fuzzy, Approximate
///
u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors);
///
- In
Pattern.h:256:
/// TAGS: BitVec, Pattern, Regex, Match
///
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern);
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
#define BitVecRegexMatch(bv, pattern) \- In
Pattern.h:257:
///
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern);
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
#define BitVecRegexMatch(bv, pattern) \
_Generic((pattern), Str *: bitvec_regex_match_str, Zstr: bitvec_regex_match_zstr, char *: bitvec_regex_match_zstr)( \- In
Pattern.h:280:
/// TAGS: BitVec, Pattern, Prefix, Multiple
///
u64 BitVecPrefixMatch(BitVec *bv, BitVecs *patterns);
///
- In
Pattern.h:298:
/// TAGS: BitVec, Pattern, Suffix, Multiple
///
u64 BitVecSuffixMatch(BitVec *bv, BitVecs *patterns);
#ifdef __cplusplus- In
Access.h:32:
/// TAGS: BitVec, Access, Get, Boolean
///
bool BitVecGet(const BitVec *bv, u64 idx);
///
- In
Access.h:53:
/// TAGS: BitVec, Access, Set, Boolean
///
void BitVecSet(BitVec *bv, u64 idx, bool value);
///
- In
Access.h:73:
/// TAGS: BitVec, Access, Flip, Toggle
///
void BitVecFlip(BitVec *bv, u64 idx);
///
- In
Access.h:147:
/// TAGS: BitVec, Count, Ones, Population
///
u64 BitVecCountOnes(const BitVec *bv);
///
- In
Access.h:163:
/// TAGS: BitVec, Count, Zeros
///
u64 BitVecCountZeros(const BitVec *bv);
///
- In
Access.h:182:
/// TAGS: BitVec, Find, Search, Access
///
u64 BitVecFind(const BitVec *bv, bool value);
///
- In
Access.h:200:
/// TAGS: BitVec, FindLast, Search, Access
///
u64 BitVecFindLast(const BitVec *bv, bool value);
///
- In
Access.h:219:
/// TAGS: BitVec, All, Check, Predicate
///
bool BitVecAll(const BitVec *bv, bool value);
///
- In
Access.h:237:
/// TAGS: BitVec, Any, Check, Predicate
///
bool BitVecAny(const BitVec *bv, bool value);
///
- In
Access.h:256:
/// TAGS: BitVec, None, Check, Predicate
///
bool BitVecNone(const BitVec *bv, bool value);
///
- In
Access.h:274:
/// TAGS: BitVec, LongestRun, Analysis, Sequence
///
u64 BitVecLongestRun(const BitVec *bv, bool value);
#ifdef __cplusplus- In
Remove.h:37:
/// TAGS: Remove, BitVec, Range, Multiple
///
void BitVecRemoveRange(BitVec *bv, u64 idx, u64 count);
///
- In
Remove.h:56:
/// TAGS: Remove, BitVec, First, Value
///
bool BitVecRemoveFirst(BitVec *bv, bool value);
///
- In
Remove.h:75:
/// TAGS: Remove, BitVec, Last, Value
///
bool BitVecRemoveLast(BitVec *bv, bool value);
///
- In
Remove.h:94:
/// TAGS: Remove, BitVec, All, Value
///
u64 BitVecRemoveAll(BitVec *bv, bool value);
///
- In
Remove.h:111:
/// TAGS: BitVec, Pop, Remove, Last
///
bool BitVecPop(BitVec *bv);
///
- In
Remove.h:131:
/// TAGS: BitVec, Remove, Shift, Single
///
bool BitVecRemove(BitVec *bv, u64 idx);
#ifdef __cplusplus- In
BitWise.h:37:
/// TAGS: BitVec, And, Bitwise, Operation
///
void BitVecAnd(BitVec *result, BitVec *a, BitVec *b);
///
- In
BitWise.h:59:
/// TAGS: BitVec, Or, Bitwise, Operation
///
void BitVecOr(BitVec *result, BitVec *a, BitVec *b);
///
- In
BitWise.h:81:
/// TAGS: BitVec, Xor, Bitwise, Operation
///
void BitVecXor(BitVec *result, BitVec *a, BitVec *b);
///
- In
BitWise.h:101:
/// TAGS: BitVec, Not, Bitwise, Operation
///
void BitVecNot(BitVec *result, BitVec *bv);
///
- In
BitWise.h:123:
/// TAGS: BitVec, Shift, Left, Operation
///
void BitVecShiftLeft(BitVec *bv, u64 positions);
///
- In
BitWise.h:145:
/// TAGS: BitVec, Shift, Right, Operation
///
void BitVecShiftRight(BitVec *bv, u64 positions);
///
- In
BitWise.h:166:
/// TAGS: BitVec, Rotate, Left, Circular
///
void BitVecRotateLeft(BitVec *bv, u64 positions);
///
- In
BitWise.h:187:
/// TAGS: BitVec, Rotate, Right, Circular
///
void BitVecRotateRight(BitVec *bv, u64 positions);
///
- In
BitWise.h:206:
/// TAGS: BitVec, Reverse, Order
///
void BitVecReverse(BitVec *bv);
#ifdef __cplusplus- In
Insert.h:128:
/// TAGS: Insert, BitVec, Range, Multiple
///
bool BitVecInsertRange(BitVec *bv, u64 idx, u64 count, bool value);
///
- In
Insert.h:151:
/// TAGS: Insert, BitVec, Multiple, Copy
///
bool BitVecInsertMultiple(BitVec *bv, u64 idx, BitVec *other);
///
- In
Insert.h:175:
/// TAGS: Insert, BitVec, Pattern, Byte
///
bool BitVecInsertPattern(BitVec *bv, u64 idx, u8 pattern, u64 pattern_bits);
///
- In
Insert.h:196:
/// TAGS: BitVec, Push, Append, Insert
///
bool BitVecPush(BitVec *bv, bool value);
///
- In
Insert.h:217:
/// TAGS: BitVec, Insert, Shift, Single
///
bool BitVecInsert(BitVec *bv, u64 idx, bool value);
#ifdef __cplusplus- In
Convert.h:31:
/// TAGS: BitVec, Convert, String, Allocator
///
bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc);
///
- In
Convert.h:44:
/// TAGS: BitVec, Convert, String, Allocator
///
Str bitvec_to_str(BitVec *bv, Allocator *alloc);
///
- In
Convert.h:58:
/// TAGS: BitVec, Convert, String, Allocator
///
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc);
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc);
#define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)- In
Convert.h:59:
///
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc);
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc);
#define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)
#define BitVecTryFromStr_2(out, str) \- In
Convert.h:85:
/// TAGS: BitVec, Convert, String, Allocator
///
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc);
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc);
#define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)- In
Convert.h:86:
///
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc);
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc);
#define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)
#define BitVecFromStr_1(str) \- In
Convert.h:119:
/// TAGS: BitVec, Convert, Bytes, Export
///
u64 BitVecToBytes(BitVec *bv, u8 *bytes, u64 max_len);
///
- In
Convert.h:134:
/// TAGS: BitVec, Convert, Bytes, Allocator
///
bool bitvec_try_from_bytes(BitVec *out, const u8 *bytes, u64 bit_len, Allocator *alloc);
#define BitVecTryFromBytes(...) OVERLOAD(BitVecTryFromBytes, __VA_ARGS__)
#define BitVecTryFromBytes_3(out, bytes, bit_len) bitvec_try_from_bytes((out), (bytes), (bit_len), MisraScope)- In
Convert.h:152:
/// TAGS: BitVec, Convert, Bytes, Allocator
///
BitVec bitvec_from_bytes(const u8 *bytes, u64 bit_len, Allocator *alloc);
#define BitVecFromBytes(...) OVERLOAD(BitVecFromBytes, __VA_ARGS__)
#define BitVecFromBytes_2(bytes, bit_len) bitvec_from_bytes((bytes), (bit_len), MisraScope)- In
Convert.h:174:
/// TAGS: BitVec, Convert, Integer, Export
///
u64 BitVecToInteger(const BitVec *bv);
///
- In
Convert.h:189:
/// TAGS: BitVec, Convert, Integer, Allocator
///
bool bitvec_try_from_integer(BitVec *out, u64 value, u64 bits, Allocator *alloc);
#define BitVecTryFromInteger(...) OVERLOAD(BitVecTryFromInteger, __VA_ARGS__)
#define BitVecTryFromInteger_3(out, value, bits) bitvec_try_from_integer((out), (value), (bits), MisraScope)- In
Convert.h:207:
/// TAGS: BitVec, Convert, Integer, Allocator
///
BitVec bitvec_from_integer(u64 value, u64 bits, Allocator *alloc);
#define BitVecFromInteger(...) OVERLOAD(BitVecFromInteger, __VA_ARGS__)
#define BitVecFromInteger_2(value, bits) bitvec_from_integer((value), (bits), MisraScope)- In
Math.h:34:
/// TAGS: BitVec, Math, Hamming, Distance
///
u64 BitVecHammingDistance(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:54:
/// TAGS: BitVec, Math, Jaccard, Similarity
///
double BitVecJaccardSimilarity(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:74:
/// TAGS: BitVec, Math, Cosine, Similarity
///
double BitVecCosineSimilarity(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:93:
/// TAGS: BitVec, Math, DotProduct, Intersection
///
u64 BitVecDotProduct(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:115:
/// TAGS: BitVec, Math, EditDistance, Transform, Fallible
///
bool BitVecTryEditDistance(BitVec *bv1, BitVec *bv2, u64 *out);
///
- In
Math.h:139:
/// TAGS: BitVec, Math, EditDistance, Transform
///
u64 BitVecEditDistanceWithError(BitVec *bv1, BitVec *bv2, bool *error);
///
- In
Math.h:159:
/// TAGS: BitVec, Math, Correlation, Statistics
///
double BitVecCorrelation(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:178:
/// TAGS: BitVec, Math, Entropy, Information
///
double BitVecEntropy(BitVec *bv);
///
- In
Math.h:200:
/// TAGS: BitVec, Math, Alignment, Bioinformatics
///
int BitVecAlignmentScore(BitVec *bv1, BitVec *bv2, int match, int mismatch);
///
- In
Math.h:221:
/// TAGS: BitVec, Math, Alignment, Overlap
///
u64 BitVecBestAlignment(BitVec *bv1, BitVec *bv2);
///
- In
Math.h:251:
/// TAGS: BitVec, RunLength, Analysis, Pattern
///
u64 bitvec_run_lengths_raw(BitVec *bv, u64 *runs, bool *values, u64 max_runs);
bool bitvec_run_lengths_vec(BitVec *bv, BitVecRuns *out);- In
Math.h:252:
///
u64 bitvec_run_lengths_raw(BitVec *bv, u64 *runs, bool *values, u64 max_runs);
bool bitvec_run_lengths_vec(BitVec *bv, BitVecRuns *out);
#define BitVecRunLengths(...) OVERLOAD(BitVecRunLengths, __VA_ARGS__)- In
Math.h:262:
#endif
static inline u64 bitvec_edit_distance_no_error(BitVec *bv1, BitVec *bv2) {
return BitVecEditDistanceWithError(bv1, bv2, NULL);
}- In
Memory.h:37:
/// TAGS: BitVec, Memory, Shrink, Optimize
///
void BitVecShrinkToFit(BitVec *bv);
///
- In
Memory.h:59:
/// TAGS: BitVec, Memory, Swap, Efficient
///
void BitVecSwap(BitVec *bv1, BitVec *bv2);
///
- In
Memory.h:79:
/// TAGS: BitVec, Memory, Clone, Copy, Fallible
///
bool BitVecTryClone(BitVec *out, BitVec *bv);
///
- In
Memory.h:103:
/// TAGS: BitVec, Memory, Clone, Copy
///
BitVec BitVecClone(BitVec *bv);
#ifdef __cplusplus- In
Type.h:39:
Allocator *allocator;
u64 __magic; // private, must not be modified
} BitVec;
typedef Vec(BitVec) BitVecs;- In
Type.h:41:
} BitVec;
typedef Vec(BitVec) BitVecs;
///
- In
Type.h:84:
/// TAGS: BitVec, Validate, API
///
void ValidateBitVec(const BitVec *bv);
#endif // MISRA_STD_CONTAINER_BITVEC_TYPE_H
- In
Compare.h:34:
/// TAGS: BitVec, Compare, Range, Equal
///
bool BitVecEqualsRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len);
///
- In
Compare.h:53:
/// TAGS: BitVec, Compare, Range, Lexicographic
///
int BitVecCompareRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len);
///
- In
Compare.h:70:
/// TAGS: BitVec, Compare, Subset, Set
///
bool BitVecIsSubset(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:87:
/// TAGS: BitVec, Compare, Superset, Set
///
bool BitVecIsSuperset(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:103:
/// TAGS: BitVec, Compare, Disjoint, Set
///
bool BitVecDisjoint(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:119:
/// TAGS: BitVec, Compare, Overlaps, Set
///
bool BitVecOverlaps(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:136:
/// TAGS: BitVec, Equals, Compare, Test
///
bool BitVecEquals(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:153:
/// TAGS: BitVec, Compare, Lexicographic
///
int BitVecCompare(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:207:
/// TAGS: BitVec, Compare, Numerical, Integer
///
int BitVecNumericalCompare(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:223:
/// TAGS: BitVec, Compare, Weight, Population
///
int BitVecWeightCompare(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:239:
/// TAGS: BitVec, Compare, Signed, Integer
///
int BitVecSignedCompare(const BitVec *bv1, const BitVec *bv2);
///
- In
Compare.h:255:
/// TAGS: BitVec, Sorted, Order, Check
///
bool BitVecIsSorted(const BitVec *bv);
#ifdef __cplusplus
Last updated on