StrInit
Description
Initialize a Str. Inside a Scope block the allocator argument may be omitted; the internal MisraScope allocator is used. Otherwise pass a typed allocator handle or a raw Allocator *.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Log.h:43:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:67:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:90:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:125:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:154:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:182:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Proc.h:286:
#define ProcReadFromStdoutFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStdout((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:313:
#define ProcReadFromStderrFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStderr((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:340:
#define ProcWriteToStdinFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
ProcWriteToStdin((p), &UNPL(buf)); \- In
Proc.h:365:
#define ProcWriteToStdinFmtLn(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
StrPushBackR(&UNPL(buf), '\n'); \- In
JSON.h:249:
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \- In
JSON.h:272:
do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
- In
JSON.h:570:
\
\
Str key = StrInit(); \
\
/* key start */ \
- In
VecStr.c:27:
// treats as a fatal arg violation. An empty source clones to an
// empty fresh Str.
Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
*(Str *)dst_ptr = copy;- In
VecStr.c:46:
// Create Str with capacity
Str str = StrInit(alloc);
// Fill with data or generate simple pattern if not enough input
- In
Log.c:54:
HeapAllocator h = HeapAllocatorInit();
Str full = StrInit(&h);
StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (Zstr)NAMES[type], (Zstr)tag, line, (Zstr)msg);- In
Log.c:67:
StackFrame frames[32];
size n = CaptureStackTrace(frames, 32, 1);
Str trace = StrInit(&h);
// FormatStackTrace takes `Allocator *` -- legitimate erasure
// boundary; pass at the call site, no intermediate variable.
- In
ArgParse.c:326:
// Usage line: "usage: name [OPTIONS] --req <REQ>... <POS>..."
Str usage = StrInit(self->alloc);
StrPushBackMany(&usage, "usage: ");
StrPushBackMany(&usage, self->name);- In
ArgParse.c:374:
n_specs = 64;
for (u64 i = 0; i < n_specs; ++i) {
left_col[i] = StrInit(self->alloc);
left_w[i] = spec_format_left(VecPtrAt(&self->specs, i), &left_col[i]);
if (left_w[i] > max_w)- In
Io.c:499:
// sense. Library-internal scratch keeps the debug-build instrumentation.
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = str_append_fmt(&tmp, fmt, args, argc);
if (ok) {- In
Io.c:532:
}
out = StrInit(&scratch);
ok = str_append_fmt(&out, fmtstr, argv, argc);- In
Io.c:1106:
// DefaultAllocator: rendered size is caller-controlled (open-ended).
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = render_binary_fmt(&tmp, fmtstr, argv, argc);
if (ok) {- In
Io.c:1136:
}
Str buffer = StrInit(&scratch);
i32 fd = FileFd(file);- In
Io.c:1370:
}
*out = StrInit(alloc);
if (!float_try_to_str(&canonical, value, alloc)) {- In
Io.c:1387:
u64 frac = 0;
result = StrInit(alloc);
if (StrBegin(&canonical)[0] == '-') {- In
Io.c:1466:
}
*out = StrInit(alloc);
if (!int_try_to_str(&digits, &value->significand, alloc)) {- In
Io.c:1472:
}
result = StrInit(alloc);
if (FloatIsZero(value)) {- In
Io.c:2997:
allocator_ptr = arg->allocator;
previous = *out;
temp = StrInit(allocator_ptr);
default_fmt = fmt_info ? *fmt_info :- In
Io.c:3406:
}
temp = StrInit(FloatAllocator(value));
parsed = FloatInit(FloatAllocator(value));- In
Str.c:96:
}
*out = StrInit(alloc);
if (len == 0) {
return true;- In
Str.c:112:
Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
Str result = StrInit(alloc);
// Try-form leaves `result` empty-but-valid on OOM, so the caller
- In
Str.c:143:
MemSet(dst, 0, sizeof(Str));
*dst = StrInit(clone_allocator);
dst->copy_init = src->copy_init;
dst->copy_deinit = src->copy_deinit;- In
Str.c:979:
// Borrowed substring view: data points into the caller's bytes and
// capacity stays 0 so StrToU64 never tries to grow it.
Str temp_str = StrInit(str->allocator);
temp_str.data = str->data + pos;
temp_str.length = str->length - pos;- In
Int.c:699:
if (!int_try_to_str(&result, value, alloc)) {
result = StrInit(alloc);
}- In
Int.c:756:
}
*out = StrInit(alloc);
if (!int_validate_radix(radix)) {- In
Int.c:771:
}
result = StrInit(alloc);
// Extract digits in the largest radix^k chunk that still fits in a u64, so
- In
Int.c:862:
if (!int_try_to_str_radix(&result, value, radix, uppercase, alloc)) {
result = StrInit(alloc);
}- In
Float.c:504:
ValidateFloat(out);
result = FloatInit(FloatAllocator(out));
digits = StrInit(FloatAllocator(out));
if (pos < length && (text[pos] == '+' || text[pos] == '-')) {- In
Float.c:645:
}
*out = StrInit(alloc);
if (FloatIsZero(value)) {- In
Float.c:655:
}
result = StrInit(alloc);
if (value->negative) {- In
Float.c:725:
if (!float_try_to_str(&result, value, alloc)) {
result = StrInit(alloc);
}- In
BitVec.c:893:
}
*out = StrInit(alloc);
if (bv->length == 0) {
return true;- In
BitVec.c:906:
if (!StrPushBackR(out, bit_char)) {
StrDeinit(out);
*out = StrInit(alloc);
return false;
}- In
BitVec.c:918:
if (!bitvec_try_to_str(&result, bv, alloc)) {
result = StrInit(alloc);
}- In
Debug.c:283:
return;
}
Str rendered = StrInit(meta);
#if !defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE
FormatStackTrace(&rendered, frames, count, meta); // Returns true on success; `out` is populated with an opened Elf.
static bool try_open_sidecar(Zstr main_path, const Elf *main, Elf *out, Allocator *alloc) {
Str path = StrInit(alloc);
// (1) Build-ID
- In
PdbCache.c:36:
// (1) exact CodeView path
*out_path = StrInit(StrAllocator(out_path));
StrPushBackMany(out_path, cv->pdb_path);
if (sys_path_exists(StrBegin(out_path)))- In
PdbCache.c:69:
return true;
Str pdb_path = StrInit(alloc);
if (!find_pdb(&entry->pe, StrBegin(&entry->module_path), &pdb_path)) {
StrDeinit(&pdb_path);- In
Dns.c:155:
static void parse_hosts_path(HostsTable *table, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {
StrDeinit(&buf);- In
Dns.c:250:
static void parse_resolv_path(DnsAddrs *out, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {
StrDeinit(&buf);- In
Dns.c:343:
if (!self || !path)
return false;
Str buf = StrInit(self->allocator);
StrPushBackMany(&buf, path, len);
bool ok = dns_add_path(self, StrBegin(&buf), do_hosts, do_resolv);- In
Socket.c:459:
Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
Str out = StrInit(alloc);
if (!addr || addr->length == 0) {
return out;- In
MachoCache.c:83:
}
Str path = StrInit(alloc);
if (!compose_dsym_path(StrBegin(&e->module_path), &path)) {
StrDeinit(&path);- In
Proc.c:224:
PROCESS_INFORMATION pi = {0};
Str cmdline = StrInit(alloc);
StrPushBackMany(&cmdline, filepath);
for (char **arg = argv + 1; *arg; ++arg) {- In
DwarfInfo.c:526:
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);
out->string_pool = StrInit(alloc);
if (!info_bytes || info_size == 0)- In
Dns.c:177:
// Decode one resource record. Advances the iter past the record.
static bool decode_record(BufIter *it, DnsRecord *rec, Allocator *alloc) {
rec->name = StrInit(alloc);
rec->target = StrInit(alloc);
rec->rdata = VecInitT(rec->rdata, alloc);- In
Dns.c:178:
static bool decode_record(BufIter *it, DnsRecord *rec, Allocator *alloc) {
rec->name = StrInit(alloc);
rec->target = StrInit(alloc);
rec->rdata = VecInitT(rec->rdata, alloc);
MemSet(rec->ipv4, 0, sizeof(rec->ipv4));- In
Dns.c:297:
// Skip echoed question section: each question is qname + qtype(2) + qclass(2).
for (u16 i = 0; i < qd; ++i) {
Str dummy = StrInit(alloc);
if (!decode_name(&it, &dummy)) {
StrDeinit(&dummy);- In
KvConfig.c:283:
char c;
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:284:
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:359:
if (!value) {
return StrInit(MapAllocator(cfg));
}- In
KvConfig.c:369:
if (!value) {
return StrInit(MapAllocator(cfg));
}- In
Pdb.c:707:
out->data = taken;
out->functions = VecInitT(out->functions, BufAllocator(&taken));
out->name_pool = StrInit(BufAllocator(&taken));
u32 num_dir_bytes = 0;- In
ProcMaps.c:230:
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);- In
ProcMaps.c:261:
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);
if (!FileIsOpen(f)) {- In
ProcMaps.c:281:
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);
if (len) {- In
Http.c:43:
const HttpHeader *src = (const HttpHeader *)src_ptr;
dst->key = StrInit((Allocator *)alloc);
dst->value = StrInit((Allocator *)alloc);- In
Http.c:44:
dst->key = StrInit((Allocator *)alloc);
dst->value = StrInit((Allocator *)alloc);
if (!StrInitCopy(&dst->key, &src->key)) {- In
Http.c:115:
Allocator *alloc = req->allocator;
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);- In
Http.c:116:
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);
StrReadFmt(cursor, "{} {} {}\r\n", method, req->url, version);- In
Http.c:432:
response->content_type = content_type;
StrDeinit(&response->body);
response->body = StrInit(response->allocator);
if (FileReadAndClose(filepath, &response->body) < 0) {
LOG_ERROR("failed to read file: {}", filepath);- In
Http.c:454:
Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);
if (!response) {- In
Http.c:491:
LOG_ERROR("HttpResponseSerialize: failed to append body");
StrDeinit(&out);
return StrInit(alloc);
}
}- In
JSON.c:54:
}
Str key = StrInit(&scratch);
// key start
- In
JSON.c:311:
// stack-backed buffer is unsafe -- DefaultAllocator is the right fit.
DefaultAllocator scratch = DefaultAllocatorInit();
Str ns = StrInit(&scratch);
bool is_neg = false;- In
JSON.c:637:
// valid input. DefaultAllocator is the right fit here.
DefaultAllocator scratch = DefaultAllocatorInit();
Str s = StrInit(&scratch);
si = JReadString(si, &s);
StrDeinit(&s);- In
Dwarf.c:547:
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);
out->string_pool = StrInit(alloc);
const ElfSection *line_section = ElfFindSection(elf, ".debug_line");- In
Beam.c:249:
static void log_request_summary(Zstr client_addr, Zstr prefix_bytes, size prefix_len) {
Scope(scope, DefaultAllocator) {
Str raw = StrInit(scope);
StrPushBackMany(&raw, prefix_bytes);- In
File.c:50:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:84:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:266:
File r = FileOpen(&path, "rb");
ok = ok && FileIsOpen(&r);
Str body = StrInit(alloc_base);
i64 got = FileRead(&r, &body);
FileClose(&r);- In
File.c:300:
File r = FileOpen(&path, "rb");
Str body = StrInit(alloc_base);
i64 got = FileRead(&r, &body);
FileClose(&r);- In
File.c:338:
bool ok = (wrote == (i64)n);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;- In
File.c:367:
FileRemove(&path);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
bool ok = (got == -1);- In
File.c:430:
// Confirm the write landed.
Str body = StrInit(alloc_base);
File r = FileOpen(&path, "rb");
i64 got = FileRead(&r, &body);- In
File.c:528:
FileClose(&owner);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 10) && ZstrCompare(StrBegin(&body), "helloworld") == 0;- In
File.c:754:
ok = ok && (FileSeek(&f, 10, FILE_SEEK_SET) == 10);
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:785:
File f = FileOpen(&path, "rb");
ok = ok && FileIsOpen(&f);
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:873:
bool ok = (wrote == (i64)n);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;- In
File.c:903:
ok = ok && (wrote == 0);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);- In
File.c:937:
ok = ok && (wrote == 5);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 5) && ZstrCompare(StrBegin(&body), "12345") == 0;- In
File.c:965:
FileClose(&seed);
Str in = StrInit(alloc_base);
StrAppendFmt(&in, "string-content");- In
File.c:971:
bool ok = (wrote == (i64)StrLen(&in));
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)StrLen(&in)) && ZstrCompare(StrBegin(&body), "string-content") == 0;- In
File.c:1040:
FileClose(&f2);
Str b1 = StrInit(alloc_base);
Str b2 = StrInit(alloc_base);
ok = ok && (FileReadAndClose(&p1, &b1) == 3) && ZstrCompare(StrBegin(&b1), "one") == 0;- In
File.c:1041:
Str b1 = StrInit(alloc_base);
Str b2 = StrInit(alloc_base);
ok = ok && (FileReadAndClose(&p1, &b1) == 3) && ZstrCompare(StrBegin(&b1), "one") == 0;
ok = ok && (FileReadAndClose(&p2, &b2) == 6) && ZstrCompare(StrBegin(&b2), "twotwo") == 0;- In
File.c:1168:
// The file was truncated to empty.
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);- In
AllocDebug.c:124:
// counted as a leak by the very report we're about to generate.
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
// Build the out-of-range marker "#N " that only the `<=` mutant emits.
Str ns = StrInit(&scratch);
StrAppendFmt(&ns, "#{} ", n);- In
ArgParse.c:255:
ArgParse p = ArgParseInit("prog", NULL, &a);
Str name = StrInit(&a);
ArgOptional(&p, NULL, "--name", &name, "n");- In
ArgParse.c:616:
// ---------------------------------------------------------------------------
static void capture_help(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- In
ArgParse.c:637:
static bool help_equals(ArgParse *p, Zstr expected) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(&a);
capture_help(p, &out);
bool ok = (StrLen(&out) == ZstrLen(expected)) && (ZstrCompare(StrBegin(&out), expected) == 0);- In
ArgParse.c:851:
DefaultAllocator a2 = DefaultAllocatorInit();
Str out = StrInit(&a2);
capture_help(&p, &out);- In
ArgParse.c:887:
// read it back into `out`. Returns true on a clean ARG_RUN_HELP capture.
static bool capture_help_file(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- In
ArgParse.c:1149:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Str name = StrInit(&a);
StrPushBackMany(&name, "stale");
ArgOptional(&p, NULL, "--name", &name, "n");- In
ArgParse.c:1271:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<LISTEN>");- In
ArgParse.c:1287:
Zstr v = NULL;
ArgRequired(&p, NULL, "--read-only", &v, "mode");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<READ_ONLY>");- In
ArgParse.c:1303:
Zstr v = NULL;
ArgRequired(&p, NULL, "--port", &v, "p");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The metavar is "<PORT>", never "<__PORT>".
- In
ArgParse.c:1319:
Zstr v = NULL;
ArgRequired(&p, "-x", NULL, &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<VALUE>");- In
ArgParse.c:1335:
Zstr v = NULL;
ArgRequired(&p, NULL, "--ip6", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<IP6>");- In
ArgParse.c:1352:
Zstr v = NULL;
ArgRequired(&p, NULL, "--gzip", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// "gzip" -> "GZIP": the trailing 'z' in the middle must be upper.
- In
ArgParse.c:1369:
Zstr v = NULL;
ArgRequired(&p, NULL, "--abc", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<ABC>");- In
ArgParse.c:1388:
Zstr s = NULL;
ArgPositional(&p, "source", &s, "from");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<source>");- In
ArgParse.c:1403:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "-l, --listen");- In
ArgParse.c:1419:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// Full left column for this spec: two-space indent, short, ", ",
- In
ArgParse.c:1437:
u32 t = 0;
ArgOptional(&p, NULL, "--timeout", &t, "secs");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// No short form: rendered as four spaces then the long name.
- In
ArgParse.c:1453:
bool f = false;
ArgFlag(&p, "-v", "--verbose", &f, "v");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The verbose flag must appear but with no "<VERBOSE>" metavar.
- In
ArgParse.c:1475:
ArgFlag(&p, "-a", "--a", &aa, "AAA");
ArgRequired(&p, NULL, "--a-very-long-option-name", &bb, "BBB");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The short flag "--a" help ("AAA") must be padded so it starts at
- In
ArgParse.c:1774:
// ---------------------------------------------------------------------------
static ArgRun capture_run(ArgParse *p, int argc, char **argv, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- In
ArgParse.c:1824:
char *argv[] = {(char *)"prog", (char *)"first", (char *)"extra"};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 3, argv, &out);- In
ArgParse.c:1849:
char *argv[] = {(char *)"prog"};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 1, argv, &out);- In
ArgParse.c:1892:
char *argv[] = {(char *)"prog", tok};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 2, argv, &out);- In
DateTime.c:146:
static bool test_iso_write_utc(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC, 0);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:157:
static bool test_iso_write_offset(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC, IST);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:168:
static bool test_iso_write_nanos(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC + 123456789ull, 0);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:180:
static bool test_iso_io_roundtrip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime a = DateTimeFromUnixNs(T_2021 * NS_PER_SEC + 123456789ull, MST);
StrAppendFmt(&s, "{}", a);- In
Type.c:288:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "1E2");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Type.c:353:
Float b = FloatFromStr("0.1", &alloc.base); // exp -1
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);
FloatAdd(&r, &a, &b);- In
Type.c:375:
Float z = FloatFromStr("0", &alloc.base); // exp 0, zero
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);
FloatAdd(&r, &a, &z);- In
Math.c:77:
Float value = FloatFromStr("12.5", &alloc.base);
Str text = StrInit(&alloc.base);
FloatNegate(&value);- In
Math.c:103:
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:126:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:150:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:198:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:221:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:245:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:288:
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:311:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:335:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:378:
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 3);- In
Math.c:401:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 0);- In
Math.c:425:
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 1);- In
Math.c:499:
Float b = FloatFromStr("5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:527:
Float b = FloatFromStr("-5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:553:
Float b = FloatFromStr("1.00", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:860:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "+5");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Math.c:882:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "19");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Math.c:902:
Float b = FloatFromStr("3", &alloc.base);
Float quotient = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool ok = FloatDiv("ient, &a, &b, 8);- In
Convert.c:107:
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
bool result = FloatToInt(&result_value, &value);- In
Convert.c:827:
Float v = FloatFromStr("12.5", &dbg.base);
Str out = StrInit(&dbg.base);
bool ok = FloatTryToStr(&out, &v);- In
Convert.c:842:
Float v = FloatFromStr("1200", &dbg.base); // exponent >= 0 arm
Str out = StrInit(&dbg.base);
bool ok = FloatTryToStr(&out, &v);
// Pattern "101" as a Str on a separate (untracked) allocator.
Str pattern = StrInit(pbase);
StrPushBackR(&pattern, '1');
StrPushBackR(&pattern, '0');- In
Math.c:114:
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &a, &b);- In
Math.c:139:
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &base, &rhs);- In
Math.c:192:
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntSub(&result_value, &base, &rhs);- In
Math.c:266:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntMul(&result_value, &value, 25u);- In
Math.c:327:
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntPow(&result_value, &base, 20u);- In
Math.c:354:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97u);- In
Math.c:395:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntDivExact(&result_value, ÷nd, 90u);- In
Math.c:435:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97);- In
Math.c:905:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:2447:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
bool ok = int_div_mod_u64("ient, &remainder, ÷nd, 97u);- In
Math.c:2477:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
bool ok = int_div_mod_i64("ient, &remainder, ÷nd, (i64)13);- In
UserTypes.c:131:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = 3, .y = 4};- In
UserTypes.c:146:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = -1, .y = 2};- In
UserTypes.c:173:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D src = {.x = 100, .y = -200};- In
UserTypes.c:192:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds b = {- In
UserTypes.c:210:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds src = {- In
UserTypes.c:234:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region r = {- In
UserTypes.c:253:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region src = {- In
UserTypes.c:280:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region region = {- In
Write.c:42:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:70:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:110:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:182:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:203:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:220:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:237:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:259:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:285:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:312:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:350:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:374:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:534:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:598:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:644:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;
Float exact = FloatFromStr("1234567890.012345", alloc_base);- In
Write.c:682:
bool test_str_write_fmt_clears(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));- In
Write.c:697:
bool test_str_patch_fmt(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "AAAAAAAA");
size before_length = StrLen(&s);- In
Write.c:720:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Buf b = BufInit(&alloc);- In
Write.c:743:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:910:
bool test_datetime_iso_write(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
bool ok = true;
u64 base = 1609459200ull * 1000000000ull; // 2021-01-01T00:00:00Z
- In
Write.c:1013:
bool ok = false;
if (FileIsOpen(&f)) {
Str back = StrInit(&alloc);
FileRead(&f, &back);
ok = (ZstrCompare(StrBegin(&back), expect) == 0);- In
Write.c:1085:
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"";
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));- In
Write.c:1185:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1210:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1229:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1232:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x0F); // single byte 0x0F -> "f"
- In
Write.c:1249:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1252:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x0F);- In
Write.c:1270:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1273:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x01);
StrPushBackR(&s, (char)0x02);- In
Write.c:1292:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1295:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x05);- In
Write.c:1312:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1330:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1519:
static bool test_m13_zstr_hex_multibyte(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "AB"; // 0x41 0x42
- In
Write.c:1535:
static bool test_m13_zstr_hex_single_byte(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Z"; // 0x5a
- In
Write.c:1552:
static bool test_m13_zstr_hex_lowercase_letters(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xab"; // single byte 0xab
- In
Write.c:1569:
static bool test_m13_zstr_hex_uppercase_letters(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xab";- In
Write.c:1585:
static bool test_m13_zstr_hex_zero_pad_nibble(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\x05"; // single byte 0x05
- In
Write.c:1600:
static bool test_m13_zstr_hex_no_pad_two_digits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xfe";- In
Write.c:1616:
static bool test_m13_zstr_precision_truncate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1632:
static bool test_m13_zstr_precision_longer_noop(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1649:
static bool test_m13_zstr_precision_zero_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1665:
static bool test_m13_zstr_precision_one(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1684:
static bool test_m13_zstr_pad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1699:
static bool test_m13_zstr_left_pad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1714:
static bool test_m13_zstr_empty_padded(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "";- In
Write.c:1979:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("1.0", alloc_base);- In
Write.c:1999:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);- In
Write.c:2021:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);- In
Write.c:2042:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12.0", alloc_base);- In
Write.c:2062:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:2557:
static bool test_m24_zero_pad_positive_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2579:
static bool test_m24_zero_pad_width_equals_content_no_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2605:
static bool test_m24_zero_pad_negative_sign_kept_ahead(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2634:
static bool test_m24_zero_pad_positive_no_sign_shift(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2662:
static bool test_m24_zero_pad_negative_wide(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2687:
static bool test_m24_zero_pad_hex_width16_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2823:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2843:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2861:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2883:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2906:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2927:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2950:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", &alloc.base);- In
Write.c:2970:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("0.001", &alloc.base);- In
Write.c:2989:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("1e12", &alloc.base);- In
Write.c:3079:
static bool test_m28_i64_hex_lower(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 255; // 0xff
- In
Write.c:3094:
static bool test_m28_i64_hex_upper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 255;- In
Write.c:3108:
static bool test_m28_i64_binary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 5; // 0b101
- In
Write.c:3121:
static bool test_m28_i64_octal(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 8; // 0o10
- In
Write.c:3135:
static bool test_m28_i64_decimal_negative(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = -42;- In
Write.c:3148:
static bool test_m28_i64_width_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 42;- In
Write.c:3163:
static bool test_m28_i64_zeropad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 42;- In
Write.c:3228:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int a = IntFrom(0x41, alloc_base); // 'A'
bool success = true;- In
Write.c:3247:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int a = IntFrom(0x7a, alloc_base); // 'z'
bool success = true;- In
Write.c:3272:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int seven = IntFrom(7, alloc_base);
bool success = true;- In
Write.c:3294:
static bool test_m3_unclosed_brace_fails(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i32 v = 5;- In
Write.c:3312:
static bool test_m3_raw_u8(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u8 v = 200;- In
Write.c:3332:
static bool test_m3_raw_u16(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u16 v = 258;- In
Write.c:3352:
static bool test_m3_raw_u32(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 65538;- In
Write.c:3372:
static bool test_m3_raw_u64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 4294967298ULL;- In
Write.c:3391:
static bool test_m3_raw_i64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 4294967298LL;- In
Write.c:3410:
static bool test_m3_raw_f64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;- In
Write.c:3432:
static bool test_m30_u64_width_pad_with_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3453:
static bool test_m30_u64_width_pad_no_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3475:
static bool test_m30_u64_zero_pad_with_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3632:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:3651:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:3676:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.2", alloc_base);- In
Write.c:3717:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("1", alloc_base);- In
Write.c:3840:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Zstr name = "hello";- In
Write.c:3856:
static bool test_m33_i8_char_emits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
i8 v = (i8)'Q';- In
Write.c:3873:
static bool test_m33_f32_char_emits_four_bytes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
// Choose a bit pattern whose 4 bytes are all printable: 0x42434445 -> "BCDE".
- In
Write.c:3958:
bool test_if_1230_hex_low_nibble_digit_selection(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3965:
// write_int_as_chars path instead), so render a Str holding the byte 0x1A.
// 0x1A: hi nibble 0x01 (<10 -> '1'), low nibble 0x0A (>=10 -> 'a') => "\x1a".
Str src = StrInit(&alloc);
StrPushBackR(&src, 0x1A);
StrAppendFmt(&out, "{c}", src);- In
Write.c:3996:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4026:
bool test_if_238_zero_pad_exact_width_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4052:
bool test_if_257_space_pad_exact_width_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4114:
bool test_if_514_patch_fmt_behaviour(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
bool ok = true;- In
Write.c:4139:
bool test_if_1703_str_zero_width_no_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4163:
bool test_if_2067_f64_default_and_explicit_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4190:
static bool test_m4_seekable_position_advance(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "42 zzzzzzz", 10);
bool ok = FileIsOpen(&f);- In
Write.c:4215:
static bool test_m4_cur_pos_from_probe(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "7", 1);
bool ok = FileIsOpen(&f);- In
Write.c:4240:
static bool test_m4_consumed_offset_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "53 and more text", 16);
bool ok = FileIsOpen(&f);- In
Write.c:4655:
static bool test_m8_zero_pad_width5(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4675:
static bool test_m8_zero_pad_width7_double_zero(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4692:
static bool test_m8_zero_pad_width9(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4714:
static bool test_m8_width9_space_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4739:
static bool test_m8_precision9_string(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4771:
#define DBG_BEGIN(dbg, out) \
DebugAllocator dbg = DebugAllocatorInit(); \
Str out = StrInit(&dbg)
#define LEAK_CFG \- In
Write.c:4779:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG); \
Allocator *adbg = ALLOCATOR_OF(&dbg); \
Str out = StrInit(adbg); \
bool ok = true- In
Write.c:4806:
static bool test_pfs_zero_pad_detect(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 7;
StrAppendFmt(&out, "{05}", v);- In
Write.c:4820:
static bool test_pfs_width_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "ab";
StrAppendFmt(&out, "{4}", s);- In
Write.c:4839:
static bool test_pfs_precision_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 3.14159;
StrAppendFmt(&out, "{.2}", v);- In
Write.c:4856:
static bool test_pfs_dot_no_digit_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "literal");
i32 v = 5;- In
Write.c:4874:
static bool test_pad_zeros_signed(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i32 v = -7;
StrAppendFmt(&out, "{05}", v);- In
Write.c:4891:
static bool test_pad_zeros_exact_and_under(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 123;
StrAppendFmt(&out, "{03}", v);- In
Write.c:4907:
static bool test_strpad_exact_and_under(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "abc";
StrAppendFmt(&out, "{3}", s);- In
Write.c:4923:
static bool test_brace_escape_open(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "a{{b");
bool ok = (ZstrCompare(StrBegin(&out), "a{b") == 0);- In
Write.c:4934:
static bool test_brace_escape_close(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "a}}b");
bool ok = (ZstrCompare(StrBegin(&out), "a}b") == 0);- In
Write.c:4946:
static bool test_brace_scan_close(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 0xAB;
StrAppendFmt(&out, "{x}", v);- In
Write.c:4962:
static bool test_raw_write_u16_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u16 v = 0x1234; // 4660
bool rc = StrAppendFmt(&out, "{<2r}", v);- In
Write.c:4975:
static bool test_raw_write_u64_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 0x0102030405060708ULL; // 72623859790382856
bool rc = StrAppendFmt(&out, "{>8r}", v);- In
Write.c:4990:
static bool test_fwrite_roundtrip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Write.c:4998:
File r = FileOpen(StrBegin(&path), "r");
if (FileIsOpen(&r)) {
Str back = StrInit(&alloc);
FileRead(&r, &back);
ok = ok && (ZstrCompare(StrBegin(&back), "n=42\n") == 0);- In
Write.c:5019:
static bool test_fwrite_empty_skipped(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Write.c:5029:
File r = FileOpen(StrBegin(&path), "r");
if (FileIsOpen(&r)) {
Str back = StrInit(&alloc);
FileRead(&r, &back);
ok = ok && (ZstrCompare(StrBegin(&back), "X") == 0);- In
Write.c:5066:
static bool test_str_hex_no_leak(void) {
DBG_BEGIN(dbg, out);
Str s = StrInit(&dbg);
StrPushBackR(&s, (char)0x01);
StrPushBackR(&s, (char)0x4F); // multi-digit so StrLen(&hex)!=1 path
- In
Write.c:5079:
static bool test_str_hex_nibble_no_leak(void) {
DBG_BEGIN(dbg, out);
Str s = StrInit(&dbg);
StrPushBackR(&s, (char)0x05);
StrAppendFmt(&out, "{x}", s);- In
Write.c:5108:
static bool test_str_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Str s = StrInitFromZstr("hi", &alloc);
StrAppendFmt(&out, "{}", s); // width 0 default
- In
Write.c:5123:
static bool test_zstr_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "hi";
StrAppendFmt(&out, "{}", s);- In
Write.c:5158:
static bool test_u64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 42;
StrAppendFmt(&out, "{}", v);- In
Write.c:5172:
static bool test_i64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = -42;
StrAppendFmt(&out, "{}", v);- In
Write.c:5188:
static bool test_f64_char_bytes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
// Build a double whose 8 BE bytes are all printable ASCII: "ABCDEFGH".
f64 v;- In
Write.c:5204:
static bool test_f64_inf_sign(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 ninf = -F64_INFINITY;
StrAppendFmt(&out, "{}", ninf);- In
Write.c:5223:
static bool test_f64_default_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;
StrAppendFmt(&out, "{}", v);- In
Write.c:5248:
static bool test_f64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;
StrAppendFmt(&out, "{.1}", v);- In
Write.c:5265:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5289:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5304:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("2.0", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5330:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("3.14159", ab);
StrAppendFmt(&out, "{.2}", v);- In
Write.c:5349:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("5", ab);
StrAppendFmt(&out, "{.3}", v);- In
Write.c:5373:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "{}", v);- In
Write.c:5392:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "AB");- In
Write.c:5419:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("101", ab);
StrAppendFmt(&out, "{}", bv);- In
Write.c:5448:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Int v = IntFrom(42, ab);
StrAppendFmt(&out, "{}", v);- In
Write.c:5468:
bool test_leak_write_str_hex_per_byte_freed(void) {
HeapAllocator sa = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&sa));
for (int i = 0; i < 8; ++i)
StrPushBackR(&s, (char)0xAB);- In
Write.c:5472:
StrPushBackR(&s, (char)0xAB);
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str out = StrInit(ALLOCATOR_OF(&dbg));
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5519:
Float v = FloatFromStr("12345.67", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{e}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5545:
Float v = FloatFromStr("0.0", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.3e}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5571:
Float v = FloatFromStr("3.14159", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5598:
Float v = FloatFromStr("42", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5625:
Zstr s = "AB"; // multi-byte Zstr -> hex loop runs per byte
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{x}", s);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5649:
i32 v = -123456;
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5675:
bool test_leak_write_str_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&va));
StrAppendFmt(&s, "payload");
LEAK_WRITE_PRELUDE();- In
Read.c:351:
bool success = true;
Str s = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{}", s);- In
Read.c:396:
i32 num = 0;
Str name = StrInit(&alloc);
z = "Count: 42, Name: Alice";
StrReadFmt(z, "Count: {}, Name: {}", num, name);- In
Read.c:603:
success = success && abc_pass;
Str str_val = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{c}", str_val);- In
Read.c:613:
StrDeinit(&str_val);
str_val = StrInit(&alloc);
z = "\"World\"";
StrReadFmt(z, "{cs}", str_val);- In
Read.c:639:
// Test 1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:664:
// Test 1.1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:689:
// Test 2: :A (uppercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:714:
// Test 2.1: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:715:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:735:
// Test 2.2: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Read.c:736:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Read.c:758:
// Test 3: :a with quoted string
{
Str result = StrInit(&alloc);
Zstr in = "\"MiXeD CaSe\"";- In
Read.c:783:
// Test 4: :A with quoted string containing special characters
{
Str result = StrInit(&alloc);
Zstr in = "\"abc123XYZ\"";- In
Read.c:808:
// Test 5: Regular :c format (no case conversion) for comparison
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:920:
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);- In
Read.c:921:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Read.c:922:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Read.c:923:
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);
z = "123456789012345678901234567890";- In
Read.c:971:
Float neg = FloatInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Read.c:972:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Read.c:973:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);
z = "1234567890.012345";- In
Read.c:1433:
static bool test_m3_double_close_brace_escape(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = StrAppendFmt(&out, "}}");- In
Read.c:1562:
static bool test_m33_char_hex_escape_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
u16 v = (u16)0x1AE0; // big-endian bytes: 0x1A, 0xE0
- In
Read.c:1644:
static bool test_m4_end_pos_sizes_full_read(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
// 50 leading spaces, then the number well past byte index 42.
- In
Read.c:1673:
static bool test_m4_empty_file_no_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "", 0);
bool ok = FileIsOpen(&f);- In
Read.c:1722:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x41BC"; // backslash, x, 4, 1, B, C -> 'A', 'B', 'C'
StrReadFmt(z, "{}", s);- In
Read.c:1743:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x41"; // -> 'A'
StrReadFmt(z, "{}", s);- In
Read.c:1764:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x61"; // -> 'a'
StrReadFmt(z, "{A}", s);- In
Read.c:1787:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
// "\x41BC" inside double quotes -> decoded "ABC"
Zstr z = "\"\\x41BC\"";- In
Read.c:1808:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\"\\x41\""; // quoted -> 'A'
StrReadFmt(z, "{s}", s);- In
Read.c:1828:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\"\\x61\""; // quoted -> 'a'
StrReadFmt(z, "{As}", s);- In
Read.c:1853:
static bool test_m9_escape_both_digit_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1871:
static bool test_m9_escape_high_digit_nonzero(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1892:
static bool test_m9_escape_letter_boundary_lowercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1912:
static bool test_m9_escape_letter_above_boundary_lowercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1932:
static bool test_m9_escape_letter_boundary_uppercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1950:
static bool test_m9_escape_letter_above_boundary_uppercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1969:
static bool test_m9_escape_mixed_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:2044:
static bool test_read_escape_budget_anchor(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
Zstr p = "\\n\\n#rest";
StrReadFmt(p, "{}#", out);- In
Read.c:2083:
static bool test_read_long_string_no_cap(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
// Quoted string of 50 chars: max_read_len (= rem_in) must allow the full
// read; the `max_read_len = rem_in` survivor would cap it at 42.
- In
Read.c:2159:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\""; // 50 A's quoted
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));
bool ok = (out != NULL) && (StrLen(&s) == 50);- In
Read.c:2682:
static bool test_fread_seekable(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Read.c:2704:
static bool test_fread_rollback(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Read.c:2731:
static bool leak_quoted_unterminated(Zstr input, Zstr fmt) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, fmt, s); // reader frees s on the unterminated/error branch
- In
Read.c:2771:
bool test_leak_read_unquoted_bad_escape_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);- In
Memory.c:23:
Str s = StrInit(&alloc);
// Reserve more space than needed
- In
Memory.c:105:
Str s = StrInit(&alloc);
// Reserve more space
- In
Memory.c:188:
// Test with an empty string
StrDeinit(&s);
s = StrInit(&alloc);
// Reverse the string
- In
Init.c:25:
// Test StrInit function
bool test_str_init(void) {
WriteFmt("Testing StrInit\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Init.c:29:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
// Validate the string
- In
Init.c:152:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "Hello, {}!", &"World"[0]);- In
Init.c:201:
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInit(&alloc);
// Copy src to dst
- In
Init.c:228:
Str dup = StrInitFromStr(&src, &alloc);
Str dst = StrInit(&alloc);
bool copied = StrInitCopy(&dst, &src);- In
Init.c:334:
src.__magic = 0;
Str dst = StrInit(&alloc);
(void)StrInitCopy(&dst, &src); // ValidateStr(src) must abort on real code
- In
Type.c:27:
// Create a Str object
Str s = StrInit(&alloc);
// Check that it behaves like a Vec of chars
- In
Type.c:83:
// Create a valid Str
Str s = StrInit(&alloc);
// This should not crash
- In
Type.c:128:
// Create an invalid Str by corrupting its fields
Str s = StrInit(&alloc);
// Corrupt the string to make it invalid
- In
Convert.c:35:
Str s = StrInit(&alloc);
// Test decimal conversion
- In
Convert.c:101:
Str s = StrInit(&alloc);
// Test positive decimal conversion
- In
Convert.c:160:
Str s = StrInit(&alloc);
// Test integer conversion
- In
Convert.c:435:
for (size i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
- In
Convert.c:456:
for (size i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
- In
Convert.c:473:
for (size i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
for (u8 precision = 1; precision <= 6; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};- In
Convert.c:502:
// Test base boundary conditions
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test with base value itself
- In
Convert.c:518:
// Test extreme values
Str s = StrInit(&alloc);
// Test maximum u64
- In
Convert.c:592:
for (u8 precision = 1; precision <= 17; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};- In
Convert.c:612:
for (size i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
Str s = StrInit(&alloc);
// Force scientific notation
- In
Convert.c:634:
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false};- In
Convert.c:663:
// Test each base from 2 to 36
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test StrFromU64
- In
Convert.c:681:
// Test uppercase digits for bases that use letters (11-36)
for (u8 base = 11; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false};- In
Convert.c:700:
for (size i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false};- In
Convert.c:735:
u64 test_value = i * 1000007; // Large prime multiplier
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromU64(&s, test_value, &config);- In
Convert.c:754:
f64 test_value = mantissa * F64Pow((10.0), (i32)(exp));
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
StrFromF64(&s, test_value, &config);- In
Convert.c:1324:
WriteFmt("Testing StrFromF64 NaN emits exactly 3 bytes\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1343:
WriteFmt("Testing StrFromF64 inf emits exactly 3 bytes\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1363:
WriteFmt("Testing StrFromF64 0.0001 stays fixed notation\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};- In
Convert.c:1383:
WriteFmt("Testing StrFromF64 1e7 uses scientific notation\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1403:
WriteFmt("Testing StrFromF64 scientific precision 0 omits dot\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 0, .force_sci = true, .uppercase = false};- In
Convert.c:1422:
WriteFmt("Testing StrFromF64 zero exponent prints +00\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};- In
Convert.c:1443:
WriteFmt("Testing StrFromF64 scientific success returns handle\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};- In
Convert.c:1463:
WriteFmt("Testing StrFromF64 fixed success returns handle\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1483:
WriteFmt("Testing StrFromF64 fixed precision 0 omits dot\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 0, .force_sci = false, .uppercase = false};- In
Convert.c:1503:
WriteFmt("Testing StrFromF64 fixed fraction scale seed\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 3, .force_sci = false, .uppercase = false};- In
Convert.c:1524:
WriteFmt("Testing StrFromF64 fixed half-up rounding\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 3, .force_sci = false, .uppercase = false};- In
Convert.c:1864:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromI64(&s, INT64_MIN, &config);- In
Convert.c:1884:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 1, .force_sci = false, .uppercase = false};
StrFromF64(&s, 2.25, &config);- In
Convert.c:1904:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 1, .force_sci = false, .uppercase = false};
StrFromF64(&s, 2.25, &config);- In
Convert.c:1928:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 37, .uppercase = false};
Str *ret = StrFromU64(&s, 5, &config);- In
Convert.c:1953:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
Str *ret = StrFromU64(&s, 12345, &config);- In
Convert.c:1985:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrIntFormat config = {.base = 10, .uppercase = false};
// 10-digit value: any growth request exceeds the 8-byte slot.
- In
Convert.c:2014:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrFloatFormat config = {.precision = 0, .force_sci = false, .uppercase = false};
// Positive 15-digit value, precision 0 -> the integer digits are the only
- In
Convert.c:2056:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};
Str *ret = StrFromF64(&s, 1.23e150, &config);- In
Foreach.c:42:
// Build a new string by iterating through each character with its index
Str result = StrInit(&alloc);
StrForeachIdx(&s, chr, idx) {
StrAppendFmt(&result, "{c}{}", chr, idx);- In
Foreach.c:65:
// Build a new string by iterating through each character in reverse with its index
Str result = StrInit(&alloc);
StrForeachReverseIdx(&s, chr, idx) {- In
Foreach.c:90:
// Build a new string by iterating through each character pointer with its index
Str result = StrInit(&alloc);
StrForeachPtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
- In
Foreach.c:122:
// Build a new string by iterating through each character pointer in reverse with its index
Str result = StrInit(&alloc);
StrForeachReversePtrIdx(&s, chrptr, idx) {- In
Foreach.c:154:
// Build a new string by iterating through each character
Str result = StrInit(&alloc);
StrForeach(&s, chr) {
// Append the character to the result string
- In
Foreach.c:178:
// Build a new string by iterating through each character in reverse
Str result = StrInit(&alloc);
size char_count = 0;- In
Foreach.c:212:
// Build a new string by iterating through each character pointer
Str result = StrInit(&alloc);
StrForeachPtr(&s, chrptr) {
// Append the character (via pointer) to the result string
- In
Foreach.c:244:
// Build a new string by iterating through each character pointer in reverse
Str result = StrInit(&alloc);
size char_count = 0;- In
Foreach.c:286:
// Build a new string by iterating through a range of characters with indices
Str result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
// Append the character and its index to the result string
- In
Foreach.c:296:
// Test with empty range
Str empty_result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
// This block should not execute
- In
Foreach.c:321:
// Build a new string by iterating through a range of characters
Str result = StrInit(&alloc);
StrForeachInRange(&s, chr, 0, 5) {
// Append the character to the result string
- In
Foreach.c:331:
// Test with range at the end of the string
Str end_result = StrInit(&alloc);
StrForeachInRange(&s, chr, 6, 11) {
// Append the character to the result string
- In
Foreach.c:356:
// Build a new string by iterating through a range of character pointers with indices
Str result = StrInit(&alloc);
StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
// Append the character and its index to the result string
- In
Foreach.c:388:
// Build a new string by iterating through a range of character pointers
Str result = StrInit(&alloc);
StrForeachPtrInRange(&s, chrptr, 0, 5) {
// Append the character to the result string
- In
Access.c:24:
Str s = StrInit(&alloc);
bool result = (StrLen(&s) == 0); si = JSkipWhitespace(si); \
} \
Str key = StrInit(&alloc); \
UNPL(read_si) = JReadString(si, &key); \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \ do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
- In
Backtrace.c:35:
size n = bt_capture_outer(frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, frames, n, alloc_base);- In
Backtrace.c:77:
ok = ok && VecLen(&frames) >= 2;
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, &frames, alloc_base);- In
Backtrace.c:107:
size n = bt_capture_outer(frames, 16);
Str out = StrInit(alloc_base);
FormatStackTraceWith(&out, frames, n, &res);- In
Backtrace.c:147:
size n = cfi_capture_outer(&res, frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTraceWith(&rendered, frames, n, &res);- In
SysDns.c:99:
// FileRemove + StrDeinit). The on-disk file holds exactly `body`.
static Str write_temp(Allocator *a, Zstr body) {
Str path = StrInit(a);
File f = file_open_temp(&path, a);
if (FileIsOpen(&f)) {- In
SysDns.c:734:
Allocator *a = ALLOCATOR_OF(&alloc);
Str body = StrInit(a);
Zstr pad = "# padding line to push the fixture past the four kilobyte chunk\n";
u64 padlen = ZstrLen(pad);- In
Socket.c:1540:
bool ok = true;
Str spec = StrInit(a);
StrAppendFmt(&spec, "{}", (Zstr) "1.2.3.4:4660");- In
MachoCache.c:867:
MachoCache cache = MachoCacheInit(base);
Str mod = StrInit(base);
StrPushBackMany(&mod, bin_path);- In
Pe.c:1650:
build_blob(blob, secs, 1);
Str path = StrInit(base);
File f = FileOpenTemp(&path, base);
if (!FileIsOpen(&f)) {- In
Pe.c:1692:
junk[1] = 'Y';
Str path = StrInit(base);
File f = FileOpenTemp(&path, base);
if (!FileIsOpen(&f)) {- In
ProcMaps.c:319:
ProcMaps pm;
MemSet(&pm, 0, sizeof(pm));
pm.raw = StrInit(ALLOCATOR_OF(&alloc));
pm.entries = VecInitT(pm.entries, ALLOCATOR_OF(&alloc));- In
Http.c:44:
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);- In
Http.c:157:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);
StrAppendFmt(&raw, "GET / HTTP/1.1\r\n");
// 101 headers -- one past the cap of 100.
- In
Http.c:185:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);
StrAppendFmt(&raw, "GET / HTTP/1.1\r\n");
for (u64 i = 0; i < 100; i++) {- In
Http.c:213:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);
File f = FileOpenTemp(&path, alloc_base);
bool ok = FileIsOpen(&f);- In
Http.c:243:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);
File f = FileOpenTemp(&path, alloc_base);
bool ok = FileIsOpen(&f);- In
Http.c:350:
Allocator *adbg = ALLOCATOR_OF(&dbg);
Str first = StrInit(adbg);
StrAppendFmt(&first, "<h1>first-body-long-enough-to-heap-allocate</h1>");- In
Http.c:356:
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);
Str second = StrInit(adbg);
StrAppendFmt(&second, "<h1>second-body-also-long-enough-to-heap</h1>");
// Second call must free the first body before installing the second.
- In
Http.c:380:
// Pre-fill body with a heap-backed string.
Str first = StrInit(adbg);
StrAppendFmt(&first, "<h1>old-body-long-enough-to-force-heap-here</h1>");
HttpResponse response = HttpResponseInit(adbg);- In
Http.c:387:
// Create a temp file with content.
Str path = StrInit(adbg);
File f = FileOpenTemp(&path, adbg);
bool ok = FileIsOpen(&f);- In
Read.Simple.c:70:
StrIter si = StrIterFromStr(json);
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);- In
Read.Simple.c:71:
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);
JR_OBJ(si, {
Person person = {0};
person.name = StrInit(&alloc);
JR_OBJ(si, {
Config config = {0};
config.log_level = StrInit(&alloc);
JR_OBJ(si, { JR_OBJ(si, {
JR_ARR_KV(si, "languages", {
Str lang = StrInit(&alloc);
JR_STR(si, lang);
VecPushBack(&languages, lang); bool active;
} data = {
{StrInit(&alloc), StrInit(&alloc)},
false
};
SimpleProduct product = {0};
product.name = StrInit(&alloc);
product.tags = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit, &alloc); JR_FLT_KV(si, "price", product.price);
JR_ARR_KV(si, "tags", {
Str tag = StrInit(&alloc);
JR_STR(si, tag);
VecPushBack(&product.tags, tag); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
// Write completely empty object
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_numbers = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc); Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
i32 temp = -25;
bool success = true;
Str json = StrInit(&alloc);
i64 big_int = 9223372036854775807LL;
bool success = true;
Str json = StrInit(&alloc);
i32 int_zero = 0;
bool success = true;
Str json = StrInit(&alloc);
// Note: These are the actual characters, not escape sequences
bool success = true;
Str json = StrInit(&alloc);
// These contain actual special characters that should be escaped
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_list = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_arr = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
i64 max_int = 2147483647LL;
bool success = true;
Str json = StrInit(&alloc);
f64 tiny = 0.000001;
bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc); bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc);
// Single integer
bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove whitespace from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
ApiResponse response = { JW_OBJ_KV(json, "data", {
// Write dynamic key for source function ID
Str source_key = StrInit(&alloc);
u64 source_id = VecLen(&response.data) > 0 ? VecAt(&response.data, 0).source_function_id : 0;
StrAppendFmt(&source_key, "{}", source_id); if (VecLen(&response.data) > 0) {
AnnSymbol *s = &VecAt(&response.data, 0);
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", s->target_function_id);
bool success = true;
Str json = StrInit(&alloc);
Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit, &alloc);
bool success = true;
Str json = StrInit(&alloc);
SearchResult result = {0};
bool success = true;
Str json = StrInit(&alloc);
Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc); JW_OBJ_KV(json, "functions", {
VecForeach(&symbols, symbol) {
Str source_key = StrInit(&alloc);
StrAppendFmt(&source_key, "{}", symbol.source_function_id);
JW_OBJ_KV(json, StrBegin(&source_key), {
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", symbol.target_function_id);
bool success = true;
Str json = StrInit(&alloc);
// Create strings for the nested structure
bool success = true;
Str json = StrInit(&alloc);
Vec(u32) numbers = VecInit(&alloc); bool active;
f64 score;
} data = {0, StrInit(&alloc), false, 0.0};
JR_OBJ(si, { Str status;
} data = {
{0, {StrInit(&alloc), 0}},
StrInit(&alloc)
}; } data = {
{0, {StrInit(&alloc), 0}},
StrInit(&alloc)
}; } company;
} data = {
{{{StrInit(&alloc), 0, 0.0}}, StrInit(&alloc)}
}; // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = target_function_id; StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
JR_OBJ(si, { // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
FunctionInfo info = {0};
info.name = StrInit(&alloc);
JR_OBJ(si, {
ModelInfo info = {0};
info.name = StrInit(&alloc);
JR_OBJ(si, {
SearchResult result = {0};
result.binary_name = StrInit(&alloc);
result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc); SearchResult result = {0};
result.binary_name = StrInit(&alloc);
result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc); result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc); result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc); result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc);
JR_OBJ(si, { StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL); StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
Str name = StrInitFromZstr("Alice", &alloc);
bool success = true;
Str json = StrInit(&alloc);
u32 count = 42;
bool success = true;
Str json = StrInit(&alloc);
bool enabled = true;
bool success = true;
Str json = StrInit(&alloc);
Person person = {1001, StrInitFromZstr("Bob", &alloc), 25, true, 50000.0};
bool success = true;
Str json = StrInit(&alloc);
Config config = {false, 30, StrInitFromZstr("INFO", &alloc)};
bool success = true;
Str json = StrInit(&alloc);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
SimpleProduct product = {0}; JR_OBJ(si2, {
JR_ARR_KV(si2, "data", {
Str value = StrInit(&alloc);
JR_STR(si2, value);
VecPushBack(&data, value); Str name;
Str description;
} obj = {StrInit(&alloc), StrInit(&alloc)};
JR_OBJ(si, { Str message;
Str data;
} obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
JR_OBJ(si, { Str tab;
} obj = {
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc), } obj = {
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc), StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc), StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc), StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc), StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc) StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc)
}; StrInit(&alloc),
StrInit(&alloc),
StrInit(&alloc)
}; i32 value;
bool flag;
} obj = {StrInit(&alloc), 0, false};
JR_OBJ(si, { Str j = StrInitFromZstr(cases[i], &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
// Truncated escape -> failure -> iterator unchanged.
Str j = StrInitFromZstr("\"a\\u00e9b\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) != StrIterIndex(&si)) { Str j = StrInitFromZstr("\"plain\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) == StrIterIndex(&si) || StrIterIndex(&r) != StrIterLength(&r)) {- In
RoundTrip.c:104:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);- In
RoundTrip.c:120:
bool enabled;
Str message;
} parsed = {0, 0.0, false, StrInit(&alloc)};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:179:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "big_int", original.big_int);- In
RoundTrip.c:252:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_BOOL_KV(json, "flag1", original.flag1);- In
RoundTrip.c:305:
Str with_special;
} original = {
StrInit(&alloc),
StrInitFromZstr("hello", &alloc),
StrInitFromZstr("hello world with spaces", &alloc),- In
RoundTrip.c:312:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty", original.empty);- In
RoundTrip.c:326:
Str with_spaces;
Str with_special;
} parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:390:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });- In
RoundTrip.c:408:
});
JR_ARR_KV(si, "strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:478:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:490:
// Read back from JSON
TestPerson parsed_person = {0, StrInit(&alloc), 0, false, 0.0};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:560:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:583:
// Read back from JSON
ComplexData parsed = {0};
parsed.user = (TestPerson) {0, StrInit(&alloc), 0, false, 0.0};
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;- In
RoundTrip.c:586:
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;
parsed.config.log_level = StrInit(&alloc);
parsed.config.features = VecInitWithDeepCopyT(parsed.config.features, NULL, StrDeinit, &alloc);
parsed.numbers = VecInitT(parsed.numbers, &alloc);- In
RoundTrip.c:605:
JR_STR_KV(si, "log_level", parsed.config.log_level);
JR_ARR_KV(si, "features", {
Str feature = StrInit(&alloc);
JR_STR(si, feature);
VecPushBack(&parsed.config.features, feature);- In
RoundTrip.c:676:
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str empty_str = StrInit(&alloc);
// Write to JSON
- In
RoundTrip.c:679:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty_string", empty_str);- In
RoundTrip.c:696:
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str parsed_str = StrInit(&alloc);
bool found_empty_object = false;- In
RoundTrip.c:708:
});
JR_ARR_KV(si, "empty_strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:762:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "max_int", original.max_int);- In
Parse.c:377:
Str src = StrInitFromZstr("host = localhost\n", &alloc);
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit(&alloc);
Str *stored_host = NULL;
bool result = true;
Last updated on