StrDeinit

Table of Contents

StrDeinit

Description

Deinit str by freeing all allocations. str : Pointer to string to be deinited

Usage example (Cross-references)

    if (read_si.pos == si.pos) {                                                                           \
    LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
    StrDeinit(&key);                                                                                   \
    failed = true;                                                                                     \
    si     = saved_si;                                                                                 \
    if (read_si.pos == si.pos) {                                                                               \
    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
    StrDeinit(&key);                                                                                       \
    failed = true;                                                                                         \
    si     = saved_si;                                                                                     \
    if (StrIterPeek(&si) != ':') {                                                                             \
    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
    StrDeinit(&key);                                                                                       \
    failed = true;                                                                                         \
    si     = saved_si;                                                                                     \
    if (read_si.pos == si.pos) {                                                                           \
    LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
    StrDeinit(&key);                                                                                   \
    failed = true;                                                                                     \
    si     = saved_si;                                                                                 \
    si = read_si;                                                                                          \
    }                                                                                                          \
    StrDeinit(&key);                                                                                           \
    si = JSkipWhitespace(si);                                                                                  \
    \
    StrWriteFmtInternal(&out_##__LINE__, (fmtstr), argv_##__LINE__, argc_##__LINE__);                              \
    fwrite(out_##__LINE__.data, 1, out_##__LINE__.length, (stream));                                               \
    StrDeinit(&out_##__LINE__);                                                                                    \
    } while (0)
    fwrite(out_##__LINE__.data, 1, out_##__LINE__.length, (stream));                                               \
    fputc('\n', (stream));                                                                                         \
    StrDeinit(&out_##__LINE__);                                                                                    \
    } while (0)
    StrWriteFmt(&m, __VA_ARGS__);                                                                                  \
    LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, m.data);                                                  \
    StrDeinit(&m);                                                                                                 \
    SysAbort();                                                                                                    \
    } while (0)
    StrWriteFmt(&m, __VA_ARGS__);                                                                                  \
    LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, m.data);                                                  \
    StrDeinit(&m);                                                                                                 \
    } while (0)
    StrWriteFmt(&m, __VA_ARGS__);                                                                                  \
    LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, m.data);                                                   \
    StrDeinit(&m);                                                                                                 \
    } while (0)
    }
    
    StrDeinit(&copy->name);
    copy->type = 0;
    stat(entry_path.data, &path_stat);
    
    StrDeinit(&entry_path);
    
    SysDirEntry direntry = {0};
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to read string key in object. Invalid JSON");
    StrDeinit(&key);
    return saved_si;
    }
    if (StrIterPeek(&si) != ':') {
    LOG_ERROR("Expected ':' after key string. Failed to read JSON");
    StrDeinit(&key);
    return saved_si;
    }
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to parse value. Invalid JSON.");
    StrDeinit(&key);
    return saved_si;
    }
    LOG_INFO("User skipped reading of '{}' field in JSON object.", key);
    
    StrDeinit(&key);
    si = read_si;
    si = JSkipWhitespace(si);
    if (has_exp) {
    LOG_ERROR("Invalid number. Multiple exponent indicators.");
    StrDeinit(&ns);
    return saved_si;
    }
    if (is_flt) {
    LOG_ERROR("Invalid number. Multiple decimal indicators.");
    StrDeinit(&ns);
    return saved_si;
    }
    "must appear after exponent 'E' or 'e' indicator."
    );
    StrDeinit(&ns);
    return saved_si;
    }
    "Expected only once after 'e' or 'E'."
    );
    StrDeinit(&ns);
    return saved_si;
    }
    if (!ns.length) {
    LOG_ERROR("Failed to parse number. '{.8}'", LVAL(saved_si.data + saved_si.pos));
    StrDeinit(&ns);
    return saved_si;
    }
    if (end == ns.data) {
    LOG_ERROR("Failed to convert string to number.");
    StrDeinit(&ns);
    return saved_si;
    }
    num->is_float = is_flt;
    
    StrDeinit(&ns);
    return si;
    }
    Str     s         = StrInit();
    si                = JReadString(si, &s);
    StrDeinit(&s);
    
    if (si.pos == before_si.pos) {
    
    // Free resources
    StrDeinit(&file_name);
    StrDeinit(&log_dir);
    // Free resources
    StrDeinit(&file_name);
    StrDeinit(&log_dir);
    
    if (e || !stderror) {
    SysStrError(errno, &err);
    LOG_ERROR("Could not save file position for rollback: {}", err);
    StrDeinit(&err);
    }
    }
    }
    
    StrDeinit(&buffer);
    }
    StrPushBackZstr(o, "0x");
    StrMerge(o, &hex);
    StrDeinit(&hex);
    });
    } else {
    StrPushBackZstr(o, "0x");
    StrMerge(o, &hex);
    StrDeinit(&hex);
    i++;
    }
    // Merge the formatted number into output
    StrMerge(o, &temp);
    StrDeinit(&temp);
    
    // Apply padding if width is specified
    // Merge the formatted number into output
    StrMerge(o, &temp);
    StrDeinit(&temp);
    
    // Apply padding if width is specified
    // Merge the formatted number into output
    StrMerge(o, &temp);
    StrDeinit(&temp);
    }
    char        c    = ProcessEscape(&curr);
    if (c == 0) { // Error in escape sequence
    StrDeinit(s);
    return NULL;
    }
    char        c    = ProcessEscape(&curr);
    if (c == 0) { // Error in escape sequence
    StrDeinit(s);
    return NULL;
    }
    if (quote) {
    LOG_ERROR("Unterminated quoted string");
    StrDeinit(s);
    return NULL;
    }
    // Try to parse as special value
    if (StrToF64(&temp, v, NULL)) {
    StrDeinit(&temp);
    return i;
    }
    return i;
    }
    StrDeinit(&temp);
    
    // If parsing failed, fall back to the new approach
    if (!IsValidNumericString(&temp, true)) {
    LOG_ERROR("Invalid floating point format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToF64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse f64");
    StrDeinit(&temp);
    return start;
    }
    }
    
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u8");
    StrDeinit(&temp);
    return start;
    }
    if (val > UINT8_MAX) {
    LOG_ERROR("Value {} exceeds u8 maximum ({})", val, UINT8_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (u8)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u16");
    StrDeinit(&temp);
    return start;
    }
    if (val > UINT16_MAX) {
    LOG_ERROR("Value {} exceeds u16 maximum ({})", val, UINT16_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (u16)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u32");
    StrDeinit(&temp);
    return start;
    }
    if (val > UINT32_MAX) {
    LOG_ERROR("Value {} exceeds u32 maximum ({})", val, UINT32_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (u32)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToU64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse u64");
    StrDeinit(&temp);
    return start;
    }
    }
    
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i8");
    StrDeinit(&temp);
    return start;
    }
    if (val > INT8_MAX || val < INT8_MIN) {
    LOG_ERROR("Value {} outside i8 range ({} to {})", val, INT8_MIN, INT8_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (i8)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i16");
    StrDeinit(&temp);
    return start;
    }
    if (val > INT16_MAX || val < INT16_MIN) {
    LOG_ERROR("Value {} outside i16 range ({} to {})", val, INT16_MIN, INT16_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (i16)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i32");
    StrDeinit(&temp);
    return start;
    }
    if (val > INT32_MAX || val < INT32_MIN) {
    LOG_ERROR("Value {} outside i32 range ({} to {})", val, INT32_MIN, INT32_MAX);
    StrDeinit(&temp);
    return start;
    }
    
    *v = (i32)val;
    StrDeinit(&temp);
    return start + pos;
    }
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    }
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToI64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse i64");
    StrDeinit(&temp);
    return start;
    }
    }
    
    StrDeinit(&temp);
    return start + pos;
    }
    // Check if reading failed
    if (next == i) {
    StrDeinit(&temp);
    return i;
    }
    if (!result) {
    LOG_ERROR("Failed to allocate memory for string");
    StrDeinit(&temp);
    return i;
    }
    
    *out = result;
    StrDeinit(&temp);
    return next;
    }
    Str bit_str = BitVecToStr(bv);
    StrMerge(o, &bit_str);
    StrDeinit(&bit_str);
    }
    }
    if (!StrToU64(&hex_str, &value, &config)) {
    LOG_ERROR("Failed to parse hex value");
    StrDeinit(&hex_str);
    return start;
    }
    
    *bv = BitVecFromInteger(value, bit_len);
    StrDeinit(&hex_str);
    return i;
    }
    if (!StrToU64(&oct_str, &value, &config)) {
    LOG_ERROR("Failed to parse octal value");
    StrDeinit(&oct_str);
    return start;
    }
    
    *bv = BitVecFromInteger(value, bit_len);
    StrDeinit(&oct_str);
    return i;
    }
    *bv = BitVecFromStr(bin_str.data);
    
    StrDeinit(&bin_str);
    return i;
    }
    if (StrToF64(&temp, &val, NULL)) {
    *v = (f32)val;
    StrDeinit(&temp);
    return i;
    }
    return i;
    }
    StrDeinit(&temp);
    
    // If parsing failed, fall back to the new approach
    if (!IsValidNumericString(&temp, true)) {
    LOG_ERROR("Invalid floating point format");
    StrDeinit(&temp);
    return start;
    }
    if (!StrToF64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse f32");
    StrDeinit(&temp);
    return start;
    }
    
    *v = (f32)val;
    StrDeinit(&temp);
    return start + pos;
    }
    }
    
    StrDeinit(&bv_str);
    return result;
    }
    }
    
    void StrDeinit(Str* copy) {
    ValidateStr(copy);
    if (copy->data) {
    ValidateStr(s);
    
    Strs sv     = VecInitWithDeepCopy(NULL, StrDeinit);
    size keylen = ZstrLen(key);
    }
    
    StrDeinit(&invalid_enum.name);
    StrDeinit(&invalid_enum.str);
    StrDeinit(&enum_name);
    
    StrDeinit(&invalid_enum.name);
    StrDeinit(&invalid_enum.str);
    StrDeinit(&enum_name);
    StrDeinit(&code);
    StrDeinit(&invalid_enum.name);
    StrDeinit(&invalid_enum.str);
    StrDeinit(&enum_name);
    StrDeinit(&code);
    StrDeinit(&invalid_enum.str);
    StrDeinit(&enum_name);
    StrDeinit(&code);
    
    VecForeach(&entries, e, {
    
    VecForeach(&entries, e, {
    StrDeinit(&e.name);
    StrDeinit(&e.str);
    });
    VecForeach(&entries, e, {
    StrDeinit(&e.name);
    StrDeinit(&e.str);
    });
    VecDeinit(&entries);
    }
    
    StrDeinit(&p->build_dir);
    VecDeinit(&p->source_directories);
    VecDeinit(&p->test_directories);
    // read project config
    Str config = StrInit();
    Scope(&config, StrDeinit, {
    if (!ReadCompleteFile(config_path, &config.data, &config.length, &config.capacity)) {
    LOG_FATAL("Failed to read config file.");
    Scope(&file_paths, VecDeinit, {
    // temporary vector to store all directory paths to explore files in
    Strs dir_paths = VecInitWithDeepCopy(NULL, StrDeinit);
    Scope(&dir_paths, VecDeinit, {
    VecMerge(&dir_paths, &project.source_directories);
    VecForeach(&file_paths, file_path, {
    Str file_contents = StrInit();
    Scope(&file_contents, StrDeinit, {
    if (!ReadCompleteFile(
    file_path.data,
    
    Str output_path = StrInit();
    Scope(&output_path, StrDeinit, {
    StrMerge(&output_path, &file_path);
    LOG_INFO("{}", output_path);
    
    Str md_code = StrInit();
    Scope(&md_code, StrDeinit, {
    // Create template strings for StrWriteFmt with escaped braces
    const char* mdHeader =
    if (rule_name.length) {
    WriteFmtLn("Got Rule : {}", rule_name);
    StrDeinit(&rule_name);
    }
    }
    // Cleanup functions
    void PersonDeinit(Person* person) {
    StrDeinit(&person->name);
    }
    
    void ConfigDeinit(Config* config) {
    StrDeinit(&config->log_level);
    }
    
    void SimpleProductDeinit(SimpleProduct* product) {
    StrDeinit(&product->name);
    VecDeinit(&product->tags);
    }
    }
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    return success;
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    PersonDeinit(&person);
    return success;
    }
    
    StrDeinit(&json);
    ConfigDeinit(&config);
    return success;
    Str  json    = StrInit();
    
    Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
    
    // Create strings and push them properly
    }
    
    StrDeinit(&json);
    VecDeinit(&languages);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    return success;
    }
    product.name          = StrInitFromZstr("Laptop");
    product.price         = 999.99;
    product.tags          = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit);
    
    // Create strings and push them properly
    }
    
    StrDeinit(&json);
    SimpleProductDeinit(&product);
    return success;
    // Cleanup functions
    void PersonDeinit(Person* person) {
    StrDeinit(&person->name);
    }
    
    void ConfigDeinit(Config* config) {
    StrDeinit(&config->log_level);
    }
    
    void SimpleProductDeinit(SimpleProduct* product) {
    StrDeinit(&product->name);
    VecDeinit(&product->tags);
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    return success;
    StrDeinit(&json);
    StrDeinit(&name);
    StrDeinit(&city);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    PersonDeinit(&person);
    return success;
    }
    
    StrDeinit(&json);
    ConfigDeinit(&config);
    return success;
    StrIter si      = StrIterFromStr(json);
    
    Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
    
    JR_OBJ(si, {
    }
    
    StrDeinit(&json);
    VecDeinit(&languages);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.user.name);
    StrDeinit(&data.user.email);
    return success;
    }
    SimpleProduct product = {0};
    product.name          = StrInit();
    product.tags          = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit);
    
    JR_OBJ(si, {
    }
    
    StrDeinit(&json);
    SimpleProductDeinit(&product);
    return success;
    }
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    
    Vec(i32) empty_numbers = VecInit();
    Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
    JW_OBJ(json, {
    }
    
    StrDeinit(&json);
    VecDeinit(&empty_numbers);
    VecDeinit(&empty_strings);
    }
    
    StrDeinit(&json);
    StrDeinit(&empty_name);
    StrDeinit(&empty_desc);
    
    StrDeinit(&json);
    StrDeinit(&empty_name);
    StrDeinit(&empty_desc);
    return success;
    StrDeinit(&json);
    StrDeinit(&empty_name);
    StrDeinit(&empty_desc);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    printf("[DEBUG] Large numbers JSON: %s\n", json.data);
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&path);
    StrDeinit(&message);
    
    StrDeinit(&json);
    StrDeinit(&path);
    StrDeinit(&message);
    StrDeinit(&data);
    StrDeinit(&json);
    StrDeinit(&path);
    StrDeinit(&message);
    StrDeinit(&data);
    return success;
    StrDeinit(&path);
    StrDeinit(&message);
    StrDeinit(&data);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&quotes);
    StrDeinit(&backslash);
    
    StrDeinit(&json);
    StrDeinit(&quotes);
    StrDeinit(&backslash);
    StrDeinit(&newline);
    StrDeinit(&json);
    StrDeinit(&quotes);
    StrDeinit(&backslash);
    StrDeinit(&newline);
    StrDeinit(&tab);
    StrDeinit(&quotes);
    StrDeinit(&backslash);
    StrDeinit(&newline);
    StrDeinit(&tab);
    return success;
    StrDeinit(&backslash);
    StrDeinit(&newline);
    StrDeinit(&tab);
    return success;
    }
    }
    
    StrDeinit(&json);
    VecDeinit(&empty_list);
    return success;
    }
    
    StrDeinit(&json);
    VecDeinit(&empty_arr);
    VecDeinit(&filled_arr);
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    success = false;
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    StrDeinit(&json3);
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    StrDeinit(&json3);
    StrDeinit(&json4);
    StrDeinit(&json1);
    StrDeinit(&json2);
    StrDeinit(&json3);
    StrDeinit(&json4);
    StrDeinit(&single_str);
    StrDeinit(&json2);
    StrDeinit(&json3);
    StrDeinit(&json4);
    StrDeinit(&single_str);
    return success;
    StrDeinit(&json3);
    StrDeinit(&json4);
    StrDeinit(&single_str);
    return success;
    }
    
    void EdgeCaseDataDeinit(EdgeCaseData* data) {
    StrDeinit(&data->empty_string);
    VecDeinit(&data->empty_array);
    VecDeinit(&data->numbers);
    }
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    return success;
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    return success;
    }
    StrIter si2   = StrIterFromStr(json2);
    
    Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit);
    
    JR_OBJ(si2, {
    }
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    VecDeinit(&items);
    
    StrDeinit(&json1);
    StrDeinit(&json2);
    VecDeinit(&items);
    VecDeinit(&data);
    }
    
    StrDeinit(&json);
    StrDeinit(&obj.name);
    StrDeinit(&obj.description);
    
    StrDeinit(&json);
    StrDeinit(&obj.name);
    StrDeinit(&obj.description);
    return success;
    StrDeinit(&json);
    StrDeinit(&obj.name);
    StrDeinit(&obj.description);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&obj.path);
    StrDeinit(&obj.message);
    
    StrDeinit(&json);
    StrDeinit(&obj.path);
    StrDeinit(&obj.message);
    StrDeinit(&obj.data);
    StrDeinit(&json);
    StrDeinit(&obj.path);
    StrDeinit(&obj.message);
    StrDeinit(&obj.data);
    return success;
    StrDeinit(&obj.path);
    StrDeinit(&obj.message);
    StrDeinit(&obj.data);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&obj.escaped);
    StrDeinit(&obj.backslash);
    
    StrDeinit(&json);
    StrDeinit(&obj.escaped);
    StrDeinit(&obj.backslash);
    StrDeinit(&obj.newline);
    StrDeinit(&json);
    StrDeinit(&obj.escaped);
    StrDeinit(&obj.backslash);
    StrDeinit(&obj.newline);
    StrDeinit(&obj.tab);
    StrDeinit(&obj.escaped);
    StrDeinit(&obj.backslash);
    StrDeinit(&obj.newline);
    StrDeinit(&obj.tab);
    return success;
    StrDeinit(&obj.backslash);
    StrDeinit(&obj.newline);
    StrDeinit(&obj.tab);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&obj.name);
    return success;
    
    StrDeinit(&json);
    StrDeinit(&obj.name);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    VecDeinit(&obj.filled_items);
    return success;
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    // Cleanup functions
    void AnnSymbolDeinit(AnnSymbol* sym) {
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    void AnnSymbolDeinit(AnnSymbol* sym) {
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    }
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    }
    
    void FunctionInfoDeinit(FunctionInfo* info) {
    StrDeinit(&info->name);
    }
    
    void SearchResultDeinit(SearchResult* result) {
    StrDeinit(&result->binary_name);
    StrDeinit(&result->sha256);
    VecDeinit(&result->tags);
    void SearchResultDeinit(SearchResult* result) {
    StrDeinit(&result->binary_name);
    StrDeinit(&result->sha256);
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    StrDeinit(&result->sha256);
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    }
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    }
    }
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    StrDeinit(&expected_str);
    StrDeinit(&output_clean);
    StrDeinit(&expected_clean);
    return result;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    return success;
    }
    });
    
    StrDeinit(&target_key);
    }
    });
    });
    
    StrDeinit(&source_key);
    });
    });
    }
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    return success;
    }
    
    StrDeinit(&json);
    VecDeinit(&functions);
    return success;
    result.analysis_id  = 999;
    result.sha256       = StrInitFromZstr("abc123");
    result.tags         = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit);
    
    // Create strings and push them properly
    }
    
    StrDeinit(&json);
    SearchResultDeinit(&result);
    return success;
    });
    
    StrDeinit(&target_key);
    });
    });
    
    StrDeinit(&source_key);
    });
    });
    }
    
    StrDeinit(&json);
    VecDeinit(&symbols);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&deep_message);
    StrDeinit(&test_name);
    
    StrDeinit(&json);
    StrDeinit(&deep_message);
    StrDeinit(&test_name);
    return success;
    StrDeinit(&json);
    StrDeinit(&deep_message);
    StrDeinit(&test_name);
    return success;
    }
    VecPushBack(&numbers, num3);
    
    Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
    // Create strings and push them properly
    }
    
    StrDeinit(&json);
    VecDeinit(&numbers);
    VecDeinit(&strings);
    // Cleanup functions
    void TestPersonDeinit(TestPerson* person) {
    StrDeinit(&person->name);
    }
    
    void TestConfigDeinit(TestConfig* config) {
    StrDeinit(&config->log_level);
    VecDeinit(&config->features);
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&original.message);
    StrDeinit(&parsed.message);
    
    StrDeinit(&json);
    StrDeinit(&original.message);
    StrDeinit(&parsed.message);
    return success;
    StrDeinit(&json);
    StrDeinit(&original.message);
    StrDeinit(&parsed.message);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    
    // Cleanup
    StrDeinit(&json);
    StrDeinit(&original.empty);
    StrDeinit(&original.simple);
    // Cleanup
    StrDeinit(&json);
    StrDeinit(&original.empty);
    StrDeinit(&original.simple);
    StrDeinit(&original.with_spaces);
    StrDeinit(&json);
    StrDeinit(&original.empty);
    StrDeinit(&original.simple);
    StrDeinit(&original.with_spaces);
    StrDeinit(&original.with_special);
    StrDeinit(&original.empty);
    StrDeinit(&original.simple);
    StrDeinit(&original.with_spaces);
    StrDeinit(&original.with_special);
    StrDeinit(&parsed.empty);
    StrDeinit(&original.simple);
    StrDeinit(&original.with_spaces);
    StrDeinit(&original.with_special);
    StrDeinit(&parsed.empty);
    StrDeinit(&parsed.simple);
    StrDeinit(&original.with_spaces);
    StrDeinit(&original.with_special);
    StrDeinit(&parsed.empty);
    StrDeinit(&parsed.simple);
    StrDeinit(&parsed.with_spaces);
    StrDeinit(&original.with_special);
    StrDeinit(&parsed.empty);
    StrDeinit(&parsed.simple);
    StrDeinit(&parsed.with_spaces);
    StrDeinit(&parsed.with_special);
    StrDeinit(&parsed.empty);
    StrDeinit(&parsed.simple);
    StrDeinit(&parsed.with_spaces);
    StrDeinit(&parsed.with_special);
    return success;
    StrDeinit(&parsed.simple);
    StrDeinit(&parsed.with_spaces);
    StrDeinit(&parsed.with_special);
    return success;
    }
    // Original data
    Vec(i32) original_numbers = VecInit();
    Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
    // Populate arrays
    // Read back from JSON
    Vec(i32) parsed_numbers = VecInit();
    Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    
    StrIter si = StrIterFromStr(json);
    
    // Cleanup
    StrDeinit(&json);
    VecDeinit(&original_numbers);
    VecDeinit(&original_strings);
    
    // Cleanup
    StrDeinit(&json);
    TestPersonDeinit(&original_person);
    TestPersonDeinit(&parsed_person);
    original.config.timeout    = 30;
    original.config.log_level  = StrInitFromZstr("INFO");
    original.config.features   = VecInitWithDeepCopyT(original.config.features, NULL, StrDeinit);
    
    // Create strings and push them properly
    parsed.config.timeout    = 0;
    parsed.config.log_level  = StrInit();
    parsed.config.features   = VecInitWithDeepCopyT(parsed.config.features, NULL, StrDeinit);
    parsed.numbers           = VecInitT(parsed.numbers);
    parsed.flags             = VecInitT(parsed.flags);
    
    // Cleanup
    StrDeinit(&json);
    ComplexDataDeinit(&original);
    ComplexDataDeinit(&parsed);
    // Original empty data
    Vec(i32) empty_numbers = VecInit();
    Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    Str empty_str          = StrInit();
    // Read back from JSON
    Vec(i32) parsed_numbers = VecInit();
    Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
    Str  parsed_str         = StrInit();
    bool found_empty_object = false;
    
    // Cleanup
    StrDeinit(&json);
    StrDeinit(&empty_str);
    StrDeinit(&parsed_str);
    // Cleanup
    StrDeinit(&json);
    StrDeinit(&empty_str);
    StrDeinit(&parsed_str);
    VecDeinit(&empty_numbers);
    StrDeinit(&json);
    StrDeinit(&empty_str);
    StrDeinit(&parsed_str);
    VecDeinit(&empty_numbers);
    VecDeinit(&empty_strings);
    }
    
    StrDeinit(&json);
    return success;
    }
    
    void AnnSymbolDeinit(AnnSymbol* sym) {
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    void AnnSymbolDeinit(AnnSymbol* sym) {
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    StrDeinit(&sym->analysis_name);
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    }
    StrDeinit(&sym->function_name);
    StrDeinit(&sym->sha256);
    StrDeinit(&sym->function_mangled_name);
    }
    
    void FunctionInfoDeinit(FunctionInfo* info) {
    StrDeinit(&info->name);
    }
    
    void ModelInfoDeinit(ModelInfo* info) {
    StrDeinit(&info->name);
    }
    
    void SearchResultDeinit(SearchResult* result) {
    StrDeinit(&result->binary_name);
    StrDeinit(&result->sha256);
    VecForeach(&result->tags, tag, { StrDeinit(&tag); });
    void SearchResultDeinit(SearchResult* result) {
    StrDeinit(&result->binary_name);
    StrDeinit(&result->sha256);
    VecForeach(&result->tags, tag, { StrDeinit(&tag); });
    VecDeinit(&result->tags);
    StrDeinit(&result->binary_name);
    StrDeinit(&result->sha256);
    VecForeach(&result->tags, tag, { StrDeinit(&tag); });
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    VecForeach(&result->tags, tag, { StrDeinit(&tag); });
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    VecDeinit(&result->tags);
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    }
    StrDeinit(&result->created_at);
    StrDeinit(&result->model_name);
    StrDeinit(&result->owned_by);
    }
    }
    
    StrDeinit(&json);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&data.name);
    return success;
    
    StrDeinit(&json);
    StrDeinit(&data.name);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.user.profile.name);
    StrDeinit(&data.status);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    return success;
    StrDeinit(&json);
    StrDeinit(&data.company.departments.engineering.head);
    StrDeinit(&data.company.name);
    return success;
    }
    }
    
    StrDeinit(&json);
    VecDeinit(&symbols);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&info.name);
    return success;
    
    StrDeinit(&json);
    StrDeinit(&info.name);
    return success;
    }
    }
    
    StrDeinit(&json);
    StrDeinit(&info.name);
    return success;
    
    StrDeinit(&json);
    StrDeinit(&info.name);
    return success;
    }
    result.binary_name  = StrInit();
    result.sha256       = StrInit();
    result.tags         = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit);
    result.created_at   = StrInit();
    result.model_name   = StrInit();
    }
    
    StrDeinit(&json);
    SearchResultDeinit(&result);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    return success;
    }
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    
    StrDeinit(&json);
    StrDeinit(&response.message);
    VecDeinit(&response.data);
    return success;
    bool result = (s.length == 5 && ZstrCompare(s.data, "Hello") == 0);
    
    StrDeinit(&s);
    return result;
    }
    
    // Create a Strs object (vector of strings)
    Strs sv = VecInitWithDeepCopy(NULL, StrDeinit);
    
    // Add some strings
    }
    
    VecDeinit(&sv); // This should call StrDeinit on each element
    return result;
    }
    bool result = true; // If we got here, the validation didn't crash
    
    StrDeinit(&s);
    return result;
    }
    }
    
    StrDeinit(&s);
    return result;
    }
    }
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "nan") == 0);
    
    StrDeinit(&s);
    return result;
    }
    
    // Test hexadecimal conversion with explicit base
    StrDeinit(&s);
    s                     = StrInitFromZstr("ABCD"); // No 0x prefix when base is explicitly 16
    StrParseConfig config = {.base = 16};
    
    // Test hexadecimal conversion (auto-detect base with 0)
    StrDeinit(&s);
    s       = StrInitFromZstr("0xABCD");
    success = StrToU64(&s, &value, NULL);
    
    // Test binary conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("0b101010");
    success = StrToU64(&s, &value, NULL);
    
    // Test octal conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("0o52");
    success = StrToU64(&s, &value, NULL);
    
    // Test zero
    StrDeinit(&s);
    s       = StrInitFromZstr("0");
    success = StrToU64(&s, &value, NULL);
    
    // Test invalid input
    StrDeinit(&s);
    s       = StrInitFromZstr("not a number");
    success = StrToU64(&s, &value, NULL);
    
    // Test negative number (should fail for unsigned)
    StrDeinit(&s);
    s       = StrInitFromZstr("-123");
    success = StrToU64(&s, &value, NULL);
    result  = result && (!success);
    
    StrDeinit(&s);
    return result;
    }
    
    // Test negative decimal conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("-12345");
    success = StrToI64(&s, &value, NULL);
    
    // Test hexadecimal conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("0xABCD");
    success = StrToI64(&s, &value, NULL);
    
    // Test binary conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("0b101010");
    success = StrToI64(&s, &value, NULL);
    
    // Test zero
    StrDeinit(&s);
    s       = StrInitFromZstr("0");
    success = StrToI64(&s, &value, NULL);
    
    // Test invalid input
    StrDeinit(&s);
    s       = StrInitFromZstr("not a number");
    success = StrToI64(&s, &value, NULL);
    result  = result && (!success);
    
    StrDeinit(&s);
    return result;
    }
    
    // Test fractional conversion
    StrDeinit(&s);
    s       = StrInitFromZstr("123.456");
    success = StrToF64(&s, &value, NULL);
    
    // Test negative number
    StrDeinit(&s);
    s       = StrInitFromZstr("-123.456");
    success = StrToF64(&s, &value, NULL);
    
    // Test scientific notation
    StrDeinit(&s);
    s       = StrInitFromZstr("1.23e2");
    success = StrToF64(&s, &value, NULL);
    
    // Test zero
    StrDeinit(&s);
    s       = StrInitFromZstr("0");
    success = StrToF64(&s, &value, NULL);
    
    // Test infinity
    StrDeinit(&s);
    s       = StrInitFromZstr("inf");
    success = StrToF64(&s, &value, NULL);
    
    // Test negative infinity
    StrDeinit(&s);
    s       = StrInitFromZstr("-inf");
    success = StrToF64(&s, &value, NULL);
    
    // Test NaN
    StrDeinit(&s);
    s       = StrInitFromZstr("nan");
    success = StrToF64(&s, &value, NULL);
    
    // Test invalid input
    StrDeinit(&s);
    s       = StrInitFromZstr("not a number");
    success = StrToF64(&s, &value, NULL);
    result  = result && (!success);
    
    StrDeinit(&s);
    return result;
    }
    result        = result && success && (recovered_u64 == u64_values[i]);
    
    StrDeinit(&s);
    }
    result             = result && success && (recovered_i64 == i64_values[i]);
    
    StrDeinit(&s);
    }
    result        = result && success && (fabs(recovered_f64 - f64_values[i]) < tolerance);
    
    StrDeinit(&s);
    }
    }
    result                      = result && success && (recovered == base);
    
    StrDeinit(&s);
    }
    result              = result && success && (recovered_large > 1e299);
    
    StrDeinit(&s);
    
    // Test prefix handling
    bool           success  = StrToU64(&test_str, &value, prefix_tests[i].base == 0 ? NULL : &config);
    result                  = result && success && (value == prefix_tests[i].expected);
    StrDeinit(&test_str);
    }
    }
    
    StrDeinit(&s);
    }
    result     = result && has_E;
    
    StrDeinit(&s);
    }
    result                   = result && success && (recovered == large_value);
    
    StrDeinit(&s);
    }
    result = result && success && (recovered == test_value);
    
    StrDeinit(&s);
    }
    result = result && success && (recovered == test_value);
    
    StrDeinit(&s);
    }
    result = result && success && (recovered == test_values[i]);
    
    StrDeinit(&s);
    
    if (!result)
    result         = result && success && (recovered == test_value);
    
    StrDeinit(&s);
    
    if (!result)
    result = result && success && (fabs(recovered - test_value) < tolerance);
    
    StrDeinit(&s);
    
    if (!result)
    result = result && (success || !success); // Either succeeds or fails gracefully
    
    StrDeinit(&long_str);
    
    return result;
    result = result && (s.capacity < 100) && (s.capacity >= s.length);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (s.data[1] == 'l' && s.data[2] == 'e');
    
    StrDeinit(&s);
    return result;
    }
    result = result && (s.length == 8) && (ZstrCompareN(s.data, "Hel", 3) == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (s.capacity >= 100);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (s.data != NULL);
    
    StrDeinit(&s);
    return result;
    }
    
    // Test with an even-length string
    StrDeinit(&s);
    s = StrInitFromZstr("abcd");
    
    // Test with a single-character string
    StrDeinit(&s);
    s = StrInitFromZstr("a");
    
    // Test with an empty string
    StrDeinit(&s);
    s = StrInit();
    result = result && (s.length == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "?He!llo.") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "He Worldllo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "He Worldllo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s1.data, "He Worldllo") == 0);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    }
    bool result = (ZstrCompare(s.data, "He Worldllo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "He Worldllo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (s2.length == 0 && s2.data == NULL);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    }
    result = result && (s2.length == 6 && ZstrCompare(s2.data, " World") == 0);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    }
    result = result && (s2.length == 6 && ZstrCompare(s2.data, " World") == 0);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello World 2023") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Hel") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "llo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Hlo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Hell") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Hel") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Hlo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    result = result && (ZstrCompare(s.data, "Heo") == 0);
    
    StrDeinit(&s);
    return result;
    }
    
    // Should never reach here if idx goes out of bounds
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    
    // Should never reach here if bounds checking triggers
    StrDeinit(&s);
    return false;
    }
    success = success && (ZstrCompare(output.data, "{{") == 0);
    
    StrDeinit(&output);
    return success;
    }
    StrWriteFmt(&output, "{}", s);
    success = success && (ZstrCompare(output.data, "World") == 0);
    StrDeinit(&s);
    
    StrDeinit(&output);
    StrDeinit(&s);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "0") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "0xDEADBEEF") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "0b10100101") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "0o777") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "2.718280") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "3.1415926536") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "nan") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, " abc ") == 0);
    
    StrDeinit(&output);
    return success;
    }
    success = success && (ZstrCompare(output.data, "3.140000 Hello 42") == 0);
    
    StrDeinit(&output);
    return success;
    }
    output.data[5] == 'Z' && output.data[6] == '1' && output.data[7] == '2');
    
    StrDeinit(&output);
    StrDeinit(&s);
    return success;
    
    StrDeinit(&output);
    StrDeinit(&s);
    return success;
    }
    BitVecDeinit(&bv3);
    BitVecDeinit(&bv_zero);
    StrDeinit(&output);
    return success;
    }
    bool success = (ZstrCompare(result.data, "H0e1l2l3o4") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    }
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    success = success && (ZstrCompare(s.data, "HELLO") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    }
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    bool success = (ZstrCompare(result.data, "Hello") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    }
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    success = success && (ZstrCompare(s.data, "HELLO") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    }
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    success = success && (empty_result.length == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&empty_result);
    
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&empty_result);
    return success;
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&empty_result);
    return success;
    }
    success = success && (ZstrCompare(end_result.data, "World") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&end_result);
    
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&end_result);
    return success;
    StrDeinit(&s);
    StrDeinit(&result);
    StrDeinit(&end_result);
    return success;
    }
    success = success && (ZstrCompare(s.data, "Hello WORLD") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    success = success && (ZstrCompare(s.data, "HELLO World") == 0);
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    
    StrDeinit(&s);
    StrDeinit(&result);
    return success;
    }
    bool result = (first == 'H');
    
    StrDeinit(&s);
    return result;
    }
    bool result = (last == 'o');
    
    StrDeinit(&s);
    return result;
    }
    bool result = (begin == s.data && *begin == 'H');
    
    StrDeinit(&s);
    return result;
    }
    bool result = (end == s.data + s.length && *end == '\0');
    
    StrDeinit(&s);
    return result;
    }
    bool result = (c0 == 'H' && c1 == 'e' && c2 == 'l' && c3 == 'l' && c4 == 'o');
    
    StrDeinit(&s);
    return result;
    }
    result = result && (p0 == s.data && p1 == s.data + 1 && p2 == s.data + 2 && p3 == s.data + 3 && p4 == s.data + 4);
    
    StrDeinit(&s);
    return result;
    }
    
    // Clean up
    StrDeinit(&str);
    BitVecDeinit(&bv);
    Str str_obj = BitVecToStr(&bv);
    result      = result && (str_obj.length == 0);
    StrDeinit(&str_obj);
    
    // Test converting single bit
    result  = result && (str_obj.length == 1);
    result  = result && (StrCmpCstr(&str_obj, "1", 1) == 0);
    StrDeinit(&str_obj);
    
    // Test large conversions
    str_obj = BitVecToStr(&bv);
    result  = result && (str_obj.length == 1000);
    StrDeinit(&str_obj);
    
    BitVecDeinit(&bv);
    result = result && (ZstrCompare(str.data, patterns[i]) == 0);
    
    StrDeinit(&str);
    BitVecDeinit(&bv);
    }
    Str empty_str = BitVecToStr(&empty);
    result        = result && (empty_str.length == 0);
    StrDeinit(&empty_str);
    
    u64 empty_value = BitVecToInteger(&empty);
    Str str = BitVecToStr(&bv);
    result  = result && (ZstrCompare(str.data, test_cases[i].pattern) == 0);
    StrDeinit(&str);
    
    // Test integer conversion (may depend on bit order)
    result = result && cross_match;
    
    StrDeinit(&str1);
    StrDeinit(&str2);
    StrDeinit(&str3);
    
    StrDeinit(&str1);
    StrDeinit(&str2);
    StrDeinit(&str3);
    BitVecDeinit(&bv1);
    StrDeinit(&str1);
    StrDeinit(&str2);
    StrDeinit(&str3);
    BitVecDeinit(&bv1);
    BitVecDeinit(&bv2);
    result = result && pattern_correct;
    
    StrDeinit(&large_str);
    
    // Test byte conversion
    bool result = (s.length == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (s.length == len && ZstrCompareN(s.data, test_str, len) == 0 && s.data[len] == '\0');
    
    StrDeinit(&s);
    return result;
    }
    bool result = (s.length == strlen(test_str) && ZstrCompare(s.data, test_str) == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (dst.length == src.length && ZstrCompare(dst.data, src.data) == 0);
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    }
    bool result = (dst.length == src.length && ZstrCompare(dst.data, src.data) == 0);
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    }
    bool result = (ZstrCompare(s.data, "Hello, World!") == 0);
    
    StrDeinit(&s);
    return result;
    }
    bool result = (success && dst.length == src.length && ZstrCompare(dst.data, src.data) == 0);
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    
    StrDeinit(&src);
    StrDeinit(&dst);
    return result;
    }
    // Test StrDeinit function
    bool test_str_deinit(void) {
    printf("Testing StrDeinit\n");
    
    Str s = StrInitFromZstr("Hello, World!");
    
    // Deinit the string
    StrDeinit(&s);
    
    // Check that the string is deinited correctly
    Str expected = StrInitFromZstr("Hello");
    success      = success && (StrCmp(&s, &expected) == 0);
    StrDeinit(&expected);
    StrClear(&s);
    expected = StrInitFromZstr("Hello, World!");
    success  = success && (StrCmp(&s, &expected) == 0);
    StrDeinit(&expected);
    
    StrDeinit(&s);
    StrDeinit(&expected);
    
    StrDeinit(&s);
    
    return success;
    Str expected = StrInitFromZstr("Alice");
    success      = success && (StrCmp(&name, &expected) == 0);
    StrDeinit(&expected);
    StrClear(&name);
    expected = StrInitFromZstr("Bob");
    success  = success && (StrCmp(&name, &expected) == 0);
    StrDeinit(&expected);
    
    StrDeinit(&name);
    StrDeinit(&expected);
    
    StrDeinit(&name);
    
    return success;
    printf("str_val test: comparing with 'Hello', pass = %s\n", str_pass ? "true" : "false");
    success = success && str_pass;
    StrDeinit(&expected);
    StrDeinit(&str_val);
    success = success && str_pass;
    StrDeinit(&expected);
    StrDeinit(&str_val);
    
    // Test :c with quoted strings (should work like regular string reading)
    printf("quoted str_val test: comparing with 'World', pass = %s\n", quoted_str_pass ? "true" : "false");
    success = success && quoted_str_pass;
    StrDeinit(&expected);
    StrDeinit(&str_val);
    success = success && quoted_str_pass;
    StrDeinit(&expected);
    StrDeinit(&str_val);
    
    printf("Overall success: %s\n", success ? "true" : "false");
    success = success && test1_pass;
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    success = success && test2_pass;
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    success = success && test3_pass;
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    success = success && test4_pass;
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    success = success && test5_pass;
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    
    StrDeinit(&expected);
    StrDeinit(&result);
    }
    (ZstrCompare(result1.data, "10110") == 0) ? "true" : "false"
    );
    StrDeinit(&result1);
    BitVecDeinit(&bv1);
    (ZstrCompare(result4.data, "1101") == 0) ? "true" : "false"
    );
    StrDeinit(&result4);
    BitVecDeinit(&bv4);
    (ZstrCompare(result5.data, "0") == 0) ? "true" : "false"
    );
    StrDeinit(&result5);
    BitVecDeinit(&bv5);
    result   = result && (cmp5 != 0);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    StrDeinit(&s3);
    
    StrDeinit(&s1);
    StrDeinit(&s2);
    StrDeinit(&s3);
    StrDeinit(&s4);
    StrDeinit(&s1);
    StrDeinit(&s2);
    StrDeinit(&s3);
    StrDeinit(&s4);
    return result;
    StrDeinit(&s2);
    StrDeinit(&s3);
    StrDeinit(&s4);
    return result;
    }
    result             = result && (found5 != NULL && ZstrCompareN(found5, "World", 3) == 0);
    
    StrDeinit(&haystack);
    StrDeinit(&needle1);
    StrDeinit(&needle2);
    
    StrDeinit(&haystack);
    StrDeinit(&needle1);
    StrDeinit(&needle2);
    StrDeinit(&needle3);
    StrDeinit(&haystack);
    StrDeinit(&needle1);
    StrDeinit(&needle2);
    StrDeinit(&needle3);
    return result;
    StrDeinit(&needle1);
    StrDeinit(&needle2);
    StrDeinit(&needle3);
    return result;
    }
    result = result && !StrEndsWithCstr(&s, "ello", 4);
    
    StrDeinit(&s);
    StrDeinit(&prefix);
    StrDeinit(&suffix);
    
    StrDeinit(&s);
    StrDeinit(&prefix);
    StrDeinit(&suffix);
    return result;
    StrDeinit(&s);
    StrDeinit(&prefix);
    StrDeinit(&suffix);
    return result;
    }
    
    // Test multiple replacements
    StrDeinit(&s1);
    s1 = StrInitFromZstr("Hello Hello Hello");
    StrReplaceZstr(&s1, "Hello", "Hi", 2);
    
    // Test StrReplaceCstr - use the full "World" string instead of just "Wo"
    StrDeinit(&s1);
    s1 = StrInitFromZstr("Hello World");
    StrReplaceCstr(&s1, "World", 5, "Universe", 8, 1);
    
    // Test StrReplace
    StrDeinit(&s1);
    s1          = StrInitFromZstr("Hello World");
    Str find    = StrInitFromZstr("World");
    result = result && (ZstrCompare(s1.data, "Hello Universe") == 0);
    
    StrDeinit(&s1);
    StrDeinit(&find);
    StrDeinit(&replace);
    
    StrDeinit(&s1);
    StrDeinit(&find);
    StrDeinit(&replace);
    return result;
    StrDeinit(&s1);
    StrDeinit(&find);
    StrDeinit(&replace);
    return result;
    }
    
    VecDeinit(&iters);
    StrDeinit(&s);
    return result;
    }
    Str  stripped = StrLStrip(&s1, NULL);
    bool result   = (ZstrCompare(stripped.data, "Hello  ") == 0);
    StrDeinit(&stripped);
    
    // Test StrRStrip
    stripped = StrRStrip(&s1, NULL);
    result   = result && (ZstrCompare(stripped.data, "  Hello") == 0);
    StrDeinit(&stripped);
    
    // Test StrStrip
    stripped = StrStrip(&s1, NULL);
    result   = result && (ZstrCompare(stripped.data, "Hello") == 0);
    StrDeinit(&stripped);
    
    // Test with custom strip characters
    
    // Test with custom strip characters
    StrDeinit(&s1);
    s1 = StrInitFromZstr("***Hello***");
    stripped = StrLStrip(&s1, "*");
    result   = result && (ZstrCompare(stripped.data, "Hello***") == 0);
    StrDeinit(&stripped);
    
    stripped = StrRStrip(&s1, "*");
    stripped = StrRStrip(&s1, "*");
    result   = result && (ZstrCompare(stripped.data, "***Hello") == 0);
    StrDeinit(&stripped);
    
    stripped = StrStrip(&s1, "*");
    stripped = StrStrip(&s1, "*");
    result   = result && (ZstrCompare(stripped.data, "Hello") == 0);
    StrDeinit(&stripped);
    
    StrDeinit(&s1);
    StrDeinit(&stripped);
    
    StrDeinit(&s1);
    return result;
    }

Share :