Skip to content

ALLOCATOR_OF

Description

Convert any allocator pointer to Allocator *. The argument may be:

  • a typed allocator pointer (HeapAllocator *, PageAllocator *,

ArenaAllocator *, SlabAllocator *, BudgetAllocator *), in which case the macro typecasts the whole pointer to Allocator *. The cast is safe because every typed allocator carries Allocator base at offset zero — the C-style inheritance contract.

  • a raw Allocator *, which is returned unchanged.

Any other pointer type triggers a _Generic mismatch at compile time, which is the type-safety check the macro layer provides.

Callers do not write &heap.base or (Allocator *)&heap by hand — every macro that takes an allocator pointer routes it through this macro first.

Usage example (from documentation)


    HeapAllocator heap = HeapAllocatorInit();
    Vec(int) v = VecInit(&heap);   // macro internally does ALLOCATOR_OF(&heap)

    void library_helper(Vec *v, Allocator *alloc) {
        Vec(int) scratch = VecInit(alloc);   // raw Allocator* also accepted
    }

Adding a new typed allocator requires adding it to this whitelist
(and forward-declaring it above).

Usage example (Cross-references)

Usage examples (Cross-references)
    static bool test_basic_alloc_free(void) {
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        char *a  = (char *)AllocatorAlloc(alloc, 32, true);
    static bool test_zeroed_alloc(void) {
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        u8  *p  = (u8 *)AllocatorAlloc(alloc, 64, true);
    static bool test_free_then_alloc_recycles(void) {
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        void *a = AllocatorAlloc(alloc, 32, false);
        // > 2 KiB hits the page-allocator passthrough path inside Heap.
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        size n  = 64 * 1024;
    static bool test_realloc_same_bin_keeps_pointer(void) {
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        // Both 24 and 28 fall in the 32-byte bin, so realloc must keep the
    static bool test_realloc_cross_bin_copies(void) {
        HeapAllocator heap  = HeapAllocatorInit();
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        char *p  = (char *)AllocatorAlloc(alloc, 16, true);
    static bool test_overaligned_alloc(void) {
        HeapAllocator heap  = HeapAllocatorInitAligned(64);
        Allocator    *alloc = ALLOCATOR_OF(&heap);
    
        // Alignment > 16 bypasses the bin path and goes via the embedded
        HeapAllocator h1     = HeapAllocatorInit();
        HeapAllocator h2     = HeapAllocatorInit();
        Allocator    *alloc1 = ALLOCATOR_OF(&h1);
        Allocator    *alloc2 = ALLOCATOR_OF(&h2);
        HeapAllocator h2     = HeapAllocatorInit();
        Allocator    *alloc1 = ALLOCATOR_OF(&h1);
        Allocator    *alloc2 = ALLOCATOR_OF(&h2);
    
        void *a  = AllocatorAlloc(alloc1, 32, true);
        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
        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);
        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
        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
        WriteFmt("Testing BitVec NOT with NULL handling\n");
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL operand - should abort
    static bool test_basic_alloc_and_free(void) {
        PageAllocator alloc      = PageAllocatorInit();
        Allocator    *alloc_base = ALLOCATOR_OF(&alloc);
        void         *ptr        = AllocatorAlloc(alloc_base, 128, true);
        bool          ok         = (ptr != NULL);
    static bool test_realloc_grow_then_shrink(void) {
        PageAllocator alloc      = PageAllocatorInit();
        Allocator    *alloc_base = ALLOCATOR_OF(&alloc);
        size          page       = PageAllocatorPageSize(&alloc);
        char         *ptr        = (char *)AllocatorAlloc(alloc_base, 64, true);
        // portably.
        PageAllocator alloc      = PageAllocatorInitAligned(64);
        Allocator    *alloc_base = ALLOCATOR_OF(&alloc);
        size          page       = PageAllocatorPageSize(&alloc);
        void         *ptr        = AllocatorAlloc(alloc_base, 1024, true);
        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];
    
        // Test foreach with invalid bitvec (length > 0 but data is NULL)
        BitVec bv   = BitVecInit(ALLOCATOR_OF(&alloc));
        bv.length   = 5;
        bv.capacity = 10;
        DefaultAllocator alloc = DefaultAllocatorInit();
        typedef List(int) LI;
        LI li = ListInit(ALLOCATOR_OF(&alloc));
        ListForeach(&li, i) {
            (void)i;
        WriteFmt("Testing BitVecHammingDistance basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecHammingDistance edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecJaccardSimilarity basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecJaccardSimilarity edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecCosineSimilarity basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecCosineSimilarity edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecDotProduct basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecDotProduct edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecEditDistance basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecEditDistance edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecCorrelation basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecCorrelation edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecEntropy basic functionality\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecEntropy edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecAlignmentScore basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecAlignmentScore edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecBestAlignment basic functionality\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecBestAlignment edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec Math stress tests\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test edit distance with smaller vectors (expensive operation)
        BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 50; i++) {
        // Test edit distance with smaller vectors (expensive operation)
        BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 50; i++) {
            BitVecPush(&small1, i % 2 == 0);
    
        WriteFmt("Testing BitVecHammingDistance(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecHammingDistance(NULL, &bv2);
    
        WriteFmt("Testing BitVecHammingDistance(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecHammingDistance(&bv1, NULL);
    
        WriteFmt("Testing BitVecJaccardSimilarity(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecJaccardSimilarity(NULL, &bv2);
    
        WriteFmt("Testing BitVecJaccardSimilarity(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecJaccardSimilarity(&bv1, NULL);
    
        WriteFmt("Testing BitVecCosineSimilarity(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecCosineSimilarity(NULL, &bv2);
    
        WriteFmt("Testing BitVecCosineSimilarity(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecCosineSimilarity(&bv1, NULL);
    
        WriteFmt("Testing BitVecDotProduct(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecDotProduct(NULL, &bv2);
    
        WriteFmt("Testing BitVecDotProduct(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecDotProduct(&bv1, NULL);
    
        WriteFmt("Testing BitVecEditDistance(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecEditDistance(NULL, &bv2);
    
        WriteFmt("Testing BitVecEditDistance(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecEditDistance(&bv1, NULL);
    
        WriteFmt("Testing BitVecCorrelation(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecCorrelation(NULL, &bv2);
    
        WriteFmt("Testing BitVecCorrelation(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecCorrelation(&bv1, NULL);
    
        WriteFmt("Testing BitVecAlignmentScore(NULL, bv2, 1, -1) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecAlignmentScore(NULL, &bv2, 1, -1);
    
        WriteFmt("Testing BitVecAlignmentScore(bv1, NULL, 1, -1) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecAlignmentScore(&bv1, NULL, 1, -1);
    
        WriteFmt("Testing BitVecBestAlignment(NULL, bv2) - should fatal\n");
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        BitVecBestAlignment(NULL, &bv2);
    
        WriteFmt("Testing BitVecBestAlignment(bv1, NULL) - should fatal\n");
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecBestAlignment(&bv1, NULL);
        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);
        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);
    
        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, NULL);
        DefaultAllocator alloc = DefaultAllocatorInit();
        WriteFmt("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
        BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
        BitVecPush(VecPtrAt(&vp, 0), true);
        BitVecPrefixMatch(NULL, &vp);
    
        WriteFmt("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&source, true);
        BitVecPrefixMatch(&source, NULL);
        DefaultAllocator alloc = DefaultAllocatorInit();
        WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
        BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
        BitVecPush(VecPtrAt(&vp, 0), true);
        BitVecSuffixMatch(NULL, &vp);
    
        WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&source, true);
        BitVecSuffixMatch(&source, NULL);
    static bool test_basic_bump(void) {
        ArenaAllocator arena      = ArenaAllocatorInit();
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        char          *a          = (char *)AllocatorAlloc(alloc_base, 16, true);
        char          *b          = (char *)AllocatorAlloc(alloc_base, 32, true);
    static bool test_grow_last_in_place(void) {
        ArenaAllocator arena      = ArenaAllocatorInit();
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        char          *p          = (char *)AllocatorAlloc(alloc_base, 16, true);
        bool           ok         = (p != NULL);
    static bool test_grow_non_last_relocates(void) {
        ArenaAllocator arena      = ArenaAllocatorInit();
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        char          *a          = (char *)AllocatorAlloc(alloc_base, 16, true);
        char          *b          = (char *)AllocatorAlloc(alloc_base, 16, true);
    static bool test_reset(void) {
        ArenaAllocator arena      = ArenaAllocatorInit();
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        char          *a          = (char *)AllocatorAlloc(alloc_base, 4096, true);
        char          *b          = (char *)AllocatorAlloc(alloc_base, 4096, true);
    static bool test_alignment(void) {
        ArenaAllocator arena      = ArenaAllocatorInitAligned(64);
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        void          *a          = AllocatorAlloc(alloc_base, 1, true);
        void          *b          = AllocatorAlloc(alloc_base, 1, true);
        WriteFmt("Testing BitVecShrinkToFit\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits
        WriteFmt("Testing BitVecReserve\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits
        WriteFmt("Testing BitVecSwap\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up first bitvector
        WriteFmt("Testing BitVecClone\n");
    
        BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up original bitvector
        alloc.base.retry_limit = 9;
    
        BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVecPush(&original, true);
        WriteFmt("Testing BitVecShrinkToFit edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecReserve edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecSwap edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecClone edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        // Test multiple clone/swap/reu64 cycles
        for (int cycle = 0; cycle < 10; cycle++) {
            BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
            BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int cycle = 0; cycle < 10; cycle++) {
            BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
            BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
            // Add random-sized data
        WriteFmt("Testing BitVec swap NULL handling\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL pointer - should abort
        WriteFmtLn("Testing BitVecAnd");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up first bitvector: 1101
        WriteFmtLn("Testing BitVecOr");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up first bitvector: 1100
        WriteFmtLn("Testing BitVecXor");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up first bitvector: 1100
        WriteFmtLn("Testing BitVecNot");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1010
        WriteFmtLn("Testing BitVecShiftLeft");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1011 (indices 0,1,2,3)
        WriteFmtLn("Testing BitVecShiftRight");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1011
        WriteFmtLn("Testing BitVecRotateLeft");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1011
        WriteFmtLn("Testing BitVecRotateRight");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1011
        WriteFmtLn("Testing BitVecReverse");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Set up bitvector: 1011
        WriteFmtLn("Testing BitVec shift edge cases");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmtLn("Testing BitVec rotate edge cases");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmtLn("Testing BitVec bitwise operations edge cases");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test operations on empty bitvecs
        BitVec result_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecAnd(&result_bv, &bv1, &bv2);
        result = result && (result_bv.length == 0);
        WriteFmtLn("Testing BitVecReverse edge cases");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmtLn("Testing BitVec comprehensive bitwise operations");
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        WriteFmtLn("Testing BitVec comprehensive shift operations");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmtLn("Testing BitVec comprehensive rotate operations");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmtLn("Testing BitVec bitwise identity operations");
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        WriteFmtLn("Testing BitVec bitwise commutative properties");
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result1     = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result1     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result2     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result1     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result2     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result1     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result2     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        WriteFmtLn("Testing BitVec bitwise operations with large patterns");
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        BitVec bv1         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2         = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec result      = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   test_result = true;
        WriteFmtLn("Testing BitVec bitwise operations NULL handling");
    
        BitVec bv  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL pointer - should abort
        WriteFmtLn("Testing BitVec AND with NULL result handling");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv1, true);
        BitVecPush(&bv2, false);
        WriteFmtLn("Testing BitVec OR with NULL operand handling");
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL operand - should abort
        WriteFmtLn("Testing BitVec XOR with NULL second operand handling");
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL second operand - should abort
        WriteFmtLn("Testing BitVec NOT with NULL handling");
    
        BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL operand - should abort
        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 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;
        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;
    
        BitVec  source   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
        bool    result   = true;
        BitVec *p2 = VecPtrAt(&patterns, 2);
    
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Pattern 0: 111 (should not match)
        WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
    
        BitVec  source   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
        bool    result   = true;
    
        BitVec  source   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
        bool    result   = true;
        BitVec *p2 = VecPtrAt(&patterns, 2);
    
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p1 = BitVecInit(ALLOCATOR_OF(&alloc));
        *p2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Pattern 0: 111 (should not match)
    
        // Create a bitvector
        BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Check initial state
    
        // Create a valid bitvector
        BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // This should not abort
        u8              buf[1024] = {0};
        BudgetAllocator bp        = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
        Allocator      *alloc     = ALLOCATOR_OF(&bp);
        Node           *a         = (Node *)AllocatorAlloc(alloc, sizeof(Node), true);
        Node           *b         = (Node *)AllocatorAlloc(alloc, sizeof(Node), true);
        u8              buf[256] = {0};
        BudgetAllocator bp       = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
        Allocator      *alloc    = ALLOCATOR_OF(&bp);
    
        bool ok = bp.slot_count > 0;
        u8              buf[1024] = {0};
        BudgetAllocator bp        = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
        Allocator      *alloc     = ALLOCATOR_OF(&bp);
    
        Node *a  = (Node *)AllocatorAlloc(alloc, sizeof(Node), true);
        u8              buf[256] = {0};
        BudgetAllocator bp       = BudgetAllocatorInit(buf, sizeof(buf), sizeof(int));
        Allocator      *alloc    = ALLOCATOR_OF(&bp);
        void           *big      = AllocatorAlloc(alloc, 4096, true);
        bool            ok       = (big == NULL);
        MemSet(buf, 0, sizeof(buf));
        BudgetAllocator bp    = BudgetAllocatorInitAligned(buf, sizeof(buf), sizeof(int), 64);
        Allocator      *alloc = ALLOCATOR_OF(&bp);
        int            *p1    = (int *)AllocatorAlloc(alloc, sizeof(int), true);
        int            *p2    = (int *)AllocatorAlloc(alloc, sizeof(int), true);
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        const char *z = NULL;
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        const char *z = NULL;
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        const char *z = NULL;
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        const char *z = NULL;
    static bool test_basic_alloc_and_free(void) {
        SlabAllocator slab       = SlabAllocatorInit(sizeof(Node));
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        Node         *a          = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true);
        Node         *b          = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true);
    static bool test_free_then_alloc_recycles(void) {
        SlabAllocator slab       = SlabAllocatorInit(sizeof(Node));
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        Node         *a          = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true);
        bool          ok         = (a != NULL);
    static bool test_grow_across_chunks(void) {
        SlabAllocator slab       = SlabAllocatorInit(sizeof(Node));
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        Node         *slots[600];
        bool          ok = true;
    static bool test_oversized_request_fails(void) {
        SlabAllocator slab       = SlabAllocatorInit(sizeof(int));
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        void         *big        = AllocatorAlloc(alloc_base, 4096, true);
        bool          ok         = (big == NULL);
    static bool test_free_half_then_realloc(void) {
        SlabAllocator slab       = SlabAllocatorInit(sizeof(Node));
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        Node         *slots[200];
        bool          ok = true;
    static bool test_pool_alignment(void) {
        SlabAllocator slab       = SlabAllocatorInitAligned(sizeof(int), 64);
        Allocator    *alloc_base = ALLOCATOR_OF(&slab);
        int          *p          = (int *)AllocatorAlloc(alloc_base, sizeof(int), true);
        bool          ok         = (p != NULL) && (((uintptr_t)p & 63u) == 0);
        WriteFmt("Testing BitVecPush\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Push some bits
        WriteFmt("Testing BitVecInsert (single bit)\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Insert at index 0 (empty bitvector)
        WriteFmt("Testing BitVecInsertRange\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create target bitvector
        WriteFmt("Testing BitVecInsertMultiple\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Start with some bits
        WriteFmt("Testing BitVecInsertPattern\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Start with some bits
    
        // Test with different pattern - 0x05 (0101 in binary) using only 3 bits
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv2, true);
        WriteFmt("Testing BitVecInsertRange edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecInsertMultiple edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec empty  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec empty  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec empty  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecInsertPattern edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec insert invalid range handling\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test inserting beyond capacity limit - should abort
        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
        WriteFmt("Testing BitVec shift edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec rotate edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        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 && (result_bv.length == 0);
        WriteFmt("Testing BitVecReverse edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        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;
        WriteFmt("Testing BitVec comprehensive shift operations\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec comprehensive rotate operations\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        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;
        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;
        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;
    
        // Test basic initialization
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Check initial state
        WriteFmt("Testing BitVecDeinit\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some data to make sure deinitialization works with allocated memory
        WriteFmt("Testing BitVecReserve\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Reserve space for 50 bits
        WriteFmt("Testing BitVecClear\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some data
        WriteFmt("Testing BitVecResize\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some initial data
    
        // Test multiple initializations
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
        // Test multiple initializations
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        bool result = (bv1.length == 0) && (bv2.length == 0) && (bv3.length == 0);
        WriteFmt("Testing BitVecReserve edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecReu64 edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecClear edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        // Test multiple init/deinit cycles
        for (int cycle = 0; cycle < 100; cycle++) {
            BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
            // Add some data
        // 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);
        // 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);
        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
        WriteFmt("Testing BitVec foreach edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        int    count  = 0;
        WriteFmt("Testing BitVec foreach idx edge cases\n");
    
        BitVec bv       = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result   = true;
        u64    last_idx = SIZE_MAX;
        WriteFmt("Testing BitVec foreach reverse edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec foreach range edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        for (int sz = 0; sz < 100; sz += 10) {
            BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
            // Create bitvec of varying sz
        WriteFmt("Testing BitVecRunLengths basic functionality\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test 1: Empty bitvector
        BitVec empty_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        u64    runs[5];
        bool   values[5];
    
        // Test 2: Single bit (true)
        BitVec single_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&single_bv, true);
        count  = BitVecRunLengths(&single_bv, runs, values, 5);
    
        // Test 3: Single bit (false)
        BitVec single_false_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&single_false_bv, false);
        count  = BitVecRunLengths(&single_false_bv, runs, values, 5);
    
        // Test 4: All same bits (all true)
        BitVec all_true_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 10; i++) {
            BitVecPush(&all_true_bv, true);
    
        // Test 5: Alternating bits (0101010)
        BitVec alternating_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 7; i++) {
            BitVecPush(&alternating_bv, i % 2 == 0);
        WriteFmt("Testing BitVecRunLengths boundary conditions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test with large bitvector
        BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern that results in many runs
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str  output  = StrInit(&alloc);
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str  output  = StrInit(&alloc);
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        Str   output  = StrInit(&alloc);
        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;
        WriteFmt("Testing BitVec multiple access operations\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec access with large patterns\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec macro functions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec access stress test\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        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;
        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;
        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;
        WriteFmt("Testing BitVecEquals\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test equal empty bitvectors
        WriteFmt("Testing BitVecCompare\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test equal bitvectors
        WriteFmt("Testing BitVecLexCompare\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test lexicographic comparison
        WriteFmt("Testing BitVecNumericalCompare\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create bitvectors representing different numbers
        WriteFmt("Testing BitVecWeightCompare\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // bv1: 111 (3 ones)
        WriteFmt("Testing BitVecIsSubset\n");
    
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create superset: 1111
        WriteFmt("Testing BitVecSignedCompare\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test positive vs negative (MSB is sign bit)
        WriteFmt("Testing BitVecIsSuperset\n");
    
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create superset: 1111
        WriteFmt("Testing BitVecOverlaps\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create overlapping bitvectors
        WriteFmt("Testing BitVecDisjoint and BitVecIntersects\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create disjoint bitvectors
        WriteFmt("Testing BitVecEqualsRange\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create test patterns
        WriteFmt("Testing BitVecCompareRange\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create test patterns
        WriteFmt("Testing BitVecIsLexicographicallyLess and BitVecIsNumericallyLess\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test lexicographic comparison
        WriteFmt("Testing BitVecIsSorted\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test empty bitvector (should be sorted)
        WriteFmt("Testing BitVec compare edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec set operations edge cases\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec comprehensive comparison operations\n");
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec bv1    = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2    = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test transitivity: if A < B and B < C, then A < C
        BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
        // bv3: larger than bv2
        for (int i = 0; i < 8; i++) {
    
        // Test subset/superset consistency
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
        // Test subset/superset consistency
        BitVec subset   = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create actual subset/superset relationship
        WriteFmt("Testing BitVec large-scale comparison operations\n");
    
        BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Verify signed vs unsigned comparison differences
        BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));
        // Verify signed vs unsigned comparison differences
        BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Positive number (MSB = 0): 01111111
        WriteFmt("Testing BitVec compare NULL pointer handling\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL pointer - should abort
        WriteFmt("Testing BitVec range operations NULL handling\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test NULL pointer in range operations - should abort
        WriteFmt("Testing BitVec range operations bounds checking\n");
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create small bitvectors
        WriteFmt("Testing BitVecToStr\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern: 1011
        const char *str = "1011";
        BitVec      bv;
        bool        ok = BitVecTryFromStrAlloc(&bv, str, ALLOCATOR_OF(&alloc));
    
        // Check result
    
        // Test with empty string
        BitVec empty_bv = BitVecFromStrAlloc("", ALLOCATOR_OF(&alloc));
        result          = result && (empty_bv.length == 0);
        WriteFmt("Testing BitVecToBytes\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern: 10110011 (0xB3)
        u8     bytes[] = {0xB3}; // 10110011 in binary
        BitVec bv;
        bool   ok = BitVecTryFromBytesAlloc(&bv, bytes, 8, ALLOCATOR_OF(&alloc)); // 8 bits from the byte
    
        // Check result (8 bits from 1 byte)
        WriteFmt("Testing BitVecToInteger\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern: 1011 (decimal 11 if MSB first, 13 if LSB first)
    
        // Test with larger pattern
        BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 8; i++) {
            BitVecPush(&bv2, (i % 2 == 0)); // Alternating pattern
        u64    value = 11; // 1011 in binary
        BitVec bv;
        bool   ok = BitVecTryFromIntegerAlloc(&bv, value, 4, ALLOCATOR_OF(&alloc));
    
        // Check result
        // Test with zero
        BitVec zero_bv;
        result = result && BitVecTryFromIntegerAlloc(&zero_bv, 0, 8, ALLOCATOR_OF(&alloc));
        result = result && (zero_bv.length == 8);
        Str    str;
        bool   ok =
            BitVecTryFromStrAlloc(&bv, "101001", ALLOCATOR_OF(&alloc));
        bool result = ok && (bv.allocator->effort == alloc.base.effort) &&
                      (bv.allocator->retry_limit == alloc.base.retry_limit);
        WriteFmt("Testing BitVec convert edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test empty string
        BitVec bv1 = BitVecFromStrAlloc("", ALLOCATOR_OF(&alloc));
        result     = result && (bv1.length == 0);
        BitVecDeinit(&bv1);
    
        // Test single character
        BitVec bv2 = BitVecFromStrAlloc("1", ALLOCATOR_OF(&alloc));
        result     = result && (bv2.length == 1);
        result     = result && (BitVecGet(&bv2, 0) == true);
        long_str[1000] = '\0';
    
        BitVec bv3 = BitVecFromStrAlloc(long_str, ALLOCATOR_OF(&alloc));
        result     = result && (bv3.length == 1000);
        result     = result && (BitVecGet(&bv3, 0) == true);
        WriteFmt("Testing BitVec bytes conversion edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        // Test bytes to bitvec with 0 bits (should return empty bitvector)
        u8     empty_bytes[1] = {0x05};
        BitVec bv2            = BitVecFromBytesAlloc(empty_bytes, 0, ALLOCATOR_OF(&alloc)); // 0 bits
        result                = result && (bv2.length == 0);
        BitVecDeinit(&bv2);
        // Test single byte
        u8     single_byte[1] = {0xFF};
        BitVec bv3            = BitVecFromBytesAlloc(single_byte, 8, ALLOCATOR_OF(&alloc)); // 8 bits from 1 byte
        result                = result && (bv3.length == 8);
        BitVecDeinit(&bv3);
        WriteFmt("Testing BitVec integer conversion edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test integer to bitvec with 0
        BitVec bv2 = BitVecFromIntegerAlloc(0, 8, ALLOCATOR_OF(&alloc));     // 8 bits for zero
        result     = result && (bv2.length == 8); // Should be 8 bits
        BitVecDeinit(&bv2);
    
        // Test large integer
        BitVec bv3 = BitVecFromIntegerAlloc(UINT64_MAX, 64, ALLOCATOR_OF(&alloc)); // 64 bits for max value
        result     = result && (bv3.length == 64);
        BitVecDeinit(&bv3);
    
        for (size_t i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
            BitVec bv  = BitVecFromStrAlloc(patterns[i], ALLOCATOR_OF(&alloc));
            Str    str = BitVecToStr(&bv);
                value    &= mask;
    
                BitVec bv        = BitVecFromIntegerAlloc(value, bits, ALLOCATOR_OF(&alloc));
                u64    recovered = BitVecToInteger(&bv);
    
        for (size_t i = 0; i < sizeof(test_bytes); i++) {
            BitVec bv             = BitVecFromBytesAlloc(&test_bytes[i], 8, ALLOCATOR_OF(&alloc));
            u8     recovered_byte = 0;
            u64    written        = BitVecToBytes(&bv, &recovered_byte, 1);
    
        // Test large integer conversion (should cap at 64 bits)
        BitVec large_bv = BitVecFromIntegerAlloc(0xFFFFFFFFFFFFFFFF, 64, ALLOCATOR_OF(&alloc));
        result          = result && (large_bv.length == 64);
    
        // Test oversized bitvec to integer (should handle gracefully)
        BitVec oversized = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 100; i++) { // 100 bits > 64 bit limit
            BitVecPush(&oversized, i % 2 == 0);
    
        // Test zero-length conversions
        BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
    
        Str empty_str = BitVecToStr(&empty);
    
        for (size_t i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); i++) {
            BitVec bv = BitVecFromStrAlloc(test_cases[i].pattern, ALLOCATOR_OF(&alloc));
    
            // Test string conversion consistency
    
        // Test cross-format validation
        BitVec bv1 = BitVecFromStrAlloc("11010110", ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecFromIntegerAlloc(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
        BitVec bv3 = BitVecFromBytesAlloc((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
        // Test cross-format validation
        BitVec bv1 = BitVecFromStrAlloc("11010110", ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecFromIntegerAlloc(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
        BitVec bv3 = BitVecFromBytesAlloc((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
        BitVec bv1 = BitVecFromStrAlloc("11010110", ALLOCATOR_OF(&alloc));
        BitVec bv2 = BitVecFromIntegerAlloc(0xD6, 8, ALLOCATOR_OF(&alloc)); // Assuming MSB-first: 11010110 = 0xD6
        BitVec bv3 = BitVecFromBytesAlloc((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
    
        // All three should produce the same result when converted back
    
        // Test with very large bitvectors
        BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create a 1000-bit pattern
    
        // Test round-trip from bytes
        BitVec recovered_bv = BitVecFromBytesAlloc(large_bytes, 1000, ALLOCATOR_OF(&alloc));
        result              = result && (recovered_bv.length == 1000);
        large_pattern[2000] = '\0';
    
        BitVec large_from_str = BitVecFromStrAlloc(large_pattern, ALLOCATOR_OF(&alloc));
        result                = result && (large_from_str.length == 2000);
        WriteFmt("Testing BitVec bytes bounds failures\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        // Test fromBytes with 0 bit length - should return empty bitvec
        u8     dummy_bytes[1] = {0xFF};
        BitVec empty_bv       = BitVecFromBytesAlloc(dummy_bytes, 0, ALLOCATOR_OF(&alloc));
        bool   result         = (empty_bv.length == 0);
        BitVecDeinit(&empty_bv);
    
        // Test NULL string - should abort
        BitVecFromStrAlloc(NULL, ALLOCATOR_OF(&alloc));
    
        DefaultAllocatorDeinit(&alloc);
    
        // Test NULL bytes - should abort
        BitVecFromBytesAlloc(NULL, 8, ALLOCATOR_OF(&alloc)); // NULL bytes, 8 bits
    
        DefaultAllocatorDeinit(&alloc);
        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
        WriteFmt("Testing BitVec foreach edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        int    count  = 0;
        WriteFmt("Testing BitVec foreach idx edge cases\n");
    
        BitVec bv       = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result   = true;
        u64    last_idx = SIZE_MAX;
        WriteFmt("Testing BitVec foreach reverse edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec foreach range edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        for (int sz = 0; sz < 100; sz += 10) {
            BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
            // Create bitvec of varying sz
        WriteFmt("Testing BitVecRunLengths basic functionality\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test 1: Empty bitvector
        BitVec empty_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        u64    runs[5];
        bool   values[5];
    
        // Test 2: Single bit (true)
        BitVec single_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&single_bv, true);
        count  = BitVecRunLengths(&single_bv, runs, values, 5);
    
        // Test 3: Single bit (false)
        BitVec single_false_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&single_false_bv, false);
        count  = BitVecRunLengths(&single_false_bv, runs, values, 5);
    
        // Test 4: All same bits (all true)
        BitVec all_true_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 10; i++) {
            BitVecPush(&all_true_bv, true);
    
        // Test 5: Alternating bits (0101010)
        BitVec alternating_bv = BitVecInit(ALLOCATOR_OF(&alloc));
        for (int i = 0; i < 7; i++) {
            BitVecPush(&alternating_bv, i % 2 == 0);
        WriteFmt("Testing BitVecRunLengths boundary conditions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
    
        // Test with large bitvector
        BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern that results in many runs
        WriteFmt("Testing BitVecRunLengths with NULL runs array\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        bool values[5];
        WriteFmt("Testing BitVecRunLengths with NULL values array\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        u64 runs[5];
        WriteFmt("Testing BitVecRunLengths with zero max_runs\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        u64  runs[5];
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        if (!write_test_file(path, "hello from file")) {
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        WriteFmt("Testing ReadCompleteFile with existing buffer allocator\n");
        WriteFmt("Testing BitVec get bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test get from empty bitvec - should abort
        WriteFmt("Testing BitVec set bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test set on empty bitvec - should abort
        WriteFmt("Testing BitVec flip bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test flip on empty bitvec - should abort
        WriteFmt("Testing BitVec get with large out-of-bounds index\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        BitVecPush(&bv, false);
        WriteFmt("Testing BitVec set with large out-of-bounds index\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        BitVecPush(&bv, false);
        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);
        WriteFmt("Testing BitVec get with maximum index value\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        WriteFmt("Testing BitVecGet\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add a pattern: 1010
        WriteFmt("Testing BitVecSet\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Initialize with some bits
        WriteFmt("Testing BitVecFlip\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Initialize with pattern: 101
        WriteFmt("Testing BitVec length and capacity operations\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Initially should be empty
        WriteFmt("Testing BitVec count operations\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Create pattern: 1101000
        WriteFmt("Testing BitVecGet edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecSet edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecFlip edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec count edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec multiple access operations\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec large pattern access\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec macro functions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec access stress test\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec comprehensive bit patterns\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec get bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test get from empty bitvec - should abort
        WriteFmt("Testing BitVec set bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test set on empty bitvec - should abort
        WriteFmt("Testing BitVec flip bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test flip on empty bitvec - should abort
        WriteFmt("Testing BitVec get with large out-of-bounds index\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        BitVecPush(&bv, false);
        WriteFmt("Testing BitVec set with large out-of-bounds index\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        BitVecPush(&bv, false);
        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);
        WriteFmt("Testing BitVec get with maximum index value\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&bv, true);
        WriteFmt("Testing BitVecFind and BitVecFindLast functions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecAll, BitVecAny, BitVecNone functions\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecLongestRun function\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecFind edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        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;
        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 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;
        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 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);
        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 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 BitVecContains 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));
        BitVec patterns[3];
        bool   result = true;
        // Initialize patterns
        for (int i = 0; i < 3; i++) {
            patterns[i] = BitVecInit(ALLOCATOR_OF(&alloc));
        }
        WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
    
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVec patterns[3];
        bool   result = true;
        // Initialize patterns
        for (int i = 0; i < 3; i++) {
            patterns[i] = BitVecInit(ALLOCATOR_OF(&alloc));
        }
    
        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);
    
        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, NULL);
    
        WriteFmt("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
        BitVec patterns[1] = {BitVecInit(ALLOCATOR_OF(&alloc))};
        BitVecPush(&patterns[0], true);
        BitVecPrefixMatch(NULL, patterns, 1);
    
        WriteFmt("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&source, true);
        BitVecPrefixMatch(&source, NULL, 1);
    
        WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
        BitVec patterns[1] = {BitVecInit(ALLOCATOR_OF(&alloc))};
        BitVecPush(&patterns[0], true);
        BitVecSuffixMatch(NULL, patterns, 1);
    
        WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
        BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&source, true);
        BitVecSuffixMatch(&source, NULL, 1);
        WriteFmt("Testing BitVecPop\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits
        WriteFmt("Testing BitVecRemove (single bit)\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits: true, false, true, false, true
        WriteFmt("Testing BitVecRemoveRange\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits: true, false, true, true, false, true
        WriteFmt("Testing BitVecRemoveFirst\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits: true, false, true, false, true
        WriteFmt("Testing BitVecRemoveLast\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits: true, false, true, false, true
        WriteFmt("Testing BitVecRemoveAll\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Add some bits: true, false, true, false, true, false
        WriteFmt("Testing BitVecPop edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecRemove edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecRemoveRange edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecRemoveFirst/Last edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVecRemoveAll edge cases\n");
    
        BitVec bv     = BitVecInit(ALLOCATOR_OF(&alloc));
        bool   result = true;
        WriteFmt("Testing BitVec remove invalid range handling\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test removing beyond capacity limit - should abort
        WriteFmt("Testing BitVec pop bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test pop from empty bitvec - should abort
        WriteFmt("Testing BitVec remove bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test remove from empty bitvec - should abort
        WriteFmt("Testing BitVec remove range bounds checking\n");
    
        BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Test remove range from empty bitvec - should abort
                .data      = NULL,                                                                                         \
                .byte_size = 0,                                                                                            \
                .allocator = ALLOCATOR_OF(allocator_ptr),                                                                  \
                .__magic   = MISRA_BITVEC_MAGIC                                                                            \
            })
                       .data      = NULL,                                                                                  \
                       .byte_size = 0,                                                                                     \
                       .allocator = ALLOCATOR_OF(allocator_ptr),                                                           \
                       .__magic   = MISRA_BITVEC_MAGIC})
    #endif
        BitVec BitVecInitWithCapacity(u64 cap, Allocator *alloc);
    
    #define BitVecInitWithCapacityMacro(cap, allocator_ptr) BitVecInitWithCapacity((cap), ALLOCATOR_OF(allocator_ptr))
    
        void BitVecDeinit(BitVec *bv);
    /// TAGS: Float, Convert, Import, Generic
    ///
    #    define FloatFrom(value, allocator_ptr) FLOAT_FROM_DISPATCH(value)((value), ALLOCATOR_OF(allocator_ptr))
    #endif
         .states            = NULL,                                                                                        \
         .policy            = validate_map_policy_copy((policy_value)),                                                    \
         .allocator         = ALLOCATOR_OF(typed_alloc_ptr),                                                               \
         .__magic           = MISRA_MAP_MAGIC}
         .copy_deinit = (cd),                                                                                              \
         .length      = 0,                                                                                                 \
         .allocator   = ALLOCATOR_OF(typed_alloc_ptr),                                                                     \
         .__magic     = MISRA_LIST_MAGIC}
    
    #define StrTryInitFromCstr(out, cstr, len, allocator_ptr)                                                              \
        str_try_init_from_cstr((out), (cstr), (len), ALLOCATOR_OF(allocator_ptr))
    
    #define StrInitFromCstr(...)                MISRA_OVERLOAD(StrInitFromCstr, __VA_ARGS__)
    #define StrInitFromCstr(...)                MISRA_OVERLOAD(StrInitFromCstr, __VA_ARGS__)
    #define StrInitFromCstr_2(cstr, len)        str_init_from_cstr((cstr), (len), MisraScope)
    #define StrInitFromCstr_3(cstr, len, alloc) str_init_from_cstr((cstr), (len), ALLOCATOR_OF(alloc))
    
    #define StrInitFromZstr(...)       MISRA_OVERLOAD(StrInitFromZstr, __VA_ARGS__)
         .copy_deinit = NULL,                                                                                              \
         .data        = NULL,                                                                                              \
         .allocator   = ALLOCATOR_OF(allocator_ptr),                                                                       \
         .__magic     = MISRA_VEC_MAGIC}
         .copy_deinit = (GenericCopyDeinit)(cd),                                                                           \
         .data        = NULL,                                                                                              \
         .allocator   = ALLOCATOR_OF(allocator_ptr),                                                                       \
         .__magic     = MISRA_VEC_MAGIC}
         .pending_delete_count  = 0,                                                                                       \
         .mutation_epoch        = 0,                                                                                       \
         .allocator             = ALLOCATOR_OF(typed_alloc_ptr),                                                           \
         .__magic               = MISRA_GRAPH_MAGIC}
Last updated on