StrLen
Description
Get string length in characters.
Parameters
| Name | Direction | Description |
|---|---|---|
str |
in | String to query. |
Success
Length of string.
Failure
Function cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Init.h:145:
///
#define StrInitFromStr(...) OVERLOAD(StrInitFromStr, __VA_ARGS__)
#define StrInitFromStr_1(str) StrInitFromCstr_2(StrBegin(str), StrLen(str))
#define StrInitFromStr_2(str, a) StrInitFromCstr_3(StrBegin(str), StrLen(str), (a))- In
Init.h:146:
#define StrInitFromStr(...) OVERLOAD(StrInitFromStr, __VA_ARGS__)
#define StrInitFromStr_1(str) StrInitFromCstr_2(StrBegin(str), StrLen(str))
#define StrInitFromStr_2(str, a) StrInitFromCstr_3(StrBegin(str), StrLen(str), (a))
///
- In
Access.h:59:
/// TAGS: Str, Empty, Query
///
#define StrEmpty(str) (StrLen(str) == 0)
///
- In
JSON.h:924:
do { \
const Str *UNPL(jw_s) = &(s); \
u64 UNPL(jw_len) = StrLen(UNPL(jw_s)); \
StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) ""); \
} while (0)- In
ProcMaps.h:103:
(src), \
File *: proc_maps_load_from_file((out), (File *)(src), MisraScope), \
Str *: proc_maps_load_from_bytes((out), (const u8 *)StrBegin((Str *)(src)), StrLen((Str *)(src)), MisraScope), \
Buf *: proc_maps_load_from_bytes((out), BufData((Buf *)(src)), BufLength((Buf *)(src)), MisraScope) \
)- In
ProcMaps.h:113:
(out), \
(const u8 *)StrBegin((Str *)(src)), \
StrLen((Str *)(src)), \
ALLOCATOR_OF(alloc) \
), \
- 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:28:
// empty fresh Str.
Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
*(Str *)dst_ptr = copy;
return true;- In
VecStr.c:475:
size_t total_len = 0;
VecForeach(vec, str) {
total_len += StrLen(&str);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:486:
size_t total_len = 0;
VecForeachIdx(vec, str, idx) {
total_len += StrLen(&str) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:497:
size_t total_len = 0;
VecForeachPtr(vec, str_ptr) {
total_len += StrLen(str_ptr);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:508:
size_t total_len = 0;
VecForeachPtrIdx(vec, str_ptr, idx) {
total_len += StrLen(str_ptr) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:519:
size_t total_len = 0;
VecForeachReverse(vec, str) {
total_len += StrLen(&str);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:530:
size_t total_len = 0;
VecForeachReverseIdx(vec, str, idx) {
total_len += StrLen(&str) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:541:
size_t total_len = 0;
VecForeachPtrReverse(vec, str_ptr) {
total_len += StrLen(str_ptr);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:552:
size_t total_len = 0;
VecForeachPtrReverseIdx(vec, str_ptr, idx) {
total_len += StrLen(str_ptr) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:566:
size_t total_len = 0;
VecForeachInRange(vec, str, start, end) {
total_len += StrLen(&str);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:581:
size_t total_len = 0;
VecForeachInRangeIdx(vec, str, idx, start, end) {
total_len += StrLen(&str) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:596:
size_t total_len = 0;
VecForeachPtrInRange(vec, str_ptr, start, end) {
total_len += StrLen(str_ptr);
}
(void)total_len; // Suppress unused variable warning
- In
VecStr.c:611:
size_t total_len = 0;
VecForeachPtrInRangeIdx(vec, str_ptr, idx, start, end) {
total_len += StrLen(str_ptr) + idx;
}
(void)total_len; // Suppress unused variable warning
- In
Log.c:58:
File out = (type == LOG_MESSAGE_TYPE_INFO) ? FileFromFd(1) : FileFromFd(2);
(void)FileWrite(&out, StrBegin(&full), StrLen(&full));
#if FEATURE_SYS_BACKTRACE && (!defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE)- In
Log.c:71:
// boundary; pass at the call site, no intermediate variable.
FormatStackTrace(&trace, frames, n, ALLOCATOR_OF(&h));
(void)FileWrite(&out, StrBegin(&trace), StrLen(&trace));
StrDeinit(&trace);
}- In
ArgParse.c:288:
// the visible width so the caller can pad to a shared right margin.
static u64 spec_format_left(const ArgSpec *sp, Str *out) {
u64 start = StrLen(out);
StrPushBackMany(out, " ");
if (sp->role == ARG_ROLE_POSITIONAL) {- In
ArgParse.c:311:
}
}
return StrLen(out) - start;
}- In
Io.c:502:
bool ok = str_append_fmt(&tmp, fmt, args, argc);
if (ok) {
if (offset > StrLen(o) || StrLen(&tmp) > StrLen(o) - offset) {
LOG_ERROR(
"StrPatchFmt: write of {} bytes at offset {} exceeds str length {}",- In
Io.c:505:
LOG_ERROR(
"StrPatchFmt: write of {} bytes at offset {} exceeds str length {}",
StrLen(&tmp),
offset,
StrLen(o)- In
Io.c:507:
StrLen(&tmp),
offset,
StrLen(o)
);
ok = false;- In
Io.c:510:
);
ok = false;
} else if (StrLen(&tmp)) {
MemCopy(StrBegin(o) + offset, StrBegin(&tmp), StrLen(&tmp));
}- In
Io.c:511:
ok = false;
} else if (StrLen(&tmp)) {
MemCopy(StrBegin(o) + offset, StrBegin(&tmp), StrLen(&tmp));
}
}- In
Io.c:543:
}
if (ok && StrLen(&out) > 0 && FileWrite(stream, StrBegin(&out), StrLen(&out)) != (i64)StrLen(&out)) {
LOG_ERROR("Failed to write formatted output");
ok = false;- In
Io.c:1109:
bool ok = render_binary_fmt(&tmp, fmtstr, argv, argc);
if (ok) {
if (offset > BufLength(out) || StrLen(&tmp) > BufLength(out) - offset) {
LOG_ERROR(
"BufPatchFmt: write of {} bytes at offset {} exceeds buf length {}",- In
Io.c:1112:
LOG_ERROR(
"BufPatchFmt: write of {} bytes at offset {} exceeds buf length {}",
StrLen(&tmp),
offset,
BufLength(out)- In
Io.c:1117:
);
ok = false;
} else if (StrLen(&tmp)) {
MemCopy(BufData(out) + offset, StrBegin(&tmp), StrLen(&tmp));
}- In
Io.c:1118:
ok = false;
} else if (StrLen(&tmp)) {
MemCopy(BufData(out) + offset, StrBegin(&tmp), StrLen(&tmp));
}
}- In
Io.c:1177:
}
if (StrLen(&buffer)) {
Zstr new_pos = str_read_fmt(StrBegin(&buffer), fmtstr, argv, argc);
if (!new_pos) {- In
Io.c:1507:
}
exponent = value->exponent + (i64)StrLen(&digits) - 1;
if (!StrPushBackR(&result, StrBegin(&digits)[0])) {
goto fail;- In
Io.c:1512:
}
frac_digits = has_precision ? precision : (StrLen(&digits) > 0 ? StrLen(&digits) - 1 : 0);
if (frac_digits > 0) {
if (!StrPushBackR(&result, '.')) {- In
Io.c:1518:
}
for (u64 i = 0; i < frac_digits; i++) {
if (i + 1 < StrLen(&digits)) {
if (!StrPushBackR(&result, StrBegin(&digits)[i + 1])) {
goto fail;- In
Io.c:1765:
// can compute "how much content did we just emit" without
// accounting for prior contents.
size start_len = StrLen(o);
if (StrLen(s)) {- In
Io.c:1767:
size start_len = StrLen(o);
if (StrLen(s)) {
if (fmt_info->flags & FMT_FLAG_HEX) {
// `{x}` over a Str renders each byte as `0xNN` with a
- In
Io.c:1787:
return false;
}
if (StrLen(&hex) == 1) {
if (!StrPushFrontR(&hex, '0')) {
return false;- In
Io.c:1801:
// `{:.Ns}`); precision 0 is the explicit "render nothing"
// case, not an error.
size len = StrLen(s);
if (fmt_info->flags & FMT_FLAG_HAS_PRECISION) {
if (fmt_info->precision == 0) {- In
Io.c:1833:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Io.c:1852:
// Snapshot the pre-render length so post-render padding sees the
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
Zstr xs = *s;- In
Io.c:1874:
return false;
}
if (StrLen(&hex) == 1) {
if (!StrPushFrontR(&hex, '0')) {
return false;- In
Io.c:1920:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Io.c:1952:
// Snapshot the pre-render length so post-render padding sees the
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
u8 base = 10;- In
Io.c:1985:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (zero_pad) {
if (!pad_numeric_zeros(o, start_len, fmt_info->width, content_len)) {- In
Io.c:2052:
// Snapshot the pre-render length so post-render padding sees the
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
u8 base = 10;- In
Io.c:2082:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (zero_pad) {
if (!pad_numeric_zeros(o, start_len, fmt_info->width, content_len)) {- In
Io.c:2154:
// Snapshot the pre-render length so post-render padding sees the
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
// NaN / +/-inf bypass `StrFromF64` so the rendered token stays
- In
Io.c:2211:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Io.c:2255:
}
start_len = StrLen(o);
if (fmt_info->flags & FMT_FLAG_SCIENTIFIC) {
if (!float_try_to_scientific_str(- In
Io.c:2286:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Io.c:2511:
return false;
size len = StrLen(str);
const char *data = StrBegin(str);- In
Io.c:2805:
// a malformed integer; the parser proper would accept the leading
// '0' and silently lose the prefix, so reject early.
if (StrLen(&temp) == 2 && StrBegin(&temp)[0] == '0' &&
(StrBegin(&temp)[1] == 'x' || StrBegin(&temp)[1] == 'X' || StrBegin(&temp)[1] == 'b' ||
StrBegin(&temp)[1] == 'B' || StrBegin(&temp)[1] == 'o' || StrBegin(&temp)[1] == 'O')) {- In
Io.c:2912:
Str temp = StrInitFromCstr(start, pos, &scratch); \
\
if (StrLen(&temp) == 2 && StrBegin(&temp)[0] == '0' && \
(StrBegin(&temp)[1] == 'x' || StrBegin(&temp)[1] == 'X' || StrBegin(&temp)[1] == 'b' || \
StrBegin(&temp)[1] == 'B' || StrBegin(&temp)[1] == 'o' || StrBegin(&temp)[1] == 'O')) { \
- In
Io.c:3021:
// the caller owns and may mutate the returned buffer. ZstrDupN's Zstr
// return is just the project-wide convention for fresh allocations.
result = (char *)ZstrDupN(StrBegin(&temp), StrLen(&temp), allocator_ptr);
if (!result) {
LOG_ERROR("Failed to allocate memory for string");- In
Io.c:3049:
// Snapshot the pre-render length so post-render padding sees the
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
if (fmt_info->flags & FMT_FLAG_HEX) {- In
Io.c:3101:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Io.c:3144:
}
size start_len = StrLen(o);
Str temp;
u8 radix = int_fmt_radix_from_flags(fmt_info);- In
Io.c:3165:
if (fmt_info->width > 0) {
size content_len = StrLen(o) - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;- In
Str.c:175:
ValidateStr(str);
for (idx = 0; idx < StrLen(str); idx++) {
hash ^= (u64)(unsigned char)StrCharAt(str, idx);
hash *= 1099511628211ULL;- In
Str.c:192:
ValidateStr(b);
min = StrLen(a) < StrLen(b) ? StrLen(a) : StrLen(b);
cmp = MemCompare(StrBegin(a), StrBegin(b), min);- In
Str.c:198:
return cmp;
}
if (StrLen(a) < StrLen(b)) {
return -1;
}- In
Str.c:201:
return -1;
}
if (StrLen(a) > StrLen(b)) {
return 1;
}- In
Str.c:252:
ValidateStr(s);
ValidateStr(key);
return ZstrFindSubstringN(StrBegin(s), StrBegin(key), StrLen(key));
}- In
Int.c:668:
}
if (StrLen(decimal) > 0 && StrCharAt(decimal, 0) == '+') {
start = 1;
}- In
Int.c:672:
}
return int_try_from_str_radix_impl(out, StrBegin(decimal), StrLen(decimal), start, 10, true);
}- In
Int.c:726:
LOG_FATAL("Invalid arguments");
}
if (StrLen(digits) > 0 && StrCharAt(digits, 0) == '+') {
start = 1;
}- In
Int.c:730:
}
return int_try_from_str_radix_impl(out, StrBegin(digits), StrLen(digits), start, radix, true);
}- In
Int.c:843:
IntDeinit(&remainder);
for (u64 i = 0; i < StrLen(&result) / 2; i++) {
char *lhs = StrCharPtrAt(&result, i);
char *rhs = StrCharPtrAt(&result, StrLen(&result) - 1 - i);- In
Int.c:845:
for (u64 i = 0; i < StrLen(&result) / 2; i++) {
char *lhs = StrCharPtrAt(&result, i);
char *rhs = StrCharPtrAt(&result, StrLen(&result) - 1 - i);
char tmp = *lhs;
*lhs = *rhs;- In
Int.c:891:
}
if (StrLen(binary) >= 2 && StrCharAt(binary, 0) == '0' &&
(StrCharAt(binary, 1) == 'b' || StrCharAt(binary, 1) == 'B')) {
start = 2;- In
Int.c:896:
}
return int_try_from_str_radix_impl(out, StrBegin(binary), StrLen(binary), start, 2, true);
}- In
Int.c:940:
}
if (StrLen(octal) >= 2 && StrCharAt(octal, 0) == '0' &&
(StrCharAt(octal, 1) == 'o' || StrCharAt(octal, 1) == 'O')) {
start = 2;- In
Int.c:945:
}
return int_try_from_str_radix_impl(out, StrBegin(octal), StrLen(octal), start, 8, true);
}- In
Int.c:982:
}
return int_try_from_str_radix_impl(out, StrBegin(hex), StrLen(hex), 0, 16, false);
}- In
Float.c:619:
LOG_FATAL("Invalid arguments");
}
return float_try_from_str_impl(out, StrBegin(text), StrLen(text));
}- In
Float.c:674:
}
} else {
i64 split = (i64)StrLen(&digits) + value->exponent;
if (split > 0) {- In
Float.c:687:
}
for (u64 i = (u64)split; i < StrLen(&digits); i++) {
if (!StrPushBackR(&result, StrCharAt(&digits, i))) {
goto fail;- In
BitVec.c:1934:
bool result = false;
if (ZstrFindSubstringN(StrBegin(&bv_str), StrBegin(pattern), StrLen(pattern)) != NULL) {
result = true;
}- In
PdbCache.c:48:
StrResize(out_path, 0);
sys_append_dirname(out_path, pe_path);
if (StrLen(out_path) > 0)
StrPushBackR(out_path, '/');
StrPushBackMany(out_path, pdb_base);- In
Dns.c:218:
HostsEntry e = {0};
e.name = StrInitFromCstr((Zstr)StrIterDataAt(&si, nm_start), nm_len, alloc);
ascii_lower((u8 *)StrBegin(&e.name), StrLen(&e.name));
if (got_v4) {
MemCopy(e.ip, v4, 4);- In
Dns.c:584:
// 1. /etc/hosts fast path.
VecForeachPtr(&self->hosts, e) {
if (StrLen(&e->name) > 0 && ZstrCompare(StrBegin(&e->name), nq) == 0) {
SocketAddr a = e->is_ipv6 ? sockaddr_v6(e->ip, port) : sockaddr_v4(e->ip, port);
VecPushBackR(out, a);- In
Proc.c:471:
#if PLATFORM_UNIX
return direct_sys3(MISRA_SYS_write, (long)(proc->_stdin_fd), (long)(u64)(StrBegin(buf)), (long)(StrLen(buf)));
#else
DWORD written = 0;- In
Proc.c:474:
#else
DWORD written = 0;
if (!WriteFile(proc->_hStdinWrite, StrBegin(buf), StrLen(buf), &written, NULL))
return -1;
return (int)written;- In
DwarfInfo.c:477:
++nlen;
if (nlen > 0 && nlen < src_max) {
u64 offset = StrLen(pool);
for (u64 i = 0; i < nlen; ++i) {
if (!StrPushBackR(pool, src[i]))- In
KvConfig.c:125:
}
if (StrLen(key) == 0) {
LOG_ERROR("Expected config key");
StrClear(key);- In
KvConfig.c:196:
while (StrIterPeek(&si, &c) && c != '\n') {
if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {- In
KvConfig.c:197:
while (StrIterPeek(&si, &c) && c != '\n') {
if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
char dropped = '\0';- In
KvConfig.c:198:
if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
while (StrLen(value) > 0 && kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {
char dropped = '\0';
StrPopBack(value, &dropped);- In
KvConfig.c:205:
}
if (kvconfig_is_comment_start(c) && StrLen(value) == 0) {
return si;
}- In
KvConfig.c:213:
}
if (StrLen(value) > 0) {
Str stripped = StrStrip(value, NULL);
StrDeinit(value);- In
KvConfig.c:362:
}
return StrInitFromCstr(StrBegin(value), StrLen(value), MapAllocator(cfg));
}- In
KvConfig.c:372:
}
return StrInitFromCstr(StrBegin(value), StrLen(value), MapAllocator(cfg));
}- In
Pdb.c:505:
// pass after the walk completes.
static bool pool_append_cstr(Str *pool, Zstr s, u64 *out_offset) {
*out_offset = StrLen(pool);
if (!StrPushBackMany(pool, s))
return false;- In
ProcMaps.c:212:
};
while (true) {
u64 grown_to = StrLen(raw) + CHUNK + 1;
if (!StrReserve(raw, grown_to))
return false;- In
ProcMaps.c:218:
if (n < 0)
return false;
StrResize(raw, StrLen(raw) + (u64)n);
if (n == 0)
break;- In
ProcMaps.c:248:
return false;
}
if (StrLen(&out->raw) == 0) {
LOG_ERROR("ProcMapsLoad: /proc/self/maps was empty");
ProcMapsDeinit(out);- In
Http.c:87:
return HTTP_REQUEST_METHOD_UNKNOWN;
}
if (0 == ZstrCompareN(StrBegin(mstr), "GET", 3) && StrLen(mstr) == 3)
return HTTP_REQUEST_METHOD_GET;
if (0 == ZstrCompareN(StrBegin(mstr), "POST", 4) && StrLen(mstr) == 4)- In
Http.c:89:
if (0 == ZstrCompareN(StrBegin(mstr), "GET", 3) && StrLen(mstr) == 3)
return HTTP_REQUEST_METHOD_GET;
if (0 == ZstrCompareN(StrBegin(mstr), "POST", 4) && StrLen(mstr) == 4)
return HTTP_REQUEST_METHOD_POST;
if (0 == ZstrCompareN(StrBegin(mstr), "DELETE", 6) && StrLen(mstr) == 6)- In
Http.c:91:
if (0 == ZstrCompareN(StrBegin(mstr), "POST", 4) && StrLen(mstr) == 4)
return HTTP_REQUEST_METHOD_POST;
if (0 == ZstrCompareN(StrBegin(mstr), "DELETE", 6) && StrLen(mstr) == 6)
return HTTP_REQUEST_METHOD_DELETE;
if (0 == ZstrCompareN(StrBegin(mstr), "PUT", 3) && StrLen(mstr) == 3)- In
Http.c:93:
if (0 == ZstrCompareN(StrBegin(mstr), "DELETE", 6) && StrLen(mstr) == 6)
return HTTP_REQUEST_METHOD_DELETE;
if (0 == ZstrCompareN(StrBegin(mstr), "PUT", 3) && StrLen(mstr) == 3)
return HTTP_REQUEST_METHOD_PUT;
if (0 == ZstrCompareN(StrBegin(mstr), "PATCH", 5) && StrLen(mstr) == 5)- In
Http.c:95:
if (0 == ZstrCompareN(StrBegin(mstr), "PUT", 3) && StrLen(mstr) == 3)
return HTTP_REQUEST_METHOD_PUT;
if (0 == ZstrCompareN(StrBegin(mstr), "PATCH", 5) && StrLen(mstr) == 5)
return HTTP_REQUEST_METHOD_PATCH;
if (0 == ZstrCompareN(StrBegin(mstr), "HEAD", 4) && StrLen(mstr) == 4)- In
Http.c:97:
if (0 == ZstrCompareN(StrBegin(mstr), "PATCH", 5) && StrLen(mstr) == 5)
return HTTP_REQUEST_METHOD_PATCH;
if (0 == ZstrCompareN(StrBegin(mstr), "HEAD", 4) && StrLen(mstr) == 4)
return HTTP_REQUEST_METHOD_HEAD;
if (0 == ZstrCompareN(StrBegin(mstr), "OPTIONS", 7) && StrLen(mstr) == 7)- In
Http.c:99:
if (0 == ZstrCompareN(StrBegin(mstr), "HEAD", 4) && StrLen(mstr) == 4)
return HTTP_REQUEST_METHOD_HEAD;
if (0 == ZstrCompareN(StrBegin(mstr), "OPTIONS", 7) && StrLen(mstr) == 7)
return HTTP_REQUEST_METHOD_OPTIONS;
if (0 == ZstrCompareN(StrBegin(mstr), "CONNECT", 7) && StrLen(mstr) == 7)- In
Http.c:101:
if (0 == ZstrCompareN(StrBegin(mstr), "OPTIONS", 7) && StrLen(mstr) == 7)
return HTTP_REQUEST_METHOD_OPTIONS;
if (0 == ZstrCompareN(StrBegin(mstr), "CONNECT", 7) && StrLen(mstr) == 7)
return HTTP_REQUEST_METHOD_CONNECT;
if (0 == ZstrCompareN(StrBegin(mstr), "TRACE", 5) && StrLen(mstr) == 5)- In
Http.c:103:
if (0 == ZstrCompareN(StrBegin(mstr), "CONNECT", 7) && StrLen(mstr) == 7)
return HTTP_REQUEST_METHOD_CONNECT;
if (0 == ZstrCompareN(StrBegin(mstr), "TRACE", 5) && StrLen(mstr) == 5)
return HTTP_REQUEST_METHOD_TRACE;
return HTTP_REQUEST_METHOD_UNKNOWN;- In
Http.c:478:
response_code,
content_type,
StrLen(&response->body)
);- In
Http.c:487:
StrAppendFmt(&out, "\r\n");
if (StrLen(&response->body)) {
if (!StrPushBackMany(&out, StrBegin(&response->body), StrLen(&response->body))) {
LOG_ERROR("HttpResponseSerialize: failed to append body");- In
Http.c:488:
if (StrLen(&response->body)) {
if (!StrPushBackMany(&out, StrBegin(&response->body), StrLen(&response->body))) {
LOG_ERROR("HttpResponseSerialize: failed to append body");
StrDeinit(&out);- In
JSON.c:399:
}
if (!StrLen(&ns)) {
LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
StrDeinit(&ns);- In
Dwarf.c:54:
// return the offset at which it was inserted.
static bool pool_append(Str *pool, Zstr s, u64 *out_offset) {
u64 start = StrLen(pool);
if (!StrPushBackMany(pool, s))
return false;- In
Resolve.c:48:
// Strip the trailing ":0" since we resolve with port=0; keep
// bracket form on v6 to round-trip through SocketAddrParse.
size n = StrLen(&s);
Zstr p = StrBegin(&s);
if (n >= 2 && p[n - 1] == '0' && p[n - 2] == ':') {- In
File.c:54:
FileClose(&f);
bool result = (got == (i64)ZstrLen("hello from file")) && (StrLen(&body) == (size)ZstrLen("hello from file")) &&
ZstrCompare(StrBegin(&body), "hello from file") == 0;- In
File.c:89:
Zstr expected = "this is longer than the initial buffer";
bool result = (got == (i64)ZstrLen(expected)) && (StrLen(&body) == (size)ZstrLen(expected)) &&
ZstrCompare(StrBegin(&body), expected) == 0 && StrCapacity(&body) >= StrLen(&body) + 1;- In
File.c:90:
Zstr expected = "this is longer than the initial buffer";
bool result = (got == (i64)ZstrLen(expected)) && (StrLen(&body) == (size)ZstrLen(expected)) &&
ZstrCompare(StrBegin(&body), expected) == 0 && StrCapacity(&body) >= StrLen(&body) + 1;
StrDeinit(&body);- In
File.c:270:
FileClose(&r);
ok = ok && (got == 3) && (StrLen(&body) == 3) && ZstrCompare(StrBegin(&body), "new") == 0;
StrDeinit(&body);- In
File.c:340:
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;
StrDeinit(&body);- In
File.c:758:
FileClose(&f);
ok = ok && (got == 6) && (StrLen(&body) == 6) && ZstrCompare(StrBegin(&body), "ABCDEF") == 0;
StrDeinit(&body);- In
File.c:789:
FileClose(&f);
ok = ok && (got == (i64)ZstrLen(payload)) && (StrLen(&body) == (size)ZstrLen(payload)) &&
ZstrCompare(StrBegin(&body), payload) == 0;- In
File.c:875:
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;
StrDeinit(&body);- In
File.c:905:
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);
StrDeinit(&body);- In
File.c:969:
i64 wrote = FileWriteAndClose(&path, &in);
bool ok = (wrote == (i64)StrLen(&in));
Str body = StrInit(alloc_base);- In
File.c:973:
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)StrLen(&in)) && ZstrCompare(StrBegin(&body), "string-content") == 0;
StrDeinit(&body);- In
File.c:999:
bool ok = FileIsOpen(&f);
// The resolved path must be non-empty (16 hex chars).
ok = ok && (StrLen(&path) == 16);
// Round-trip a payload through the freshly created temp file.
- In
File.c:1030:
bool ok = FileIsOpen(&f1) && FileIsOpen(&f2);
ok = ok && (StrLen(&p1) == 16) && (StrLen(&p2) == 16);
// Distinct names (overwhelmingly likely; the loop draws fresh entropy).
ok = ok && (ZstrCompare(StrBegin(&p1), StrBegin(&p2)) != 0);- In
File.c:1170:
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);
StrDeinit(&body);- In
AllocDebug.c:127:
DebugAllocatorReportLeaks(&dbg, &out);
bool ok = StrLen(&out) > 0;
ok = ok && (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "24 bytes") != NULL);- In
ArgParse.c:261:
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && StrLen(&name) == 5 && StrBegin(&name)[0] == 'a' && StrBegin(&name)[4] == 'e';
ArgParseDeinit(&p);
StrDeinit(&name);- In
ArgParse.c:639:
Str out = StrInit(&a);
capture_help(p, &out);
bool ok = (StrLen(&out) == ZstrLen(expected)) && (ZstrCompare(StrBegin(&out), expected) == 0);
if (!ok) {
WriteFmt("[a1] help mismatch:\n");- In
ArgParse.c:643:
WriteFmt("[a1] help mismatch:\n");
WriteFmt("---- expected ({} bytes) ----\n{}\n", ZstrLen(expected), expected);
WriteFmt("---- actual ({} bytes) ----\n{}\n", StrLen(&out), StrBegin(&out));
}
StrDeinit(&out);- In
ArgParse.c:907:
// True iff `needle` occurs as a substring of `hay` (a Str body).
static bool str_contains(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);
u64 nn = ZstrLen(needle);- In
ArgParse.c:1154:
char *argv[] = {(char *)"prog", (char *)"--name", (char *)"bob"};
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && (StrLen(&name) == 3) && (StrBegin(&name)[0] == 'b') && (StrBegin(&name)[2] == 'b');
ArgParseDeinit(&p);
StrDeinit(&name);- In
ArgParse.c:1791:
static bool str_has(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);
u64 nn = ZstrLen(needle);- In
Foreach.c:34:
static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const Str *name, DefaultAllocator *alloc) {
GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));
Str key_copy = StrInitFromCstr(StrBegin(name), StrLen(name), alloc);- In
Foreach.c:36:
GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));
Str key_copy = StrInitFromCstr(StrBegin(name), StrLen(name), alloc);
MapInsertR(index, key_copy, id);
return id;- In
Convert.c:462:
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "3.14") == 0) && (StrLen(&text) == 4);
StrDeinit(&text);- In
Convert.c:484:
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "0.001") == 0) && (StrLen(&text) == 5);
StrDeinit(&text);- In
Convert.c:503:
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "100") == 0) && (StrLen(&text) == 3);
StrDeinit(&text);- In
Convert.c:649:
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "4503599627370496") == 0) && (StrLen(&text) == 16);
StrDeinit(&text);- In
Memory.c:455:
StrClear(&s);
bool result = (StrLen(&s) == 0) && (ZstrCompare(StrBegin(&s), "") == 0);
StrDeinit(&s);- In
Memory.c:473:
StrClear(&s);
bool result = (StrLen(&s) == 0) && (ZstrCompare(StrBegin(&s), "") == 0);
StrDeinit(&s);- In
Convert.c:56:
// Check result
bool result = ok && (StrLen(&str) == 4);
result = result && (StrBegin(&str)[0] == '1');
result = result && (StrBegin(&str)[1] == '0');- In
Convert.c:323:
// Test converting empty bitvec
Str str_obj = BitVecToStr(&bv);
result = result && (StrLen(&str_obj) == 0);
StrDeinit(&str_obj);- In
Convert.c:329:
BitVecPush(&bv, true);
str_obj = BitVecToStr(&bv);
result = result && (StrLen(&str_obj) == 1);
result = result && (StrCmp(&str_obj, "1", 1) == 0);
StrDeinit(&str_obj);- In
Convert.c:339:
}
str_obj = BitVecToStr(&bv);
result = result && (StrLen(&str_obj) == 1000);
StrDeinit(&str_obj);- In
Convert.c:534:
Str empty_str = BitVecToStr(&empty);
result = result && (StrLen(&empty_str) == 0);
StrDeinit(&empty_str);- In
Convert.c:652:
// Test string conversion
Str large_str = BitVecToStr(&large_bv);
result = result && (StrLen(&large_str) == 1000);
// Verify pattern consistency
- In
Convert.c:656:
// Verify pattern consistency
bool pattern_correct = true;
for (u64 i = 0; i < StrLen(&large_str); i++) {
bool expected = (i % 3) == 0;
bool actual = (StrBegin(&large_str)[i] == '1');- In
Convert.c:453:
Str text = IntToStrRadix(&value, 37, false);
bool result = StrLen(&text) == 0;
StrDeinit(&text);- In
Convert.c:1574:
Int v = IntFrom(1234567u, a);
Str s = IntToStrRadix(&v, 10, false, a);
bool ok = StrLen(&s) == 7;
u64 rem = 0;
{- In
Write.c:46:
StrAppendFmt(&output, "");
success = success && (StrLen(&output) == 0);
StrClear(&output);- In
Write.c:80:
Zstr empty = "";
StrAppendFmt(&output, "{}", empty);
success = success && (StrLen(&output) == 0);
StrClear(&output);- In
Write.c:422:
StrAppendFmt(&output, "{c}", u16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'A' && StrBegin(&output)[1] == 'B');
StrClear(&output);- In
Write.c:426:
StrAppendFmt(&output, "{a}", u16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'a' && StrBegin(&output)[1] == 'b');
StrClear(&output);- In
Write.c:430:
StrAppendFmt(&output, "{A}", u16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'A' && StrBegin(&output)[1] == 'B');
StrClear(&output);- In
Write.c:436:
StrAppendFmt(&output, "{c}", i16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'C' && StrBegin(&output)[1] == 'd');
StrClear(&output);- In
Write.c:440:
StrAppendFmt(&output, "{a}", i16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'c' && StrBegin(&output)[1] == 'd');
StrClear(&output);- In
Write.c:444:
StrAppendFmt(&output, "{A}", i16_value);
success = success && (StrLen(&output) == 2 && StrBegin(&output)[0] == 'C' && StrBegin(&output)[1] == 'D');
StrClear(&output);- In
Write.c:450:
StrAppendFmt(&output, "{c}", u32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'E' && StrBegin(&output)[1] == 'f' &&
StrBegin(&output)[2] == 'G' && StrBegin(&output)[3] == 'h');
StrClear(&output);- In
Write.c:455:
StrAppendFmt(&output, "{a}", u32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'e' && StrBegin(&output)[1] == 'f' &&
StrBegin(&output)[2] == 'g' && StrBegin(&output)[3] == 'h');
StrClear(&output);- In
Write.c:460:
StrAppendFmt(&output, "{A}", u32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'E' && StrBegin(&output)[1] == 'F' &&
StrBegin(&output)[2] == 'G' && StrBegin(&output)[3] == 'H');
StrClear(&output);- In
Write.c:467:
StrAppendFmt(&output, "{c}", i32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'I' && StrBegin(&output)[1] == 'j' &&
StrBegin(&output)[2] == 'K' && StrBegin(&output)[3] == 'l');
StrClear(&output);- In
Write.c:472:
StrAppendFmt(&output, "{a}", i32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'i' && StrBegin(&output)[1] == 'j' &&
StrBegin(&output)[2] == 'k' && StrBegin(&output)[3] == 'l');
StrClear(&output);- In
Write.c:477:
StrAppendFmt(&output, "{A}", i32_value);
success = success && (StrLen(&output) == 4 && StrBegin(&output)[0] == 'I' && StrBegin(&output)[1] == 'J' &&
StrBegin(&output)[2] == 'K' && StrBegin(&output)[3] == 'L');
StrClear(&output);- In
Write.c:485:
StrAppendFmt(&output, "{c}", u64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'M' && StrBegin(&output)[1] == 'n' &&
StrBegin(&output)[2] == 'O' && StrBegin(&output)[3] == 'p' && StrBegin(&output)[4] == 'Q' &&
StrBegin(&output)[5] == 'r' && StrBegin(&output)[6] == 'S' && StrBegin(&output)[7] == 't');- In
Write.c:491:
StrAppendFmt(&output, "{a}", u64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'm' && StrBegin(&output)[1] == 'n' &&
StrBegin(&output)[2] == 'o' && StrBegin(&output)[3] == 'p' && StrBegin(&output)[4] == 'q' &&
StrBegin(&output)[5] == 'r' && StrBegin(&output)[6] == 's' && StrBegin(&output)[7] == 't');- In
Write.c:497:
StrAppendFmt(&output, "{A}", u64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'M' && StrBegin(&output)[1] == 'N' &&
StrBegin(&output)[2] == 'O' && StrBegin(&output)[3] == 'P' && StrBegin(&output)[4] == 'Q' &&
StrBegin(&output)[5] == 'R' && StrBegin(&output)[6] == 'S' && StrBegin(&output)[7] == 'T');- In
Write.c:506:
StrAppendFmt(&output, "{c}", i64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'U' && StrBegin(&output)[1] == 'v' &&
StrBegin(&output)[2] == 'W' && StrBegin(&output)[3] == 'x' && StrBegin(&output)[4] == 'Y' &&
StrBegin(&output)[5] == 'z' && StrBegin(&output)[6] == '1' && StrBegin(&output)[7] == '2');- In
Write.c:512:
StrAppendFmt(&output, "{a}", i64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'u' && StrBegin(&output)[1] == 'v' &&
StrBegin(&output)[2] == 'w' && StrBegin(&output)[3] == 'x' && StrBegin(&output)[4] == 'y' &&
StrBegin(&output)[5] == 'z' && StrBegin(&output)[6] == '1' && StrBegin(&output)[7] == '2');- In
Write.c:518:
StrAppendFmt(&output, "{A}", i64_value);
success = success && (StrLen(&output) == 8 && StrBegin(&output)[0] == 'U' && StrBegin(&output)[1] == 'V' &&
StrBegin(&output)[2] == 'W' && StrBegin(&output)[3] == 'X' && StrBegin(&output)[4] == 'Y' &&
StrBegin(&output)[5] == 'Z' && StrBegin(&output)[6] == '1' && StrBegin(&output)[7] == '2');- In
Write.c:544:
BitVec bv_empty = BitVecInit(alloc_base);
StrAppendFmt(&output, "{}", bv_empty);
success = success && (StrLen(&output) == 0);
StrClear(&output);- In
Write.c:685:
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));
bool ok = (StrLen(&s) == 8) && (StrBegin(&s)[0] == 'f') && (StrBegin(&s)[StrLen(&s) - 1] == '2');
StrDeinit(&s);
DefaultAllocatorDeinit(&alloc);- In
Write.c:699:
Str s = StrInit(&alloc);
StrAppendFmt(&s, "AAAAAAAA");
size before_length = StrLen(&s);
bool ok = StrPatchFmt(&s, 2, "{}", LVAL(1234));
ok = ok && StrLen(&s) == before_length;- In
Write.c:701:
size before_length = StrLen(&s);
bool ok = StrPatchFmt(&s, 2, "{}", LVAL(1234));
ok = ok && StrLen(&s) == before_length;
ok = ok && StrBegin(&s)[0] == 'A' && StrBegin(&s)[1] == 'A';
ok = ok && StrBegin(&s)[2] == '1' && StrBegin(&s)[3] == '2' && StrBegin(&s)[4] == '3' && StrBegin(&s)[5] == '4';- In
Write.c:708:
// Patch that would extend past the end must fail.
ok = ok && !StrPatchFmt(&s, 6, "{}", LVAL(9999));
ok = ok && StrLen(&s) == before_length;
ok = ok && StrBegin(&s)[6] == 'A' && StrBegin(&s)[7] == 'A';- In
Write.c:1088:
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));
bool ok = (out != NULL) && (StrLen(&s) == 50);
StrDeinit(&s);- In
Write.c:1335:
Str s = StrInitFromZstr("hello", &alloc);
StrAppendFmt(&output, "{.0}", s);
ok = ok && (StrLen(&output) == 0);
StrDeinit(&s);- In
Write.c:1653:
Zstr s = "Hello";
StrAppendFmt(&output, "{.0}", s);
bool ok = (StrLen(&output) == 0);
StrDeinit(&output);- In
Write.c:2562:
StrAppendFmt(&out, "{05}", (u32)42);
ok = ok && (ZstrCompare(StrBegin(&out), "00042") == 0);
ok = ok && (StrLen(&out) == 5);
StrDeinit(&out);- In
Write.c:2584:
StrAppendFmt(&out, "{05}", (u32)12345);
ok = ok && (ZstrCompare(StrBegin(&out), "12345") == 0);
ok = ok && (StrLen(&out) == 5);
StrDeinit(&out);- In
Write.c:2610:
StrAppendFmt(&out, "{06}", (i32)-42);
ok = ok && (ZstrCompare(StrBegin(&out), "-00042") == 0);
ok = ok && (StrLen(&out) == 6);
StrDeinit(&out);- In
Write.c:2667:
StrAppendFmt(&out, "{08}", (i32)-7);
ok = ok && (ZstrCompare(StrBegin(&out), "-0000007") == 0);
ok = ok && (StrLen(&out) == 8);
StrDeinit(&out);- In
Write.c:2692:
StrAppendFmt(&out, "{016x}", (u32)0xFF);
ok = ok && (ZstrCompare(StrBegin(&out), "00000000000000ff") == 0);
ok = ok && (StrLen(&out) == 16);
StrDeinit(&out);- In
Write.c:2889:
StrAppendFmt(&output, "{12}", v);
ok = ok && (ZstrCompare(StrBegin(&output), " 1.500000") == 0);
ok = ok && (StrLen(&output) == 12);
StrDeinit(&output);- In
Write.c:2932:
f64 v = 1.5;
StrAppendFmt(&output, "{12}", v);
ok = ok && (StrLen(&output) == 12);
StrDeinit(&output);- In
Write.c:3414:
f64 v = 1.5;
bool ok = StrAppendFmt(&out, "{8r}", v);
ok = ok && (StrLen(&out) > 0); // returns false under the mutant
StrDeinit(&out);- In
Write.c:3681:
StrAppendFmt(&out, "XX");
StrAppendFmt(&out, "{>5}", v);
bool ok = ZstrCompare(StrBegin(&out), " XX1.2") == 0 && StrLen(&out) == 7;
FloatDeinit(&v);- In
Write.c:3721:
StrAppendFmt(&out, "XX{>5}", bv);
bool ok = (StrLen(&out) == 7) && (ZstrCompare(StrBegin(&out), " XX1") == 0);
BitVecDeinit(&bv);- In
Write.c:3770:
Str o = StrInitFromZstr("hello", &alloc);
bool r = StrPatchFmt(&o, StrLen(&o), ""); // offset == length, empty render
bool ok = (r == true) && (ZstrCompare(StrBegin(&o), "hello") == 0);- In
Write.c:3861:
StrAppendFmt(&output, "{c}", v);
bool ok = (StrLen(&output) == 1) && (StrBegin(&output)[0] == 'Q');
StrDeinit(&output);- In
Write.c:3882:
StrAppendFmt(&output, "{c}", v);
bool ok = (StrLen(&output) == 4) && (ZstrCompare(StrBegin(&output), "BCDE") == 0);
StrDeinit(&output);- In
Write.c:4118:
StrAppendFmt(&s, "AAAAAAAA");
size before = StrLen(&s);
ok = ok && StrPatchFmt(&s, 2, "{}", LVAL(1234));
ok = ok && (StrLen(&s) == before);- In
Write.c:4120:
size before = StrLen(&s);
ok = ok && StrPatchFmt(&s, 2, "{}", LVAL(1234));
ok = ok && (StrLen(&s) == before);
ok = ok && StrBegin(&s)[2] == '1' && StrBegin(&s)[5] == '4';- In
Write.c:4719:
StrAppendFmt(&out, "{9}", (u32)3);
ok = ok && (ZstrCompare(StrBegin(&out), " 3") == 0);
ok = ok && (StrLen(&out) == 9);
StrDeinit(&out);- In
Write.c:5068:
Str s = StrInit(&dbg);
StrPushBackR(&s, (char)0x01);
StrPushBackR(&s, (char)0x4F); // multi-digit so StrLen(&hex)!=1 path
StrAppendFmt(&out, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&out), "0x01 0x4f") == 0);- In
Write.c:5473:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str out = StrInit(ALLOCATOR_OF(&dbg));
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Write.c:5485:
bool test_leak_write_f64_default_freed(void) {
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", 1e300) && (StrLen(&out) > 0);
LEAK_WRITE_EPILOGUE();
}- In
Write.c:5494:
Float f = FloatFromStr("12345678901234567890123456789012345678901234567890.5", ALLOCATOR_OF(&fa));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", f) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Write.c:5521:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{e}", v);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5547:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.3e}", v);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5573:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5600:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5627:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{x}", s);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5651:
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{}", v);
ok = ok && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5663:
bool test_leak_write_u64_temp_freed(void) {
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", (u64)12345678901234ull) && (StrLen(&out) > 0);
LEAK_WRITE_EPILOGUE();
}- In
Write.c:5669:
bool test_leak_write_f64_temp_freed(void) {
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", (f64)3.14159) && (StrLen(&out) > 0);
LEAK_WRITE_EPILOGUE();
}- In
Write.c:5678:
StrAppendFmt(&s, "payload");
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Write.c:5691:
Int v = IntFromStr("123456789012345678901234567890", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Write.c:5704:
Float v = FloatFromStr("2.718281828", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Write.c:5718:
BitVecResize(&v, 12);
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Read.c:647:
WriteFmt("Test 1 - :a (lowercase)\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:672:
WriteFmt("Test 1.1 - :as (lowercase string single word)\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:697:
WriteFmt("Test 2 - :A (uppercase)\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:766:
WriteFmt("Test 3 - :a with quoted string\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:791:
WriteFmt("Test 4 - :A with mixed alphanumeric\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:816:
WriteFmt("Test 5 - :c (no case conversion)\n");
WriteFmt("Input: '{}', Output: '", in);
for (size i = 0; i < StrLen(&result); i++) {
WriteFmt("{c}", StrBegin(&result)[i]);
}- In
Read.c:1727:
Str expected = StrInitFromZstr("ABC", &alloc);
bool ok = (StrLen(&s) == 3) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:1748:
Str expected = StrInitFromZstr("A", &alloc);
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:1769:
Str expected = StrInitFromZstr("A", &alloc); // uppercased
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:1793:
Str expected = StrInitFromZstr("ABC", &alloc);
bool ok = (StrLen(&s) == 3) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:1813:
Str expected = StrInitFromZstr("A", &alloc);
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:1833:
Str expected = StrInitFromZstr("A", &alloc); // uppercased
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:2047:
Zstr p = "\\n\\n#rest";
StrReadFmt(p, "{}#", out);
bool ok = (StrLen(&out) == 2) && (StrBegin(&out)[0] == '\n') && (StrBegin(&out)[1] == '\n');
StrDeinit(&out);
DefaultAllocatorDeinit(&a);- In
Read.c:2088:
Zstr p = "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""; // 50 'a' quoted
StrReadFmt(p, "{s}", out);
bool ok = (StrLen(&out) == 50);
StrDeinit(&out);
DefaultAllocatorDeinit(&a);- In
Read.c:2161:
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));
bool ok = (out != NULL) && (StrLen(&s) == 50);
StrDeinit(&s);
DefaultAllocatorDeinit(&alloc);- In
Ops.c:383:
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrLStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);
StrDeinit(&stripped);- In
Ops.c:400:
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrRStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);
StrDeinit(&stripped);- In
Ops.c:417:
Str s = StrInitFromZstr("x", &alloc);
Str stripped = StrStrip(&s, "*");
bool result = (StrLen(&stripped) == 1) && (ZstrCompare(StrBegin(&stripped), "x") == 0);
StrDeinit(&stripped);- In
Memory.c:38:
// Capacity should now be closer to the actual length
result = result && (StrCapacity(&s) < 100) && (StrCapacity(&s) >= StrLen(&s));
StrDeinit(&s);- In
Memory.c:79:
// Initial length should be 5
bool result = (StrLen(&s) == 5);
// Resize to a smaller length
- In
Memory.c:85:
// Length should now be 3 and content should be "Hel"
result = result && (StrLen(&s) == 3) && (ZstrCompareN(StrBegin(&s), "Hel", 3) == 0);
// Resize to a larger length
- In
Memory.c:92:
// Length should now be 8, and the first 3 characters should still be "Hel"
// The rest will be filled with zeros
result = result && (StrLen(&s) == 8) && (ZstrCompareN(StrBegin(&s), "Hel", 3) == 0);
StrDeinit(&s);- In
Memory.c:114:
// Length should still be 0
result = result && (StrLen(&s) == 0);
// Reserve less space (should be a no-op)
- In
Memory.c:136:
// Initial length should be 13
bool result = (StrLen(&s) == 13);
// Clear the string
- In
Memory.c:142:
// Length should now be 0, but capacity should remain
result = result && (StrLen(&s) == 0) && (StrCapacity(&s) >= 13);
// Data pointer should still be valid
- In
Memory.c:194:
// Check that the string is still empty
result = result && (StrLen(&s) == 0);
StrDeinit(&s);- In
Init.c:36:
// Check that it's initialized correctly
// A newly initialized string may have NULL data if capacity is 0
bool result = (StrLen(&s) == 0);
StrDeinit(&s);- In
Init.c:57:
// Check that it's initialized correctly
bool result = (StrLen(&s) == len && ZstrCompareN(StrBegin(&s), test_str, len) == 0 && StrBegin(&s)[len] == '\0');
StrDeinit(&s);- In
Init.c:77:
// Check that it's initialized correctly
bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
StrDeinit(&s);- In
Init.c:95:
ValidateStr(&s);
bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
StrDeinit(&s);- In
Init.c:116:
// Check that dst is initialized correctly
bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Init.c:138:
// Check that dst is initialized correctly
bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Init.c:211:
// Check that the copy was successful
bool result = (success && StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Init.c:238:
bool dst_allocator_matches = copied && (StrAllocator(&dst) == StrAllocator(&src));
bool result = copied && StrLen(&dup) == StrLen(&src) && StrLen(&dst) == StrLen(&src) &&
ZstrCompare(StrBegin(&dup), StrBegin(&src)) == 0 &&
ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0 && dup_allocator_matches && dst_allocator_matches;- In
Insert.c:48:
// Insert a character at the end
StrInsertR(&s, '.', StrLen(&s));
// Check that the character was inserted correctly
- In
Insert.c:279:
// Check that s2 was reset - data should be NULL, length should be 0
result = result && (StrLen(&s2) == 0 && StrBegin(&s2) == NULL);
StrDeinit(&s1);- In
Insert.c:303:
// Check that s2 was not reset
result = result && (StrLen(&s2) == 6 && ZstrCompare(StrBegin(&s2), " World") == 0);
StrDeinit(&s1);- In
Insert.c:327:
// s2 was zeroed on take per L-form contract
result = result && (StrLen(&s2) == 0 && StrBegin(&s2) == NULL);
StrDeinit(&s1);- In
Type.c:36:
StrPushBackR(&s, 'o');
bool result = (StrLen(&s) == 5 && ZstrCompare(StrBegin(&s), "Hello") == 0);
StrDeinit(&s);- In
Convert.c:1329:
StrFromF64(&s, F64_NAN, &config);
bool result = (StrLen(&s) == 3) && (ZstrCompare(StrBegin(&s), "nan") == 0);
if (!result)
WriteFmt(" FAIL: expected len 3 \"nan\", got len {} \"{}\"\n", StrLen(&s), StrBegin(&s));- In
Convert.c:1331:
bool result = (StrLen(&s) == 3) && (ZstrCompare(StrBegin(&s), "nan") == 0);
if (!result)
WriteFmt(" FAIL: expected len 3 \"nan\", got len {} \"{}\"\n", StrLen(&s), StrBegin(&s));
StrDeinit(&s);- In
Convert.c:1348:
StrFromF64(&s, F64_INFINITY, &config);
bool result = (StrLen(&s) == 3) && (ZstrCompare(StrBegin(&s), "inf") == 0);
if (!result)
WriteFmt(" FAIL: expected len 3 \"inf\", got len {} \"{}\"\n", StrLen(&s), StrBegin(&s));- In
Convert.c:1350:
bool result = (StrLen(&s) == 3) && (ZstrCompare(StrBegin(&s), "inf") == 0);
if (!result)
WriteFmt(" FAIL: expected len 3 \"inf\", got len {} \"{}\"\n", StrLen(&s), StrBegin(&s));
StrDeinit(&s);- In
Convert.c:1791:
i64 value = 7; // sentinel that must be overwritten to 0
bool success = StrToI64(&s, &value, NULL);
bool result = success && (value == 0) && (StrLen(&s) == 43);
StrDeinit(&s);- In
Foreach.c:189:
// The expected result depends on whether all characters are processed
bool success = false;
if (char_count == StrLen(&s)) {
success = (ZstrCompare(StrBegin(&result), "olleH") == 0);
WriteFmt(" (All characters were processed)\n");- In
Foreach.c:261:
// The expected result depends on whether all characters are processed
bool success = false;
if (char_count == StrLen(&s)) {
success = (ZstrCompare(StrBegin(&result), "olleH") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0); // All uppercase
- In
Foreach.c:303:
// The empty_result should remain empty
success = success && (StrLen(&empty_result) == 0);
StrDeinit(&s);- In
Foreach.c:421:
// Use StrForeachInRangeIdx which captures the 'end' parameter at the start
// Even if we shrink the string, the loop will continue until idx reaches the fixed end
size original_length = StrLen(&s); // Capture this as 12
StrForeachInRangeIdx(&s, chr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);- In
Foreach.c:423:
size original_length = StrLen(&s); // Capture this as 12
StrForeachInRangeIdx(&s, chr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);
// When we reach idx=4, drastically shrink the string to length 3
- In
Foreach.c:429:
if (idx == 4) {
StrResize(&s, 3); // Shrink to only 3 characters
WriteFmt("String resized to length {}, idx={}...\n", StrLen(&s), idx);
}- In
Foreach.c:458:
// Use StrForeachInRangeIdx with a fixed range that will become invalid
// when we delete characters during iteration
size original_length = StrLen(&s); // Capture this as 11
StrForeachInRangeIdx(&s, chr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);- In
Foreach.c:460:
size original_length = StrLen(&s); // Capture this as 11
StrForeachInRangeIdx(&s, chr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);
// When we reach idx=3, delete several characters from the beginning
- In
Foreach.c:466:
if (idx == 3) {
StrDeleteRange(&s, 0, 6); // Remove first 6 characters
WriteFmt("Deleted first 6 characters, new length={}, idx={}...\n", StrLen(&s), idx);
}- In
Foreach.c:495:
// StrForeachReverseIdx (VecForeachReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
StrForeachReverseIdx(&s, chr, idx) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);
// When we reach idx=10, drastically shrink the string
- In
Foreach.c:502:
if (idx == 10) {
StrResize(&s, 4); // Shrink to only 4 characters
WriteFmt("String resized to length {} during reverse iteration... idx = {}\n", StrLen(&s), idx);
}- In
Foreach.c:530:
// StrForeachPtrIdx (VecForeachPtrIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
StrForeachPtrIdx(&s, chr_ptr, idx) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), *chr_ptr);
// When we reach idx=4, delete most characters from the string
- In
Foreach.c:536:
if (idx == 4) {
StrResize(&s, 4); // Shrink to only 4 characters (valid indices: 0,1,2,3)
WriteFmt("String resized to length {}, current idx={} is now out of bounds...\n", StrLen(&s), idx);
}- In
Foreach.c:565:
// StrForeachReversePtrIdx (VecForeachPtrReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
StrForeachReversePtrIdx(&s, chr_ptr, idx) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), *chr_ptr);
// When we reach idx=12, shrink the string significantly
- In
Foreach.c:570:
if (idx == 12) {
StrResize(&s, 5); // Shrink to only 5 characters
WriteFmt("String resized to length {} during reverse ptr iteration... idx = {}\n", StrLen(&s), idx);
}- In
Foreach.c:598:
// Use StrForeachPtrInRangeIdx with a fixed range that becomes invalid when we modify the string
size original_length = StrLen(&s); // Capture this as 32
StrForeachPtrInRangeIdx(&s, chr_ptr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), *chr_ptr);- In
Foreach.c:600:
size original_length = StrLen(&s); // Capture this as 32
StrForeachPtrInRangeIdx(&s, chr_ptr, idx, 0, original_length) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), *chr_ptr);
// When we reach idx=8, delete several characters
- In
Foreach.c:605:
if (idx == 8) {
StrDeleteRange(&s, 0, 20); // Remove first 20 characters
WriteFmt("Deleted first 20 characters, new length={}, idx = {}...\n", StrLen(&s), idx);
}- In
Foreach.c:611:
// loop will terminate automatically
if (idx >= StrLen(&s)) {
LOG_ERROR("Should've terminated");
StrDeinit(&s);- In
Foreach.c:634:
// Basic StrForeachIdx (VecForeachIdx) now has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
StrForeachIdx(&s, chr, idx) {
WriteFmt("Accessing idx {} (s.length={}): '{c}'\n", idx, StrLen(&s), chr);
// When we reach idx=3, drastically shrink the string
- In
Foreach.c:642:
WriteFmt(
"String resized to length {}, but basic foreach iteration continues... idx = {}\n",
StrLen(&s),
idx
);- In
Access.c:20:
// Test StrLen and StrEmpty functions
bool test_str_len_empty(void) {
WriteFmt("Testing StrLen and StrEmpty\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:26:
Str s = StrInit(&alloc);
bool result = (StrLen(&s) == 0);
result = result && StrEmpty(&s);- In
Access.c:32:
StrPushBackR(&s, 'i');
result = result && (StrLen(&s) == 2);
result = result && !StrEmpty(&s);- In
Access.c:36:
StrClear(&s);
result = result && (StrLen(&s) == 0);
result = result && StrEmpty(&s);- In
Backtrace.c:41:
// (Apple's C mangling prepends `_`; substring search matches both
// "bt_capture_with_helper" and "_bt_capture_with_helper".)
bool ok = StrLen(&rendered) > 0 && ZstrFindSubstring(StrBegin(&rendered), "bt_capture_with_helper") != NULL &&
ZstrFindSubstring(StrBegin(&rendered), "bt_capture_outer") != NULL;- In
Backtrace.c:80:
FormatStackTrace(&rendered, &frames, alloc_base);
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_with_helper") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_outer") != NULL;- In
Backtrace.c:111:
// Should also contain the helper name through the shared resolver.
bool ok = StrLen(&out) > 0 && ZstrFindSubstring(StrBegin(&out), "bt_capture_with_helper") != NULL;
StrDeinit(&out);- In
Backtrace.c:153:
// unwound across at least two real-code frames.
bool ok = n >= 2;
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_inner") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_outer") != NULL;- In
SysDns.c:81:
}
Str s = SocketAddrFormat(ad, a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);
return ok;- In
SysDns.c:91:
}
Str s = SocketAddrFormat(ad, a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);
return ok;- In
SysDns.c:118:
static const HostsEntry *find_host(HostsTable *t, Zstr name) {
VecForeachPtr(t, e) {
if (StrLen(&e->name) > 0 && ZstrCompare(StrBegin(&e->name), name) == 0) {
return e;
}- In
SysDns.c:135:
}
Str s = SocketAddrFormat(VecPtrAt(&r->nameservers, i), a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);
return ok;- In
SysDns.c:223:
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "203.0.113.7:9999") == 0;
StrDeinit(&s);
}- In
SysDns.c:247:
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;
StrDeinit(&s);
}- In
SysDns.c:272:
VecForeachPtr(&out, ad) {
Str s = SocketAddrFormat(ad, a);
u64 L = StrLen(&s);
if (L < 3 || StrBegin(&s)[L - 1] != '3' || StrBegin(&s)[L - 2] != '5' || StrBegin(&s)[L - 3] != ':') {
ok = false;- In
SysDns.c:300:
if (ok) {
Str s = SocketAddrFormat(&one, a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "127.0.0.1:80") == 0;
StrDeinit(&s);
}- In
SysDns.c:1294:
resolver_init_empty(&r, a);
Str path = write_temp(a, "1.2.3.4 lenhost\n");
u64 plen = StrLen(&path);
Str smeared = StrInitFromStr(&path, a);- In
SysDns.c:1316:
Str path = write_temp(a, "1.2.3.4 leakhost\n");
u64 plen = StrLen(&path);
size baseline = DebugAllocatorLiveCount(&alloc);- In
SysDns.c:1438:
"nameserver 8.8.8.8\n"
);
bool added = DnsResolverAddPath(&r, StrBegin(&path), StrLen(&path));
bool ok = added && VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "zlhost"), 1, 2, 3, 4) &&- In
SysDns.c:1458:
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver 4.3.2.1\n");
bool added = DnsResolverAddResolvPath(&r, StrBegin(&path), StrLen(&path));
bool ok = added && VecLen(&r.nameservers) == 1 && ns_fmt_is(&r, 0, a, "4.3.2.1:53") && VecLen(&r.hosts) == 0;- In
Socket.c:103:
}
Str rendered = SocketAddrFormat(&addr, alloc_base);
ok = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "127.0.0.1:8080") == 0;
StrDeinit(&rendered);
}- In
Socket.c:114:
}
Str rendered = SocketAddrFormat(&addr, alloc_base);
ok = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "[::1]:8080") == 0;
StrDeinit(&rendered);
}- In
Socket.c:647:
if (ok) {
Str r = SocketAddrFormat(&addr, a);
ok = StrLen(&r) > 0 && ZstrCompare(StrBegin(&r), expect) == 0;
StrDeinit(&r);
}- In
Socket.c:786:
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "1.2.3.4:80") == 0;
StrDeinit(&s);- In
Socket.c:803:
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "10.0.0.1:4660") == 0;
StrDeinit(&s);- In
Socket.c:832:
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "[2001:db8::1]:443") == 0;
StrDeinit(&s);- In
Socket.c:849:
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "[::1]:8080") == 0;
StrDeinit(&s);- In
Socket.c:935:
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "127.0.0.1:4660") == 0;
StrDeinit(&s);- In
Socket.c:969:
// Rendered "127.0.0.1:<port>" with a nonzero ephemeral port.
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0;
if (ok) {
Zstr rendered = StrBegin(&s);- In
Socket.c:1172:
Str peer = SocketAddrFormat(&server.peer, a);
Zstr p = StrBegin(&peer);
ok = ok && StrLen(&peer) > 0 && p[0] == '1' && p[1] == '2' && p[2] == '7' && p[3] == '.';
StrDeinit(&peer);
}- In
Socket.c:1264:
// formats to "127.0.0.1:<port>" with port in 1..65535.
Str rendered = SocketAddrFormat(&local, a);
bool ok = StrLen(&rendered) > 0;
// must start with the loopback host and a colon, then a non-"0" port.
ok = ok && local.family == SOCKET_FAMILY_INET;- In
Socket.c:1578:
SocketAddr empty = {0};
Str r = SocketAddrFormat(&empty, a);
ok = ok && StrLen(&r) == 0;
StrDeinit(&r);
}- In
Socket.c:1616:
if (ok) {
Str r = SocketAddrFormat(&addr, a);
ok = StrLen(&r) > 0 && ZstrCompare(StrBegin(&r), expect) == 0;
StrDeinit(&r);
}- In
Socket.c:1675:
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0 && ZstrCompareN(StrBegin(&s), "127.0.0.1:", 10u) == 0;
StrDeinit(&s);- In
Dns.c:2087:
ok = ok && (r->type == DNS_TYPE_CNAME);
// Heap-backed target ("example.com") -- the Str the dropped StrDeinit leaks.
ok = ok && (StrLen(&r->target) == 11);
DnsResponseDeinit(&resp);- In
Http.c:27:
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (req.method == HTTP_REQUEST_METHOD_GET) && (StrLen(&req.url) == 11) &&
(ZstrCompare(StrBegin(&req.url), "/index.html") == 0) && (VecLen(&req.headers) == 2) &&
(ZstrCompare(next, "body-bytes") == 0);- In
Http.c:56:
// - includes a Content-Length: 11 (length of "<h1>hi</h1>")
// - ends with the body
bool ok = StrLen(&wire) > 0 && ZstrFindSubstring(StrBegin(&wire), "HTTP/1.1 200 OK\r\n") == StrBegin(&wire) &&
ZstrFindSubstring(StrBegin(&wire), "Content-Type: text/html\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "Content-Length: 11\r\n") != NULL &&- In
Http.c:226:
ok = ok && (res != NULL) && (response.status_code == HTTP_RESPONSE_CODE_OK) &&
(response.content_type == HTTP_CONTENT_TYPE_TEXT_PLAIN) && (StrLen(&response.body) == ZstrLen(payload)) &&
(ZstrCompare(StrBegin(&response.body), payload) == 0);- In
Http.c:252:
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));
ok = ok && (res != NULL) && (response.status_code == HTTP_RESPONSE_CODE_OK) && (StrLen(&response.body) == 0);
FileRemove(StrBegin(&path));- In
Http.c:332:
HttpRequest req = HttpRequestInit(adbg);
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (StrLen(&req.url) > 0);
ok = ok && (DebugAllocatorLiveCount(&dbg) > 0);- In
Read.Simple.c:80:
if (StrCmp(&name, "Alice", 5) != 0) {
WriteFmt("[DEBUG] Name check failed: expected 'Alice', got '");
for (size i = 0; i < StrLen(&name); i++) {
WriteFmt("{c}", StrBegin(&name)[i]);
}- In
Read.Simple.c:89:
if (StrCmp(&city, "New York", 8) != 0) {
WriteFmt("[DEBUG] City check failed: expected 'New York', got '");
for (size i = 0; i < StrLen(&city); i++) {
WriteFmt("{c}", StrBegin(&city)[i]);
} if (StrCmp(&person.name, "Bob", 3) != 0) {
WriteFmt("[DEBUG] Person name check failed: expected 'Bob', got '");
for (size i = 0; i < StrLen(&person.name); i++) {
WriteFmt("{c}", StrBegin(&person.name)[i]);
} if (StrCmp(&config.log_level, "INFO", 4) != 0) {
WriteFmt("[DEBUG] Log level check failed: expected 'INFO', got '");
for (size i = 0; i < StrLen(&config.log_level); i++) {
WriteFmt("{c}", StrBegin(&config.log_level)[i]);
} if (StrCmp(lang1, "C", 1) != 0) {
WriteFmt("[DEBUG] Language 1 check failed: expected 'C', got '");
for (size i = 0; i < StrLen(lang1); i++) {
WriteFmt("{c}", StrBegin(lang1)[i]);
} if (StrCmp(lang2, "Python", 6) != 0) {
WriteFmt("[DEBUG] Language 2 check failed: expected 'Python', got '");
for (size i = 0; i < StrLen(lang2); i++) {
WriteFmt("{c}", StrBegin(lang2)[i]);
} if (StrCmp(lang3, "Rust", 4) != 0) {
WriteFmt("[DEBUG] Language 3 check failed: expected 'Rust', got '");
for (size i = 0; i < StrLen(lang3); i++) {
WriteFmt("{c}", StrBegin(lang3)[i]);
} if (StrCmp(&data.user.name, "Charlie", 7) != 0) {
WriteFmt("[DEBUG] User name check failed: expected 'Charlie', got '");
for (size i = 0; i < StrLen(&data.user.name); i++) {
WriteFmt("{c}", StrBegin(&data.user.name)[i]);
} if (StrCmp(&data.user.email, "charlie@example.com", 19) != 0) {
WriteFmt("[DEBUG] User email check failed: expected 'charlie@example.com', got '");
for (size i = 0; i < StrLen(&data.user.email); i++) {
WriteFmt("{c}", StrBegin(&data.user.email)[i]);
} if (StrCmp(&product.name, "Laptop", 6) != 0) {
WriteFmt("[DEBUG] Product name check failed: expected 'Laptop', got '");
for (size i = 0; i < StrLen(&product.name); i++) {
WriteFmt("{c}", StrBegin(&product.name)[i]);
} if (StrCmp(tag1, "electronics", 11) != 0) {
WriteFmt("[DEBUG] Tag 1 check failed: expected 'electronics', got '");
for (size i = 0; i < StrLen(tag1); i++) {
WriteFmt("{c}", StrBegin(tag1)[i]);
} if (StrCmp(tag2, "computers", 9) != 0) {
WriteFmt("[DEBUG] Tag 2 check failed: expected 'computers', got '");
for (size i = 0; i < StrLen(tag2); i++) {
WriteFmt("{c}", StrBegin(tag2)[i]);
} if (StrCmp(tag3, "portable", 8) != 0) {
WriteFmt("[DEBUG] Tag 3 check failed: expected 'portable', got '");
for (size i = 0; i < StrLen(tag3); i++) {
WriteFmt("{c}", StrBegin(tag3)[i]);
}
// Remove spaces and newlines from both strings for comparison
for (size i = 0; i < StrLen(output); i++) {
char c = StrBegin(output)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { }
for (size i = 0; i < StrLen(&expected_str); i++) {
char c = StrBegin(&expected_str)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { WriteFmtLn("[DEBUG] JSON comparison failed");
WriteFmt("[DEBUG] Expected: '");
for (u64 i = 0; i < StrLen(&expected_clean); i++) {
WriteFmt("{c}", StrBegin(&expected_clean)[i]);
}
WriteFmt("[DEBUG] Got: '");
for (u64 i = 0; i < StrLen(&output_clean); i++) {
WriteFmt("{c}", StrBegin(&output_clean)[i]);
}
// For large numbers, just check that valid JSON was produced
if (StrLen(&json) > 0 && StrBegin(&json)[0] == '{' && StrBegin(&json)[StrLen(&json) - 1] == '}') {
WriteFmtLn("[DEBUG] Large numbers test passed - produced valid JSON structure");
} else {
// Just verify that valid JSON structure was produced
if (StrLen(&json) > 0 && StrBegin(&json)[0] == '{' && StrBegin(&json)[StrLen(&json) - 1] == '}') {
WriteFmtLn("[DEBUG] Special characters test passed - produced valid JSON");
} else {
// Verify valid JSON structure was produced
if (StrLen(&json) > 0 && StrBegin(&json)[0] == '{' && StrBegin(&json)[StrLen(&json) - 1] == '}') {
WriteFmtLn("[DEBUG] Escape sequences test passed - produced valid JSON");
} else {
// Check for reasonable float formatting (exact precision may vary)
if (StrLen(&json) > 0 && StrBegin(&json)[0] == '{' && StrBegin(&json)[StrLen(&json) - 1] == '}') {
WriteFmtLn("[DEBUG] Boundary floats test passed - JSON: {}", json);
} else {
// Remove whitespace from both strings for comparison
for (u64 i = 0; i < StrLen(output); i++) {
char c = StrBegin(output)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { }
for (u64 i = 0; i < StrLen(&expected_str); i++) {
char c = StrBegin(&expected_str)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { WriteFmt("[DEBUG] JSON comparison failed\n");
WriteFmt("[DEBUG] Expected: '");
for (u64 i = 0; i < StrLen(&expected_clean); i++) {
WriteFmt("{c}", StrBegin(&expected_clean)[i]);
} WriteFmt("'\n");
WriteFmt("[DEBUG] Got: '");
for (u64 i = 0; i < StrLen(&output_clean); i++) {
WriteFmt("%c", StrBegin(&output_clean)[i]);
} if (StrCmp(&data.name, "test", 4) != 0) {
WriteFmt("[DEBUG] Name check failed: expected 'test', got '");
for (size i = 0; i < StrLen(&data.name); i++) {
WriteFmt("{c}", StrBegin(&data.name)[i]);
} if (StrCmp(&data.user.profile.name, "Alice", 5) != 0) {
WriteFmt("[DEBUG] Profile name check failed: expected 'Alice', got '");
for (u64 i = 0; i < StrLen(&data.user.profile.name); i++) {
WriteFmt("{}", StrBegin(&data.user.profile.name)[i]);
} if (StrCmp(&data.status, "active", 6) != 0) {
WriteFmt("[DEBUG] Status check failed: expected 'active', got '");
for (size i = 0; i < StrLen(&data.status); i++) {
WriteFmt("{}", StrBegin(&data.status)[i]);
} if (StrCmp(&data.company.departments.engineering.head, "John", 4) != 0) {
WriteFmt("[DEBUG] Engineering head check failed: expected 'John', got '");
for (size i = 0; i < StrLen(&data.company.departments.engineering.head); i++) {
WriteFmt("{c}", StrBegin(&data.company.departments.engineering.head)[i]);
} if (StrCmp(&data.company.name, "TechCorp", 8) != 0) {
WriteFmt("[DEBUG] Company name check failed: expected 'TechCorp', got '");
for (size i = 0; i < StrLen(&data.company.name); i++) {
WriteFmt("{c}", StrBegin(&data.company.name)[i]);
} if (StrCmp(&response.message, "Success", 7) != 0) {
WriteFmt("[DEBUG] Message check failed: expected 'Success', got '");
for (size i = 0; i < StrLen(&response.message); i++) {
WriteFmt("{c}", StrBegin(&response.message)[i]);
} if (StrCmp(&sym->analysis_name, "test_analysis", 13) != 0) {
WriteFmt("[DEBUG] Analysis name check failed: expected 'test_analysis', got '");
for (size i = 0; i < StrLen(&sym->analysis_name); i++) {
WriteFmt("{c}", StrBegin(&sym->analysis_name)[i]);
} WriteFmt(
"[DEBUG] Function name check failed: expected 'main_func', got string of length {}\n",
StrLen(&sym->function_name)
);
success = false; if (StrCmp(&sym->sha256, "abc123", 6) != 0) {
WriteFmt("[DEBUG] SHA256 check failed: expected 'abc123', got '");
for (size i = 0; i < StrLen(&sym->sha256); i++) {
WriteFmt("{c}", StrBegin(&sym->sha256)[i]);
} if (StrCmp(&sym->function_mangled_name, "_Z4main", 7) != 0) {
WriteFmt("[DEBUG] Mangled name check failed: expected '_Z4main', got '");
for (size i = 0; i < StrLen(&sym->function_mangled_name); i++) {
WriteFmt("{c}", StrBegin(&sym->function_mangled_name)[i]);
} if (StrCmp(&info.name, "test_func", 9) != 0) {
WriteFmt("[DEBUG] Function name check failed: expected 'test_func', got '");
for (size i = 0; i < StrLen(&info.name); i++) {
WriteFmt("{}", StrBegin(&info.name)[i]);
} if (StrCmp(&info.name, "test_model", 10) != 0) {
WriteFmt("[DEBUG] Model name check failed: expected 'test_model', got '");
for (size i = 0; i < StrLen(&info.name); i++) {
WriteFmt("{}", StrBegin(&info.name)[i]);
} if (StrCmp(&result.binary_name, "test_binary", 11) != 0) {
WriteFmt("[DEBUG] Binary name check failed: expected 'test_binary', got '");
for (size i = 0; i < StrLen(&result.binary_name); i++) {
WriteFmt("{c}", StrBegin(&result.binary_name)[i]);
} if (StrCmp(&result.sha256, "abc123", 6) != 0) {
WriteFmt("[DEBUG] SHA256 check failed: expected 'abc123', got '");
for (size i = 0; i < StrLen(&result.sha256); i++) {
WriteFmt("{c}", StrBegin(&result.sha256)[i]);
} if (StrCmp(&result.model_name, "test_model", 10) != 0) {
WriteFmt("[DEBUG] Model name check failed: expected 'test_model', got '");
for (size i = 0; i < StrLen(&result.model_name); i++) {
WriteFmt("{c}", StrBegin(&result.model_name)[i]);
} if (StrCmp(&result.owned_by, "user1", 5) != 0) {
WriteFmt("[DEBUG] Owned by check failed: expected 'user1', got '");
for (size i = 0; i < StrLen(&result.owned_by); i++) {
WriteFmt("{c}", StrBegin(&result.owned_by)[i]);
}
WriteFmt("[DEBUG] Parsed status: {}, message: '", response.status ? "true" : "false");
for (size i = 0; i < StrLen(&response.message); i++) {
WriteFmt("{c}", StrBegin(&response.message)[i]);
} if (StrCmp(&response.message, "Success", 7) != 0) {
WriteFmt("[DEBUG] Message check failed: expected 'Success', got '");
for (size i = 0; i < StrLen(&response.message); i++) {
WriteFmt("{c}", StrBegin(&response.message)[i]);
} if (StrCmp(&sym->analysis_name, "test_analysis", 13) != 0) {
WriteFmt("[DEBUG] Analysis name check failed: expected 'test_analysis', got '");
for (size i = 0; i < StrLen(&sym->analysis_name); i++) {
WriteFmt("{c}", StrBegin(&sym->analysis_name)[i]);
} WriteFmt(
"[DEBUG] Function name check failed: expected 'main_func', got string of length {}\n",
StrLen(&sym->function_name)
);
success = false; if (StrCmp(&sym->sha256, "abc123", 6) != 0) {
WriteFmt("[DEBUG] SHA256 check failed: expected 'abc123', got '");
for (size i = 0; i < StrLen(&sym->sha256); i++) {
WriteFmt("{c}", StrBegin(&sym->sha256)[i]);
} if (StrCmp(&sym->function_mangled_name, "_Z4main", 7) != 0) {
WriteFmt("[DEBUG] Mangled name check failed: expected '_Z4main', got '");
for (size i = 0; i < StrLen(&sym->function_mangled_name); i++) {
WriteFmt("{c}", StrBegin(&sym->function_mangled_name)[i]);
}
WriteFmt("[DEBUG] Parsed status: {}, message: '", response.status ? "true" : "false");
for (size i = 0; i < StrLen(&response.message); i++) {
WriteFmt("{c}", StrBegin(&response.message)[i]);
} if (StrCmp(&response.message, "Success", 7) != 0) {
WriteFmt("[DEBUG] Message check failed: expected 'Success', got '");
for (u64 i = 0; i < StrLen(&response.message); i++) {
WriteFmt("{c}", StrBegin(&response.message)[i]);
} if (StrCmp(&sym->analysis_name, "test_analysis", 13) != 0) {
WriteFmt("[DEBUG] Analysis name check failed: expected 'test_analysis', got '");
for (size i = 0; i < StrLen(&sym->analysis_name); i++) {
WriteFmt("{}", StrBegin(&sym->analysis_name)[i]);
} if (StrCmp(&sym->function_name, "main_func", 9) != 0) {
WriteFmt("[DEBUG] Function name check failed: expected 'main_func', got '");
for (size i = 0; i < StrLen(&sym->function_name); i++) {
WriteFmt("{c}", StrBegin(&sym->function_name)[i]);
} if (StrCmp(&sym->sha256, "abc123", 6) != 0) {
WriteFmt("[DEBUG] SHA256 check failed: expected 'abc123', got '");
for (size i = 0; i < StrLen(&sym->sha256); i++) {
WriteFmt("{}", StrBegin(&sym->sha256)[i]);
} if (StrCmp(&sym->function_mangled_name, "_Z4main", 7) != 0) {
WriteFmt("[DEBUG] Mangled name check failed: expected '_Z4main', got '");
for (size i = 0; i < StrLen(&sym->function_mangled_name); i++) {
WriteFmt("{c}", StrBegin(&sym->function_mangled_name)[i]);
}
// Remove spaces and newlines from both strings for comparison
for (size i = 0; i < StrLen(output); i++) {
char c = StrBegin(output)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { }
for (size i = 0; i < StrLen(&expected_str); i++) {
char c = StrBegin(&expected_str)[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') { WriteFmt("[DEBUG] JSON comparison failed\n");
WriteFmt("[DEBUG] Expected: '");
for (size i = 0; i < StrLen(&expected_clean); i++) {
WriteFmt("{c}", StrBegin(&expected_clean)[i]);
} WriteFmt("'\n");
WriteFmt("[DEBUG] Got: '");
for (size i = 0; i < StrLen(&output_clean); i++) {
WriteFmt("{c}", StrBegin(&output_clean)[i]);
} });
if (StrLen(&obj.name) == 0 && StrLen(&obj.description) == 0) {
WriteFmt("[DEBUG] Empty string test passed - both strings empty\n");
} else { WriteFmt(
"[DEBUG] Empty string test FAILED - name len: {}, desc len: {}\n",
StrLen(&obj.name),
StrLen(&obj.description)
); "[DEBUG] Empty string test FAILED - name len: {}, desc len: {}\n",
StrLen(&obj.name),
StrLen(&obj.description)
);
success = false; Zstr msg_want = "Hello, \"World\"!";
Zstr data_want = "line1\nline2\ttab";
if (StrLen(&obj.path) != ZstrLen(path_want) || MemCompare(StrBegin(&obj.path), path_want, StrLen(&obj.path)) != 0) {
WriteFmtLn("[DEBUG] Special characters FAILED: path content wrong");
success = false; success = false;
}
if (StrLen(&obj.message) != ZstrLen(msg_want) ||
MemCompare(StrBegin(&obj.message), msg_want, StrLen(&obj.message)) != 0) {
WriteFmtLn("[DEBUG] Special characters FAILED: message content wrong"); }
if (StrLen(&obj.message) != ZstrLen(msg_want) ||
MemCompare(StrBegin(&obj.message), msg_want, StrLen(&obj.message)) != 0) {
WriteFmtLn("[DEBUG] Special characters FAILED: message content wrong");
success = false; success = false;
}
if (StrLen(&obj.data) != ZstrLen(data_want) || MemCompare(StrBegin(&obj.data), data_want, StrLen(&obj.data)) != 0) {
WriteFmtLn("[DEBUG] Special characters FAILED: data content wrong");
success = false; };
for (u64 i = 0; i < sizeof(expect) / sizeof(expect[0]); i++) {
if (StrLen(expect[i].got) != 1 || *StrBegin(expect[i].got) != expect[i].want) {
WriteFmtLn(
"[DEBUG] Escape sequences FAILED: {} decoded wrong (len={})", "[DEBUG] Escape sequences FAILED: {} decoded wrong (len={})",
expect[i].name,
StrLen(expect[i].got)
);
success = false; success = false;
}
if (StrLen(&out) != 0) {
WriteFmtLn("[DEBUG] JReadString left partial output on rejected \\u escape: len={}", StrLen(&out));
success = false; }
if (StrLen(&out) != 0) {
WriteFmtLn("[DEBUG] JReadString left partial output on rejected \\u escape: len={}", StrLen(&out));
success = false;
} success = false;
}
if (StrLen(&out) != 5 || MemCompare(StrBegin(&out), "plain", 5) != 0) {
WriteFmtLn("[DEBUG] JReadString decoded plain string wrong: len={}", StrLen(&out));
success = false; }
if (StrLen(&out) != 5 || MemCompare(StrBegin(&out), "plain", 5) != 0) {
WriteFmtLn("[DEBUG] JReadString decoded plain string wrong: len={}", StrLen(&out));
success = false;
}- In
RoundTrip.c:337:
// Compare values
if (StrLen(&parsed.empty) == StrLen(&original.empty) && StrCmp(&original.simple, &parsed.simple) == 0 &&
StrCmp(&original.with_spaces, &parsed.with_spaces) == 0 &&
StrCmp(&original.with_special, &parsed.with_special) == 0) {- In
RoundTrip.c:428:
if (strings_match) {
for (size i = 0; i < VecLen(&original_strings); i++) {
if (StrLen(VecPtrAt(&original_strings, i)) != StrLen(VecPtrAt(&parsed_strings, i)) ||
(StrLen(VecPtrAt(&original_strings, i)) &&
StrCmp(VecPtrAt(&original_strings, i), VecPtrAt(&parsed_strings, i)) != 0)) {- In
RoundTrip.c:429:
for (size i = 0; i < VecLen(&original_strings); i++) {
if (StrLen(VecPtrAt(&original_strings, i)) != StrLen(VecPtrAt(&parsed_strings, i)) ||
(StrLen(VecPtrAt(&original_strings, i)) &&
StrCmp(VecPtrAt(&original_strings, i), VecPtrAt(&parsed_strings, i)) != 0)) {
strings_match = false;- In
RoundTrip.c:716:
// Compare empty containers
if (StrLen(&parsed_str) == 0 && VecLen(&parsed_numbers) == 0 && VecLen(&parsed_strings) == 0 &&
!found_empty_object) { // Empty object should not execute the content
WriteFmtLn("[DEBUG] Empty containers round-trip test passed");- In
RoundTrip.c:723:
WriteFmtLn(
"[DEBUG] String length: {}, numbers: {}, strings: {}, found_obj: {}\n",
StrLen(&parsed_str),
VecLen(&parsed_numbers),
VecLen(&parsed_strings),- In
Parse.c:178:
v = KvConfigGetPtr(&cfg, "k");
result = result && v && (StrLen(v) == 0);
StrDeinit(&src);- In
Parse.c:364:
result = result && user && StrCmp(user, "root") == 0;
result = result && greet && StrCmp(greet, "hello world") == 0;
result = result && empty && (StrLen(empty) == 0);
StrDeinit(&src);
Last updated on