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
Container.h:19:
#if FEATURE_BITVEC
# include <Misra/Std/Container/BitVec.h>
#endif
#if FEATURE_LIST- In
Io.h:219:
#if FEATURE_BITVEC
# define IOFMT_BITVEC_CASE_(x, addr) \
BitVec: \
TO_TYPE_SPECIFIC_IO(BitVec, addr),
#else- In
Io.h:220:
# define IOFMT_BITVEC_CASE_(x, addr) \
BitVec: \
TO_TYPE_SPECIFIC_IO(BitVec, addr),
#else
# define IOFMT_BITVEC_CASE_(x, addr)- In
Io.h:755:
#endif
#if FEATURE_BITVEC
bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- In
Io.h:780:
#endif
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- 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
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
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
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- 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
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
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:94:
/// TAGS: BitVec, Deinit, Memory
///
void BitVecDeinit(BitVec *bv);
///
- In
Init.h:106:
/// TAGS: BitVec, Clear, Reset, Memory
///
void BitVecClear(BitVec *bv);
///
- In
Init.h:119:
/// TAGS: BitVec, Reserve, Capacity, Memory
///
bool BitVecReserve(BitVec *bv, u64 n);
///
- In
Init.h:133:
/// TAGS: BitVec, Resize, Length, Memory
///
bool BitVecResize(BitVec *bv, u64 n);
#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
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
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
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: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
Io.c:24:
#if FEATURE_BITVEC
# include <Misra/Std/Container/BitVec.h>
#endif
#if FEATURE_INT- In
Io.c:3038:
#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:3176:
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv) {
(void)fmt_info; // Unused parameter
if (!i || !bv) {- 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
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:111:
}
void BitVecDeinit(BitVec *bitvec) {
ValidateBitVec(bitvec);
if (bitvec->data) {- In
BitVec.c:119:
}
void BitVecClear(BitVec *bitvec) {
ValidateBitVec(bitvec);
bitvec->length = 0;- In
BitVec.c:127:
}
bool BitVecResize(BitVec *bitvec, u64 new_size) {
ValidateBitVec(bitvec);
if (new_size > bitvec->capacity) {- In
BitVec.c:159:
}
bool BitVecReserve(BitVec *bitvec, u64 n) {
ValidateBitVec(bitvec);
if (n <= bitvec->capacity)- In
BitVec.c:182:
}
void BitVecShrinkToFit(BitVec *bv) {
ValidateBitVec(bv);
if (bv->length == 0) {- In
BitVec.c:220:
}
void BitVecSwap(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:243:
}
bool BitVecTryClone(BitVec *out, BitVec *bv) {
ValidateBitVec(bv);
if (!out) {- In
BitVec.c:275:
}
BitVec BitVecClone(BitVec *bv) {
BitVec clone;- In
BitVec.c:276:
BitVec BitVecClone(BitVec *bv) {
BitVec clone;
ValidateBitVec(bv);- In
BitVec.c:284:
}
bool BitVecGet(const BitVec *bitvec, u64 idx) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:295:
}
void BitVecSet(BitVec *bitvec, u64 idx, bool value) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:310:
}
void BitVecFlip(BitVec *bitvec, u64 idx) {
ValidateBitVec(bitvec);
if (idx >= bitvec->length) {- In
BitVec.c:321:
}
bool BitVecPush(BitVec *bitvec, bool value) {
ValidateBitVec(bitvec);
if (bitvec->length >= bitvec->capacity) {- In
BitVec.c:337:
}
bool BitVecPop(BitVec *bitvec) {
ValidateBitVec(bitvec);
if (bitvec->length == 0) {- In
BitVec.c:347:
}
bool BitVecInsert(BitVec *bitvec, u64 idx, bool value) {
ValidateBitVec(bitvec);
if (idx > bitvec->length) {- In
BitVec.c:365:
}
bool BitVecInsertRange(BitVec *bv, u64 idx, u64 count, bool value) {
ValidateBitVec(bv);
if (idx > bv->length) {- In
BitVec.c:392:
}
bool BitVecInsertMultiple(BitVec *bv, u64 idx, BitVec *other) {
ValidateBitVec(bv);
ValidateBitVec(other);- In
BitVec.c:421:
}
bool BitVecInsertPattern(BitVec *bv, u64 idx, u8 pattern, u64 pattern_bits) {
ValidateBitVec(bv);
if (idx > bv->length) {- In
BitVec.c:451:
}
bool BitVecRemove(BitVec *bv, u64 idx) {
ValidateBitVec(bv);
if (idx >= bv->length) {- In
BitVec.c:468:
}
void BitVecRemoveRange(BitVec *bv, u64 idx, u64 count) {
ValidateBitVec(bv);
if (idx >= bv->length) {- In
BitVec.c:492:
}
bool BitVecRemoveFirst(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:504:
}
bool BitVecRemoveLast(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:516:
}
u64 BitVecRemoveAll(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:541:
}
u64 BitVecCountOnes(const BitVec *bitvec) {
ValidateBitVec(bitvec);
if (!bitvec->data)- In
BitVec.c:566:
}
u64 BitVecCountZeros(const BitVec *bitvec) {
ValidateBitVec(bitvec);
return bitvec->length - BitVecCountOnes(bitvec);- In
BitVec.c:571:
}
void BitVecAnd(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:592:
}
void BitVecOr(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:613:
}
void BitVecXor(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);- In
BitVec.c:634:
}
void BitVecNot(BitVec *result, BitVec *bitvec) {
ValidateBitVec(result);
ValidateBitVec(bitvec);- In
BitVec.c:651:
}
bool BitVecEquals(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:662:
}
bool BitVecEqualsRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:686:
// to distinct buckets.
u64 bitvec_hash(const void *data, u32 size) {
const BitVec *bv = (const BitVec *)data;
u64 hash = 1469598103934665603ULL;- In
BitVec.c:707:
i32 bitvec_compare(const void *lhs, const void *rhs) {
return (i32)BitVecCompare((const BitVec *)lhs, (const BitVec *)rhs);
}- In
BitVec.c:710:
}
int BitVecCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:732:
}
int BitVecCompareRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:757:
}
int BitVecNumericalCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:780:
}
int BitVecWeightCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:796:
}
int BitVecSignedCompare(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:825:
}
bool BitVecIsSubset(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:846:
}
bool BitVecIsSuperset(const BitVec *bv1, const BitVec *bv2) {
return BitVecIsSubset(bv2, bv1);
}- In
BitVec.c:850:
}
bool BitVecDisjoint(const BitVec *bv1, const BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:865:
}
bool BitVecOverlaps(const BitVec *bv1, const BitVec *bv2) {
return !BitVecDisjoint(bv1, bv2);
}- In
BitVec.c:869:
}
bool BitVecIsSorted(const BitVec *bv) {
ValidateBitVec(bv);- In
BitVec.c:887:
}
bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc) {
ValidateBitVec(bv);
if (!out) {- In
BitVec.c:914:
}
Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
Str result;- In
BitVec.c:924:
}
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:960:
}
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:967:
}
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:974:
}
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc) {
BitVec result;- In
BitVec.c:975:
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_str_zstr(&result, str, alloc)) {- In
BitVec.c:984:
}
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
BitVec result;- In
BitVec.c:985:
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_str_str(&result, str, alloc)) {- In
BitVec.c:994:
}
u64 BitVecToBytes(BitVec *bv, u8 *bytes, u64 max_len) {
ValidateBitVec(bv);
if (!bytes) {- In
BitVec.c:1023:
}
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:1053:
}
BitVec bitvec_from_bytes(const u8 *bytes, u64 bit_len, Allocator *alloc) {
BitVec result;- In
BitVec.c:1054:
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:1063:
}
u64 BitVecToInteger(const BitVec *bv) {
ValidateBitVec(bv);
if (bv->length == 0) {- In
BitVec.c:1081:
}
bool bitvec_try_from_integer(BitVec *out, u64 value, u64 bits, Allocator *alloc) {
if (!out) {
LOG_FATAL("out is NULL");- In
BitVec.c:1109:
}
BitVec bitvec_from_integer(u64 value, u64 bits, Allocator *alloc) {
BitVec result;- In
BitVec.c:1110:
BitVec bitvec_from_integer(u64 value, u64 bits, Allocator *alloc) {
BitVec result;
if (!bitvec_try_from_integer(&result, value, bits, alloc)) {- In
BitVec.c:1119:
}
void BitVecShiftLeft(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1142:
}
void BitVecShiftRight(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1163:
}
void BitVecRotateLeft(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1174:
}
BitVec temp = BitVecClone(bv);
if (temp.length != bv->length) {
BitVecDeinit(&temp);- In
BitVec.c:1189:
}
void BitVecRotateRight(BitVec *bv, u64 positions) {
ValidateBitVec(bv);
if (positions == 0 || bv->length == 0) {- In
BitVec.c:1200:
}
BitVec temp = BitVecClone(bv);
if (temp.length != bv->length) {
BitVecDeinit(&temp);- In
BitVec.c:1215:
}
void BitVecReverse(BitVec *bv) {
ValidateBitVec(bv);
if (bv->length <= 1) {- In
BitVec.c:1230:
}
u64 BitVecFind(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1241:
}
u64 BitVecFindLast(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1260:
}
bool BitVecAll(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1271:
}
bool BitVecAny(const BitVec *bv, bool value) {
ValidateBitVec(bv);
return BitVecFind(bv, value) != SIZE_MAX;- In
BitVec.c:1276:
}
bool BitVecNone(const BitVec *bv, bool value) {
return !BitVecAny(bv, value);
}- In
BitVec.c:1280:
}
u64 BitVecLongestRun(const BitVec *bv, bool value) {
ValidateBitVec(bv);- In
BitVec.c:1304:
}
u64 BitVecFindPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1320:
}
u64 BitVecFindLastPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1339:
}
u64 bitvec_find_all_pattern_raw(BitVec *bv, BitVec *pattern, size *results, u64 max_results) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1363:
}
bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1384:
}
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:1427:
}
bool bitvec_run_lengths_vec(BitVec *bv, BitVecRuns *out) {
ValidateBitVec(bv);
if (!out || !out->allocator) {- In
BitVec.c:1457:
}
u64 BitVecHammingDistance(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1478:
}
double BitVecJaccardSimilarity(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1505:
}
double BitVecCosineSimilarity(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1523:
}
u64 BitVecDotProduct(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1539:
}
bool BitVecTryEditDistance(BitVec *bv1, BitVec *bv2, u64 *out) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1607:
}
u64 BitVecEditDistanceWithError(BitVec *bv1, BitVec *bv2, bool *error) {
u64 result = 0;
bool ok = BitVecTryEditDistance(bv1, bv2, &result);- In
BitVec.c:1618:
}
double BitVecCorrelation(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1646:
}
double BitVecEntropy(BitVec *bv) {
ValidateBitVec(bv);- In
BitVec.c:1664:
}
int BitVecAlignmentScore(BitVec *bv1, BitVec *bv2, int match, int mismatch) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1682:
}
u64 BitVecBestAlignment(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
BitVec.c:1715:
}
bool BitVecStartsWith(BitVec *bv, BitVec *prefix) {
ValidateBitVec(bv);
ValidateBitVec(prefix);- In
BitVec.c:1726:
}
bool BitVecEndsWith(BitVec *bv, BitVec *suffix) {
ValidateBitVec(bv);
ValidateBitVec(suffix);- In
BitVec.c:1738:
}
bool BitVecContainsAt(BitVec *bv, BitVec *pattern, u64 idx) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1758:
}
u64 BitVecCountPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1776:
}
u64 BitVecRFindPattern(BitVec *bv, BitVec *pattern, u64 start) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1796:
}
bool BitVecReplace(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
ValidateBitVec(bv);
ValidateBitVec(old_pattern);- In
BitVec.c:1817:
}
u64 BitVecReplaceAll(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
ValidateBitVec(bv);
ValidateBitVec(old_pattern);- In
BitVec.c:1857:
}
bool BitVecMatches(BitVec *bv, BitVec *pattern, BitVec *wildcard) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1878:
}
u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors) {
ValidateBitVec(bv);
ValidateBitVec(pattern);- In
BitVec.c:1904:
}
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
BitVec.c:1925:
}
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
BitVec.c:1942:
}
u64 BitVecPrefixMatch(BitVec *bv, BitVecs *patterns) {
ValidateBitVec(bv);
if (!patterns) {- In
BitVec.c:1957:
}
u64 BitVecSuffixMatch(BitVec *bv, BitVecs *patterns) {
ValidateBitVec(bv);
if (!patterns) {- In
BitVec.c:1974:
// 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:1991:
}
void ValidateBitVec(const BitVec *bv) {
if (!bv) {
LOG_FATAL("Invalid bitvec object: NULL.");- In
BitVec.c:2002:
}
validate_bitvec_structural(bv);
((BitVec *)(void *)bv)->__magic &= ~MAGIC_VALIDATED_BIT;
}- In
Memory.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Memory.c:41:
WriteFmt("Testing BitVecShrinkToFit\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
- In
Memory.c:81:
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
- In
Memory.c:120:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecReserve(&bv, 64);- In
Memory.c:136:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecReserve(&bv, 64);- In
Memory.c:152:
WriteFmt("Testing BitVecSwap\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Memory.c:153:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector
- In
Memory.c:200:
WriteFmt("Testing BitVecClone\n");
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up original bitvector
- In
Memory.c:209:
// Clone the bitvector
BitVec clone = BitVecClone(&original);
// Check that clone has same content as original
- In
Memory.c:254:
alloc.base.retry_limit = 9;
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&original, true);- In
Memory.c:260:
BitVecPush(&original, true);
BitVec clone = BitVecClone(&original);
// Clone should share the same Allocator* and therefore see identical
- In
Memory.c:285:
WriteFmt("Testing BitVecShrinkToFit edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Memory.c:319:
WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Memory.c:354:
WriteFmt("Testing BitVecSwap edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Memory.c:355:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Memory.c:398:
WriteFmt("Testing BitVecClone edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Memory.c:402:
// Test clone empty bitvec
BitVec clone1 = BitVecClone(&bv);
result = result && (BitVecLen(&clone1) == 0);
BitVecDeinit(&clone1);- In
Memory.c:408:
// Test clone single element
BitVecPush(&bv, true);
BitVec clone2 = BitVecClone(&bv);
result = result && (BitVecLen(&clone2) == 1);
result = result && (BitVecGet(&clone2, 0) == true);- In
Memory.c:419:
}
BitVec clone3 = BitVecClone(&bv);
result = result && (BitVecLen(&clone3) == 1000);- In
Memory.c:440:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec memory stress test\n");
bool result = true;- In
Memory.c:445:
for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Memory.c:446:
for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Add random-sized data
- In
Memory.c:455:
// Clone and swap
BitVec clone = BitVecClone(&bv1);
BitVecSwap(&bv1, &bv2);- In
Memory.c:479:
// Deadend tests
bool test_bitvec_memory_null_failures(void) {
WriteFmt("Testing BitVec memory NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
- In
Memory.c:490:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec swap NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Memory.c:492:
WriteFmt("Testing BitVec swap NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
- In
Memory.c:503:
bool test_bitvec_clone_null_failures(void) {
WriteFmt("Testing BitVec clone NULL handling\n");
// Test NULL pointer - should abort
- In
Memory.c:525:
WriteFmt("Testing resize-grow clears stale tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Fill a full byte with ones so bits 5,6,7 are set in the backing byte.
- In
Memory.c:560:
WriteFmt("Testing BitVecReserve with zero capacity returns true\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = (BitVecReserve(&bv, 0) == true);- In
Memory.c:603:
WriteFmt("Testing BitVecShrinkToFit preserves bits on a large vector\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 400 bits => doubling growth yields capacity 512, byte_size 64,
- In
Memory.c:635:
WriteFmt("Testing BitVecShrinkToFit keeps the vector structurally valid\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 400; i++) {- In
Memory.c:663:
WriteFmt("Testing BitVecSwap keeps a swapped-in large vector valid\n");
BitVec small = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large = BitVecInit(ALLOCATOR_OF(&alloc));- In
Memory.c:664:
BitVec small = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&small, true);- In
Memory.c:698:
WriteFmt("Testing BitVecSwap aborts on an invalid second argument\n");
BitVec good = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&good, true);- In
Memory.c:701:
BitVecPush(&good, true);
BitVec bad = {0}; // magic 0 => invalid bitvec
// Should abort inside ValidateBitVec(bv2).
- In
Memory.c:718:
WriteFmt("Testing BitVecTryClone aborts on an invalid source\n");
BitVec out = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; // magic 0 => invalid bitvec
- In
Memory.c:719:
BitVec out = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; // magic 0 => invalid bitvec
// Should abort inside ValidateBitVec(bv).
- In
Memory.c:729:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Memory tests\n\n");
// Array of normal test functions
- In
Memory.c:767:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Memory");
}- In
Init.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Init.c:29:
// Test basic initialization
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
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
Init.c:83:
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Reserve space for 50 bits
- In
Init.c:120:
WriteFmt("Testing BitVecClear\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
- In
Init.c:159:
WriteFmt("Testing BitVecResize\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some initial data
- In
Init.c:205:
// Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Init.c:206:
// Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Init.c:207:
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);- In
Init.c:227:
WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Init.c:258:
WriteFmt("Testing BitVecReu64 edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Init.c:297:
WriteFmt("Testing BitVecClear edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Init.c:329:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec multiple init/deinit cycles\n");
bool result = true;- In
Init.c:335:
// Test multiple init/deinit cycles
for (int cycle = 0; cycle < 100; cycle++) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
- In
Init.c:353:
// 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
- In
Init.c:368:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec invalid operations\n");
// BitVecReserve is now a fallible API that returns bool on allocation
- In
Init.c:373:
// 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);- In
Init.c:386:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set operations on invalid indices\n");
// BitVecResize is now a fallible API that returns bool on allocation
- In
Init.c:391:
// 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);- In
Init.c:403:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Init tests\n\n");
// Array of normal test functions
- In
Init.c:430:
// 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>
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");
}- In
Compare.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Allocator/Default.h>- In
Compare.c:54:
WriteFmt("Testing BitVecEquals\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:55:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:56:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal empty bitvectors
- In
Compare.c:101:
WriteFmt("Testing BitVecCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:102:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal bitvectors
- In
Compare.c:141:
WriteFmt("Testing BitVecLexCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:142:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
- In
Compare.c:179:
WriteFmt("Testing BitVecNumericalCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:180:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvectors representing different numbers
- In
Compare.c:219:
WriteFmt("Testing BitVecWeightCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:220:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1: 111 (3 ones)
- In
Compare.c:259:
WriteFmt("Testing BitVecIsSubset\n");
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:260:
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
- In
Compare.c:306:
WriteFmt("Testing BitVecSignedCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:307:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test positive vs negative (MSB is sign bit)
- In
Compare.c:334:
// Test equal signed values
BitVec bv3 = BitVecClone(&bv1);
result = result && (BitVecSignedCompare(&bv1, &bv3) == 0);- In
Compare.c:353:
WriteFmt("Testing BitVecIsSuperset\n");
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:354:
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
- In
Compare.c:400:
WriteFmt("Testing BitVecOverlaps\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:401:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create overlapping bitvectors
- In
Compare.c:445:
WriteFmt("Testing BitVecDisjoint and BitVecIntersects\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:446:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create disjoint bitvectors
- In
Compare.c:493:
WriteFmt("Testing BitVecEqualsRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:494:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
- In
Compare.c:539:
WriteFmt("Testing BitVecCompareRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:540:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
- In
Compare.c:590:
WriteFmt("Testing BitVecIsLexicographicallyLess and BitVecIsNumericallyLess\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:591:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
- In
Compare.c:610:
// Test equal cases
BitVec bv3 = BitVecClone(&bv1);
result = result && !(BitVecCompare(&bv1, &bv3) < 0);
result = result && !(BitVecNumericalCompare(&bv1, &bv3) < 0);- In
Compare.c:634:
WriteFmt("Testing BitVecIsSorted\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test empty bitvector (should be sorted)
- In
Compare.c:680:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec compare edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:682:
WriteFmt("Testing BitVec compare edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:683:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:719:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec set operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:721:
WriteFmt("Testing BitVec set operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:722:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:754:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive comparison operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:756:
WriteFmt("Testing BitVec comprehensive comparison operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:757:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:787:
// 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++) {- In
Compare.c:798:
// Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:799:
// Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create actual subset/superset relationship
- In
Compare.c:829:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec large-scale comparison operations\n");
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:831:
WriteFmt("Testing BitVec large-scale comparison operations\n");
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:832:
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Compare.c:859:
// Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:860:
// Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));
// Positive number (MSB = 0): 01111111
- In
Compare.c:896:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec compare NULL pointer handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:898:
WriteFmt("Testing BitVec compare NULL pointer handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
- In
Compare.c:909:
bool test_bitvec_subset_null_failures(void) {
WriteFmt("Testing BitVec subset NULL handling\n");
// Test NULL pointer - should abort
- In
Compare.c:920:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec range operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:922:
WriteFmt("Testing BitVec range operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer in range operations - should abort
- In
Compare.c:935:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec range operations bounds checking\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:937:
WriteFmt("Testing BitVec range operations bounds checking\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:938:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create small bitvectors
- In
Compare.c:956:
bool test_bitvec_sorted_null_failures(void) {
WriteFmt("Testing BitVec sorted operations NULL handling\n");
// Test NULL pointer - should abort
- In
Compare.c:971:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
for (int i = 0; i < 11; i++) {- In
Compare.c:972:
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
for (int i = 0; i < 11; i++) {
BitVecPush(&a, (i % 2) == 0);- In
Compare.c:978:
}
BitVec empty1 = BitVecInit(base);
BitVec empty2 = BitVecInit(base);- In
Compare.c:979:
BitVec empty1 = BitVecInit(base);
BitVec empty2 = BitVecInit(base);
bool result = (bitvec_hash(&a, 0) == bitvec_hash(&b, 0));- In
Compare.c:1000:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base);- In
Compare.c:1001:
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base);- In
Compare.c:1002:
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
BitVec c = BitVecInit(base);
BitVecPush(&a, true);- In
Compare.c:1032:
// 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();- In
Compare.c:1037:
Allocator *base = ALLOCATOR_OF(&alloc);
Map(BitVec, u64) counts = MapInit(bitvec_hash, bitvec_compare, &alloc);
BitVec k1 = BitVecInit(base);- In
Compare.c:1039:
Map(BitVec, u64) counts = MapInit(bitvec_hash, bitvec_compare, &alloc);
BitVec k1 = BitVecInit(base);
BitVecPush(&k1, true);
BitVecPush(&k1, false);- In
Compare.c:1044:
BitVecPush(&k1, true);
BitVec k2 = BitVecInit(base);
BitVecPush(&k2, false);
BitVecPush(&k2, true);- In
Compare.c:1051:
MapInsertR(&counts, k2, 2u);
BitVec probe = BitVecInit(base);
BitVecPush(&probe, true);
BitVecPush(&probe, false);- In
Compare.c:1058:
u64 *got = MapGetFirstPtr(&counts, probe);
BitVec missing = BitVecInit(base);
BitVecPush(&missing, true);
BitVecPush(&missing, true);- In
Compare.c:1084:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVecPush(&a, false);
BitVecPush(&a, true);- In
Compare.c:1088:
BitVecPush(&a, true);
BitVec b = BitVecInit(base);
BitVecPush(&b, false);
BitVecPush(&b, true);- In
Compare.c:1092:
BitVecPush(&b, true);
BitVec c = BitVecInit(base);
BitVecPush(&c, true);
BitVecPush(&c, false);- In
Compare.c:1120:
WriteFmt("Testing BitVecEquals rejects bad second operand\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};- In
Compare.c:1121:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecPush(&bv1, true);- In
Compare.c:1140:
WriteFmt("Testing BitVecEqualsRange rejects bad second operand\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};- In
Compare.c:1141:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecEqualsRange(&bv1, 0, &bad, 0, 0);- In
Compare.c:1158:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // byte 0x00
BitVec b = BitVecInit(base); // byte 0x01
- In
Compare.c:1159:
BitVec a = BitVecInit(base); // byte 0x00
BitVec b = BitVecInit(base); // byte 0x01
// a: 8 zero bits -> byte 0x00.
- In
Compare.c:1186:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // 10101010
BitVec b = BitVecInit(base); // 01010101
- In
Compare.c:1187:
BitVec a = BitVecInit(base); // 10101010
BitVec b = BitVecInit(base); // 01010101
for (int i = 0; i < 8; i++) {- In
Compare.c:1211:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // byte0 = 0xFF, byte1 = 0x00
BitVec b = BitVecInit(base); // byte0 = 0xFF, byte1 = 0xFF
- In
Compare.c:1212:
BitVec a = BitVecInit(base); // byte0 = 0xFF, byte1 = 0x00
BitVec b = BitVecInit(base); // byte0 = 0xFF, byte1 = 0xFF
// a: first 8 bits set, next 8 clear.
- In
Compare.c:1243:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1258:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1273:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1288:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1304:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1323:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);- In
Compare.c:1324:
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);
for (u64 i = 0; i < 50; i++) {- In
Compare.c:1348:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base);
BitVec empty = BitVecInit(base);- In
Compare.c:1349:
BitVec neg = BitVecInit(base);
BitVec empty = BitVecInit(base);
BitVecPush(&neg, true); // single bit set -> MSB set -> negative
- In
Compare.c:1368:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec empty = BitVecInit(base);
BitVec neg = BitVecInit(base);- In
Compare.c:1369:
BitVec empty = BitVecInit(base);
BitVec neg = BitVecInit(base);
BitVecPush(&neg, true); // negative
- In
Compare.c:1388:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base);
BitVec pos = BitVecInit(base);- In
Compare.c:1389:
BitVec neg = BitVecInit(base);
BitVec pos = BitVecInit(base);
BitVecPush(&neg, true); // length 1, MSB set -> negative
- In
Compare.c:1411:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec empty = BitVecInit(base);
BitVec neg = BitVecInit(base);- In
Compare.c:1412:
BitVec empty = BitVecInit(base);
BitVec neg = BitVecInit(base);
BitVecPush(&neg, true); // negative
- In
Compare.c:1432:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base);
BitVec empty = BitVecInit(base);- In
Compare.c:1433:
BitVec neg = BitVecInit(base);
BitVec empty = BitVecInit(base);
BitVecPush(&neg, true); // negative
- In
Compare.c:1452:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);- In
Compare.c:1453:
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
// [1,1]: MSB (index 1) set -> both negative, identical magnitude.
- In
Compare.c:1477:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);- In
Compare.c:1478:
BitVec a = BitVecInit(base);
BitVec b = BitVecInit(base);
// a = [1,1]: index1 (MSB) set -> negative, magnitude 3.
- In
Compare.c:1503:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1519:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1535:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1551:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
BitVecPush(&bv, true);- In
Compare.c:1571:
WriteFmt("Testing BitVecIsSubset scans past index 42\n");
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);- In
Compare.c:1572:
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);
for (u64 i = 0; i < 50; i++) {- In
Compare.c:1598:
WriteFmt("Testing BitVecIsSubset with shorter bv1 stays in bounds\n");
BitVec bv1 = BitVecInit(base); // length 2
BitVec bv2 = BitVecInit(base); // length 5
- In
Compare.c:1599:
BitVec bv1 = BitVecInit(base); // length 2
BitVec bv2 = BitVecInit(base); // length 5
BitVecPush(&bv1, true);- In
Compare.c:1629:
WriteFmt("Testing BitVecIsSubset with shorter bv2 stays in bounds\n");
BitVec bv1 = BitVecInit(base); // length 5
BitVec bv2 = BitVecInit(base); // length 2
- In
Compare.c:1630:
BitVec bv1 = BitVecInit(base); // length 5
BitVec bv2 = BitVecInit(base); // length 2
BitVecPush(&bv1, true);- In
Compare.c:1660:
WriteFmt("Testing BitVecDisjoint scans beyond position 0\n");
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);- In
Compare.c:1661:
BitVec bv1 = BitVecInit(base);
BitVec bv2 = BitVecInit(base);
// Both: 0 1 1 -- no shared 1 at position 0, shared 1s at 1 and 2.
- In
Compare.c:1689:
WriteFmt("Testing BitVecIsSubset rejects NULL bv2\n");
BitVec bv1 = BitVecInit(base);
BitVecPush(&bv1, true);- In
Compare.c:1708:
WriteFmt("Testing BitVecDisjoint rejects NULL bv1\n");
BitVec bv2 = BitVecInit(base);
BitVecPush(&bv2, true);- In
Compare.c:1727:
WriteFmt("Testing BitVecDisjoint rejects NULL bv2\n");
BitVec bv1 = BitVecInit(base);
BitVecPush(&bv1, true);- In
Compare.c:1748:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 256; i++) {- In
Compare.c:1749:
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 256; i++) {
BitVecPush(&a, false);- In
Compare.c:1792:
int main(void) {
WriteFmt("[INFO] Starting BitVec.Compare tests\n\n");
// Array of normal test functions
- In
Compare.c:1864:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Compare");
}- In
Insert.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Insert.c:33:
WriteFmt("Testing BitVecPush\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
- In
Insert.c:66:
WriteFmt("Testing BitVecInsert (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Insert at index 0 (empty bitvector)
- In
Insert.c:105:
WriteFmt("Testing BitVecInsertRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create target bitvector
- In
Insert.c:136:
WriteFmt("Testing BitVecInsertMultiple\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));- In
Insert.c:137:
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
- In
Insert.c:174:
WriteFmt("Testing BitVecInsertPattern\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
- In
Insert.c:195:
// Test with different pattern - 0x05 (0101 in binary) using only 3 bits
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);- In
Insert.c:223:
WriteFmt("Testing BitVecInsertRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Insert.c:254:
WriteFmt("Testing BitVecInsertMultiple edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));- In
Insert.c:255:
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Insert.c:256:
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Insert.c:290:
WriteFmt("Testing BitVecInsertPattern edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Insert.c:315:
// Deadend tests
bool test_bitvec_insert_null_failures(void) {
WriteFmt("Testing BitVec insert NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
- In
Insert.c:326:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec insert invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Insert.c:328:
WriteFmt("Testing BitVec insert invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test inserting beyond capacity limit - should abort
- In
Insert.c:339:
bool test_bitvec_insert_pattern_null_failures(void) {
WriteFmt("Testing BitVec insert pattern NULL handling\n");
// Test NULL bitvec - should abort
- In
Insert.c:355:
WriteFmt("Testing BitVecInsertRange shifts existing tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Original: [1, 0, 1, 1]
- In
Insert.c:386:
WriteFmt("Testing BitVecInsertMultiple shifts existing tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));- In
Insert.c:387:
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));
// bv: [1, 0, 1]
- In
Insert.c:431:
WriteFmt("Testing BitVecInsertMultiple NULL bv validation\n");
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&other, true);- In
Insert.c:448:
WriteFmt("Testing BitVecInsertMultiple NULL other validation\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);- In
Insert.c:461:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Insert tests\n\n");
// Array of normal test functions
- In
Insert.c:491:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Insert");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Default.h>
// Helper: append the bits of a 0/1 ASCII string to a BitVec.
static void push_bits(BitVec *bv, const char *bits) {
for (const char *c = bits; *c != '\0'; c++)
BitVecPush(bv, *c == '1'); 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); WriteFmt("Testing BitVecFindAllPattern (vec) with NULL bitvector\n");
BitVec pattern = BitVecInit(base);
BitVecPush(&pattern, true); WriteFmt("Testing BitVecFindAllPattern (vec) with NULL pattern\n");
BitVec source = BitVecInit(base);
BitVecPush(&source, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true); WriteFmt("Testing BitVecReplace(src, old, NULL) with old absent - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "0000");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "0000");
push_bits(&old_pattern, "111"); // not present in source
WriteFmt("Testing BitVecReplaceAll(uninitialized, old, new) - should fatal\n");
BitVec bad = {0}; // magic mismatch -> ValidateBitVec aborts
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; // magic mismatch -> ValidateBitVec aborts
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1"); BitVec bad = {0}; // magic mismatch -> ValidateBitVec aborts
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1");
push_bits(&new_pattern, "0"); WriteFmt("Testing BitVecReplaceAll(empty, NULL, new) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&new_pattern, "0");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&new_pattern, "0"); WriteFmt("Testing BitVecReplaceAll(empty, old, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1"); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec wildcard = BitVecInit(base);
BitVecPush(&source, true);
BitVec source = BitVecInit(base);
BitVec wildcard = BitVecInit(base);
BitVecPush(&source, true);
BitVecPush(&wildcard, false); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVecPush(&source, true);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVecPush(&source, true);
BitVecPush(&pattern, true); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec pattern = BitVecInit(base);
BitVecPush(&pattern, true); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVecPush(&source, true); // 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");
} #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");
} #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");
}- In
Type.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>- In
Type.c:18:
// Test basic BitVec type functionality
bool test_bitvec_type_basic(void) {
WriteFmt("Testing basic BitVec type functionality\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Type.c:23:
// Create a bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
Type.c:44:
// Create a valid bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// This should not abort
- In
Type.c:71:
WriteFmt("Testing ValidateBitVec honours the validated-bit memoization (1943:23)\n");
BitVec bv = {0};
// Structurally inconsistent: capacity claims 400 bits but byte_size 1
// only backs 8 bits. length 0 + data NULL keeps the earlier structural
- In
Type.c:101:
WriteFmt("Testing validate_bitvec_structural catches an undersized byte_size (1926:22)\n");
BitVec bv = {0};
bv.length = 0;
bv.capacity = 400;- In
Type.c:118:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Type tests\n\n");
// Array of test functions
- In
Type.c:130:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Type");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.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; WriteFmt("Testing BitVecOr widens past shorter operand a\n");
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// a = 10 (len 2)
WriteFmt("Testing BitVecXor widens past shorter operand a\n");
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// a = 10 (len 2)
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 8; i++) {
BitVecPush(&bv, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); // bit 0
BitVecPush(&bv, true); // bit 1
bool test_blind_rotate_right_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool pat[5] = {true, false, false, true, true}; Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg);
// 1011 -- length > 1 and positions % length != 0 so the rotate body
Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg);
// length > 1 and positions % length != 0 so the rotate body
// 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> // 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
WriteFmt("Testing BitVecAnd rejects bad third operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecAnd(&result, &a, &bad); WriteFmt("Testing BitVecAnd rejects bad second operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecAnd(&result, &bad, &b); WriteFmt("Testing BitVecOr rejects bad second operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecOr(&result, &bad, &b); WriteFmt("Testing BitVecXor rejects bad third operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecXor(&result, &a, &bad); // function-level ValidateBitVec; a NULL handle must abort.
static bool test_rotate_right_null_aborts(void) {
BitVecRotateRight((BitVec *)NULL, 1);
return false;
} // 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/Container/Str.h>
#include <Misra/Std/Allocator/Debug.h>
// Helper: append the bits of a 0/1 ASCII string to a BitVec.
static void push_bits(BitVec *bv, const char *bits) {
for (const char *c = bits; *c != '\0'; c++)
BitVecPush(bv, *c == '1'); 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)); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true;
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true; Allocator *base = ALLOCATOR_OF(&alloc);
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();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&suffix, "101"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&pattern, "101"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&pattern, "101"); WriteFmt("Testing BitVecRFindPattern window-condition (ge_to_lt)\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 window-condition (add_to_sub)\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 window-value (add_to_sub)\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 loop-seed (add_to_sub)\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 loop-guard (gt_to_ge)\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 BitVecReplaceAll found-flag init\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 forward-scan direction\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; Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
bool result = true; BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
bool result = true; Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
bool result = true; BitVec source = BitVecInit(base);
BitVec old = BitVecInit(base);
BitVec neww = BitVecInit(base);
bool result = true; Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVec wildcard = BitVecInit(base);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVec wildcard = BitVecInit(base);
bool result = true; BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVec wildcard = BitVecInit(base);
bool result = true; // Sanity: an all-wildcard mask must still match (proves we did not just
// wire the function to always return false).
BitVec wild_all = BitVecInit(base);
for (int i = 0; i < 4; i++)
BitVecPush(&wild_all, true); Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true;
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true; Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true;
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
bool result = true; Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
BitVec source = BitVecInit(base);
BitVec pattern = BitVecInit(base);
// source: 4096 zero bits; pattern: a single 1. No window ever matches with
WriteFmt("Testing bitvec_regex_match_str returns false on non-match\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg);
// 101010 so the render is a non-empty Str that must be freed.
Allocator *pbase = ALLOCATOR_OF(&palloc);
BitVec bv = BitVecInit(adbg);
BitVecPush(&bv, true);
BitVecPush(&bv, false);
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
Math.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Math.c:70:
// Helper: push a 0/1 character string of bits into bv.
static void push_bits(BitVec *bv, const char *bits) {
for (const char *p = bits; *p != '\0'; p++)
BitVecPush(bv, *p == '1');- In
Math.c:81:
WriteFmt("Testing BitVecHammingDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:82:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:126:
WriteFmt("Testing BitVecHammingDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:127:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:159:
WriteFmt("Testing BitVecJaccardSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:160:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:211:
WriteFmt("Testing BitVecJaccardSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:212:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:240:
WriteFmt("Testing BitVecCosineSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:241:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:278:
WriteFmt("Testing BitVecCosineSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:279:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:311:
WriteFmt("Testing BitVecDotProduct basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:312:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:351:
WriteFmt("Testing BitVecDotProduct edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:352:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:381:
WriteFmt("Testing BitVecEditDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:382:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:428:
WriteFmt("Testing BitVecEditDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:429:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:459:
WriteFmt("Testing BitVecCorrelation basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:460:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:498:
WriteFmt("Testing BitVecCorrelation edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:499:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:529:
WriteFmt("Testing BitVecEntropy basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:561:
WriteFmt("Testing BitVecEntropy edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:584:
WriteFmt("Testing BitVecAlignmentScore basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:585:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:620:
WriteFmt("Testing BitVecAlignmentScore edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:621:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:650:
WriteFmt("Testing BitVecBestAlignment basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:651:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:683:
WriteFmt("Testing BitVecBestAlignment edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:684:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:709:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec Math stress tests\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:711:
WriteFmt("Testing BitVec Math stress tests\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:712:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:732:
// 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++) {- In
Math.c:733:
// 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);- In
Math.c:768:
WriteFmt("Testing BitVecHammingDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecHammingDistance(NULL, &bv2);- In
Math.c:780:
WriteFmt("Testing BitVecHammingDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecHammingDistance(&bv1, NULL);- In
Math.c:792:
WriteFmt("Testing BitVecJaccardSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecJaccardSimilarity(NULL, &bv2);- In
Math.c:804:
WriteFmt("Testing BitVecJaccardSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecJaccardSimilarity(&bv1, NULL);- In
Math.c:816:
WriteFmt("Testing BitVecCosineSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCosineSimilarity(NULL, &bv2);- In
Math.c:828:
WriteFmt("Testing BitVecCosineSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCosineSimilarity(&bv1, NULL);- In
Math.c:840:
WriteFmt("Testing BitVecDotProduct(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecDotProduct(NULL, &bv2);- In
Math.c:852:
WriteFmt("Testing BitVecDotProduct(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecDotProduct(&bv1, NULL);- In
Math.c:864:
WriteFmt("Testing BitVecEditDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecEditDistance(NULL, &bv2);- In
Math.c:876:
WriteFmt("Testing BitVecEditDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecEditDistance(&bv1, NULL);- In
Math.c:888:
WriteFmt("Testing BitVecCorrelation(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCorrelation(NULL, &bv2);- In
Math.c:900:
WriteFmt("Testing BitVecCorrelation(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCorrelation(&bv1, NULL);- In
Math.c:918:
WriteFmt("Testing BitVecAlignmentScore(NULL, bv2, 1, -1) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecAlignmentScore(NULL, &bv2, 1, -1);- In
Math.c:930:
WriteFmt("Testing BitVecAlignmentScore(bv1, NULL, 1, -1) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecAlignmentScore(&bv1, NULL, 1, -1);- In
Math.c:942:
WriteFmt("Testing BitVecBestAlignment(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecBestAlignment(NULL, &bv2);- In
Math.c:954:
WriteFmt("Testing BitVecBestAlignment(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecBestAlignment(&bv1, NULL);- In
Math.c:972:
WriteFmt("Testing BitVecJaccardSimilarity guard only fires when both empty\n");
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec one = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&one, true);- In
Math.c:973:
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec one = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&one, true);- In
Math.c:1001:
WriteFmt("Testing BitVecJaccardSimilarity with bv1 shorter than bv2\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1002:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {1}, bv2 = {1, 0}. Intersection 1 (pos 0), union 1 -> 1.0.
- In
Math.c:1027:
WriteFmt("Testing BitVecJaccardSimilarity with bv2 shorter than bv1\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1028:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {1, 0}, bv2 = {1}. Intersection 1 (pos 0), union 1 -> 1.0.
- In
Math.c:1054:
WriteFmt("Testing BitVecJaccardSimilarity reads bv2 bits in valid region\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1055:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {0, 0}, bv2 = {1, 1}. Intersection 0, union 2 -> 0.0.
- In
Math.c:1081:
WriteFmt("Testing BitVecEditDistance column-0 base case\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1082:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, false);- In
Math.c:1106:
WriteFmt("Testing BitVecEditDistance deletion term\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1107:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, false);- In
Math.c:1140:
// exact size the empty->5 distance will recycle, guaranteeing the stale
// (large) values land in prev_row[len2].
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {- In
Math.c:1141:
// (large) values land in prev_row[len2].
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {
BitVecPush(&warm_a, (i % 2) == 0);- In
Math.c:1150:
BitVecDeinit(&warm_b);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {- In
Math.c:1151:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {
BitVecPush(&bv2, true);- In
Math.c:1178:
// the empty->4 distance recycles, so the unfilled prev_row[len2] holds a
// stale large value rather than a coincidental 4.
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {- In
Math.c:1179:
// stale large value rather than a coincidental 4.
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {
BitVecPush(&warm_a, (i % 2) == 1);- In
Math.c:1188:
BitVecDeinit(&warm_b);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {- In
Math.c:1189:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {
BitVecPush(&bv2, false);- In
Math.c:1214:
WriteFmt("Testing BitVecEditDistance insertion term\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1215:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);- In
Math.c:1241:
WriteFmt("Testing BitVecJaccardSimilarity rejects bad second operand\n");
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};- In
Math.c:1242:
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVecJaccardSimilarity(&empty, &bad);- In
Math.c:1261:
WriteFmt("Testing BitVecCorrelation with bv1 shorter than bv2 (no OOB)\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1262:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1291:
WriteFmt("Testing BitVecCorrelation with bv2 shorter than bv1 (no OOB)\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1292:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1323:
WriteFmt("Testing BitVecEntropy on an unbalanced (3 ones, 1 zero) vector\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1357:
WriteFmt("Testing BitVecBestAlignment all-mismatch best offset == 3\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1358:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1388:
WriteFmt("Testing BitVecCosineSimilarity of identical vectors == 1.0\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1389:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1417:
WriteFmt("Testing BitVecEntropy of a 3:1 distribution\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Math.c:1444:
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base);
bool result = true;- In
Math.c:1473:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1011");- In
Math.c:1474:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1011");
push_bits(&bv2, "11");- In
Math.c:1494:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "11");- In
Math.c:1495:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "11");
push_bits(&bv2, "000");- In
Math.c:1513:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1010");- In
Math.c:1514:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1010");
push_bits(&bv2, "10");- In
Math.c:1534:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");- In
Math.c:1535:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
push_bits(&bv2, "11");- In
Math.c:1554:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");- In
Math.c:1555:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
push_bits(&bv2, "11");- In
Math.c:1568:
int main(void) {
WriteFmt("[INFO] Starting BitVec.Math tests\n\n");
// Array of normal test functions
- In
Math.c:1640:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Math");
}- In
Remove.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Remove.c:39:
WriteFmt("Testing BitVecPop\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
- In
Remove.c:77:
WriteFmt("Testing BitVecRemove (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
- In
Remove.c:117:
WriteFmt("Testing BitVecRemoveRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, true, false, true
- In
Remove.c:150:
WriteFmt("Testing BitVecRemoveFirst\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
- In
Remove.c:191:
WriteFmt("Testing BitVecRemoveLast\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
- In
Remove.c:233:
WriteFmt("Testing BitVecRemoveAll\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true, false
- In
Remove.c:274:
WriteFmt("Testing BitVecPop edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Remove.c:302:
WriteFmt("Testing BitVecRemove edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Remove.c:330:
WriteFmt("Testing BitVecRemoveRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Remove.c:363:
WriteFmt("Testing BitVecRemoveFirst/Last edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Remove.c:402:
WriteFmt("Testing BitVecRemoveAll edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Remove.c:437:
// Deadend tests
bool test_bitvec_remove_null_failures(void) {
WriteFmt("Testing BitVec remove NULL pointer handling\n");
// Test NULL bitvec pointer - should abort
- In
Remove.c:446:
bool test_bitvec_remove_range_null_failures(void) {
WriteFmt("Testing BitVec remove range NULL handling\n");
// Test NULL bitvec pointer - should abort
- In
Remove.c:457:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:459:
WriteFmt("Testing BitVec remove invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test removing beyond capacity limit - should abort
- In
Remove.c:472:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec pop bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:474:
WriteFmt("Testing BitVec pop bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test pop from empty bitvec - should abort
- In
Remove.c:487:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:489:
WriteFmt("Testing BitVec remove bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove from empty bitvec - should abort
- In
Remove.c:502:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec remove range bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:504:
WriteFmt("Testing BitVec remove range bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove range from empty bitvec - should abort
- In
Remove.c:522:
WriteFmt("Testing BitVecRemoveRange clamps oversized count\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Length 10, all true.
- In
Remove.c:554:
WriteFmt("Testing BitVecRemoveRange clamp gap count\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Length 10, all true.
- In
Remove.c:581:
WriteFmt("Testing BitVecRemoveRange shifts tail down\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Pattern: indices 0..9 = [1,0,1,0,0,1,0,1,1,0]
- In
Remove.c:624:
WriteFmt("Testing BitVecRemove rejects idx == length\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false);- In
Remove.c:652:
// validator would let the NULL deref slip silently.
bool test_clear_null_aborts(void) {
BitVecClear((BitVec *)NULL);
return false;
}- In
Remove.c:664:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting BitVec.Remove tests\n\n");
// Array of normal test functions
- In
Remove.c:703:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "BitVec.Remove");
}- In
Convert.c:1:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Convert.c:43:
WriteFmt("Testing BitVecToStr\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011
- In
Convert.c:79:
// Convert from string
Zstr str = "1011";
BitVec bv;
bool ok = BitVecTryFromStr(&bv, str, ALLOCATOR_OF(&alloc));- In
Convert.c:90:
// Test with empty string
BitVec empty_bv = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&empty_bv) == 0);- In
Convert.c:108:
WriteFmt("Testing BitVecToBytes\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 10110011 (0xB3)
- In
Convert.c:145:
// 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
- In
Convert.c:181:
WriteFmt("Testing BitVecToInteger\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011 (decimal 11 if MSB first, 13 if LSB first)
- In
Convert.c:198:
// Test with larger pattern
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 8; i++) {
BitVecPush(&bv2, (i % 2 == 0)); // Alternating pattern
- In
Convert.c:223:
// Convert from integer
u64 value = 11; // 1011 in binary
BitVec bv;
bool ok = BitVecTryFromInteger(&bv, value, 4, ALLOCATOR_OF(&alloc));- In
Convert.c:245:
// Test with zero
BitVec zero_bv;
result = result && BitVecTryFromInteger(&zero_bv, 0, 8, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&zero_bv) == 8);- In
Convert.c:268:
bool test_bitvec_try_conversion_allocators(void) {
WriteFmt("Testing BitVec try conversion allocator behavior\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:277:
alloc.base.retry_limit = 3;
BitVec bv;
Str str;
bool ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));- In
Convert.c:303:
u8 dummy_bytes[1] = {0xFF};
BitVec empty_bv = BitVecFromBytes(dummy_bytes, 0, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&empty_bv) == 0);
BitVecDeinit(&empty_bv);- In
Convert.c:316:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec convert edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Convert.c:318:
WriteFmt("Testing BitVec convert edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Convert.c:355:
// Test empty string
BitVec bv1 = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv1) == 0);
BitVecDeinit(&bv1);- In
Convert.c:360:
// Test single character
BitVec bv2 = BitVecFromStr("1", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv2) == 1);
result = result && (BitVecGet(&bv2, 0) == true);- In
Convert.c:372:
long_str[1000] = '\0';
BitVec bv3 = BitVecFromStr(long_str, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv3) == 1000);
result = result && (BitVecGet(&bv3, 0) == true);- In
Convert.c:386:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Convert.c:388:
WriteFmt("Testing BitVec bytes conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Convert.c:398:
// 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);- In
Convert.c:404:
// 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);- In
Convert.c:416:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec integer conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Convert.c:418:
WriteFmt("Testing BitVec integer conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
Convert.c:426:
// 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);- In
Convert.c:431:
// Test large integer
BitVec bv3 = BitVecFromInteger(UINT64_MAX, 64, ALLOCATOR_OF(&alloc)); // 64 bits for max value
result = result && (BitVecLen(&bv3) == 64);
BitVecDeinit(&bv3);- In
Convert.c:444:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec round-trip conversions\n");
bool result = true;- In
Convert.c:452:
for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
BitVec bv = BitVecFromStr(patterns[i], ALLOCATOR_OF(&alloc));
Str str = BitVecToStr(&bv);- In
Convert.c:475:
value &= mask;
BitVec bv = BitVecFromInteger(value, bits, ALLOCATOR_OF(&alloc));
u64 recovered = BitVecToInteger(&bv);- In
Convert.c:488:
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);- In
Convert.c:507:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec conversion bounds checking\n");
bool result = true;- In
Convert.c:512:
// Test large integer conversion (should cap at 64 bits)
BitVec large_bv = BitVecFromInteger(0xFFFFFFFFFFFFFFFF, 64, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_bv) == 64);- In
Convert.c:520:
// 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);- In
Convert.c:531:
// Test zero-length conversions
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
Str empty_str = BitVecToStr(&empty);- In
Convert.c:556:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec comprehensive conversion validation\n");
bool result = true;- In
Convert.c:576:
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
- In
Convert.c:607:
// FromInteger(0xD6, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
// FromBytes({0xD6}, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));- In
Convert.c:608:
// FromBytes({0xD6}, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));- In
Convert.c:609:
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
Str str1 = BitVecToStr(&bv1);- In
Convert.c:638:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec large-scale conversions\n");
bool result = true;- In
Convert.c:643:
// Test with very large bitvectors
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create a 1000-bit pattern
- In
Convert.c:674:
// Test round-trip from bytes
BitVec recovered_bv = BitVecFromBytes(large_bytes, 1000, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&recovered_bv) == 1000);- In
Convert.c:699:
large_pattern[2000] = '\0';
BitVec large_from_str = BitVecFromStr(large_pattern, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_from_str) == 2000);- In
Convert.c:725:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes zero max_len handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Convert.c:727:
WriteFmt("Testing BitVec bytes zero max_len handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);- In
Convert.c:741:
bool test_bitvec_integer_bounds_failures(void) {
WriteFmt("Testing BitVec integer bounds failures\n");
// Test BitVecToInteger with NULL pointer - should abort
- In
Convert.c:754:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec convert NULL pointer handling\n");
// Use the explicit-allocator form so the NULL bitvec reaches the
- In
Convert.c:759:
// function-level ValidateBitVec instead of dereferencing NULL
// inside the BitVecAllocator accessor macro.
BitVecToStr((BitVec *)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);- In
Convert.c:769:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec from string NULL handling\n");
// Test NULL string - should abort
- In
Convert.c:782:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVec bytes NULL handling\n");
// Test NULL bytes - should abort
- In
Convert.c:798:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv;
bool ok = BitVecTryFromInteger(&bv, 0xFFu, 100, ALLOCATOR_OF(&alloc));- In
Convert.c:823:
WriteFmt("Testing BitVecToBytes 4-bit pack does not over-read\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 4-bit pattern 1011 -> LSB-first packing: bits 0,2,3 set -> 0x0D.
BitVecPush(&bv, true); // bit 0
- In
Convert.c:856:
WriteFmt("Testing BitVecToBytes truncation respects max_len\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 16 bits; ensure byte 1 has at least one set bit (bit 8 -> byte1 bit0).
for (u64 i = 0; i < 16; i++) {- In
Convert.c:885:
WriteFmt("Testing BitVecToBytes aborts on an invalid (zeroed) bitvec\n");
BitVec bv = {0}; // bad magic -> ValidateBitVec must abort
u8 bytes[4];- In
Convert.c:900:
Str s = StrInitFromZstr("111000111", &alloc);
BitVec bv = bitvec_from_str_str(&s, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&bv) == 9) && (BitVecCountOnes(&bv) == 6);
for (int i = 0; i < 9; i++) {- In
Convert.c:913:
int main(void) {
WriteFmt("[INFO] Starting BitVec.Convert tests\n\n");
// Array of normal test functions
- In
Convert.c:953:
// 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 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
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>- In
Write.c:5:
#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
Write.c:529:
bool test_bitvec_formatting(void) {
WriteFmt("Testing BitVec formatting\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:537:
bool success = true;
BitVec bv1 = BitVecFromStr("10110", alloc_base);
StrAppendFmt(&output, "{}", bv1);
success = success && (ZstrCompare(StrBegin(&output), "10110") == 0);- In
Write.c:542:
StrClear(&output);
BitVec bv_empty = BitVecInit(alloc_base);
StrAppendFmt(&output, "{}", bv_empty);
success = success && (StrLen(&output) == 0);- In
Write.c:547:
StrClear(&output);
BitVec bv2 = BitVecFromInteger(0xABCD, 16, alloc_base);
StrAppendFmt(&output, "{x}", bv2);
success = success && (ZstrCompare(StrBegin(&output), "0xabcd") == 0);- In
Write.c:556:
StrClear(&output);
BitVec bv3 = BitVecFromInteger(0755, 10, alloc_base);
StrAppendFmt(&output, "{o}", bv3);
success = success && (ZstrCompare(StrBegin(&output), "0o755") == 0);- In
Write.c:573:
StrClear(&output);
BitVec bv_zero = BitVecFromInteger(0, 1, alloc_base);
StrAppendFmt(&output, "{x}", bv_zero);
success = success && (ZstrCompare(StrBegin(&output), "0x0") == 0);- In
Write.c:1413:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x1";
StrReadFmt(z, "{}", bv);- In
Write.c:1431:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);- In
Write.c:1447:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);- In
Write.c:1466:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o1";
StrReadFmt(z, "{}", bv);- In
Write.c:1485:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o10";
StrReadFmt(z, "{}", bv);- In
Write.c:1502:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o755";
StrReadFmt(z, "{}", bv);- In
Write.c:2490:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x3ff";
StrReadFmt(z, "{}", bv);- In
Write.c:2509:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xff";
StrReadFmt(z, "{}", bv);- In
Write.c:2528:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x10000";
StrReadFmt(z, "{}", bv);- In
Write.c:3718:
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("1", alloc_base);
StrAppendFmt(&out, "XX{>5}", bv);- In
Write.c:5408:
static bool test_bitvec_write_no_leak(void) {
DBG_BEGIN(dbg, out);
BitVec bv = BitVecFromStr("10110", &dbg.base);
StrAppendFmt(&out, "{}", bv);
bool ok = (ZstrCompare(StrBegin(&out), "10110") == 0);- In
Write.c:5420:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("101", ab);
StrAppendFmt(&out, "{}", bv);
bool ok = (ZstrCompare(StrBegin(&out), "101") == 0);- In
Write.c:5715:
bool test_leak_write_bitvec_freed(void) {
HeapAllocator va = HeapAllocatorInit();
BitVec v = BitVecInit(ALLOCATOR_OF(&va));
BitVecResize(&v, 12);
LEAK_WRITE_PRELUDE();- In
Read.c:5:
#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
Read.c:837:
bool test_bitvec_reading(void) {
WriteFmt("Testing BitVec reading\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Read.c:846:
bool success = true;
BitVec bv1 = BitVecInit(alloc_base);
z = "10110";
StrReadFmt(z, "{}", bv1);- In
Read.c:859:
BitVecDeinit(&bv1);
BitVec bv2 = BitVecInit(alloc_base);
z = "0xDEAD";
StrReadFmt(z, "{}", bv2);- In
Read.c:867:
BitVecDeinit(&bv2);
BitVec bv3 = BitVecInit(alloc_base);
z = "0o755";
StrReadFmt(z, "{}", bv3);- In
Read.c:875:
BitVecDeinit(&bv3);
BitVec bv4 = BitVecInit(alloc_base);
z = " 1101";
StrReadFmt(z, "{}", bv4);- In
Read.c:888:
BitVecDeinit(&bv4);
BitVec bv5 = BitVecInit(alloc_base);
z = "0";
StrReadFmt(z, "{}", bv5);- In
Read.c:901:
BitVecDeinit(&bv5);
WriteFmt("Overall BitVec reading success: {}\n", success ? "true" : "false");
DefaultAllocatorDeinit(&alloc);
return success;- In
Read.c:2513:
static bool test_read_bitvec_hex(void) {
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "0x1";
StrReadFmt(z, "{}", bv);- In
Read.c:2526:
static bool test_read_bitvec_hex_wide(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(&alloc.base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);- In
Read.c:2538:
static bool test_read_bitvec_octal(void) {
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "0o1";
StrReadFmt(z, "{}", bv);- In
Read.c:2551:
static bool test_read_bitvec_binary(void) {
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "10110";
StrReadFmt(z, "{}", bv);- In
Read.c:2743:
static bool leak_bitvec_overflow(Zstr input) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
BitVec bv = BitVecInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, "{}", bv);
Last updated on