ZstrCompare
Description
Compare two strings lexicographically (case-sensitive).
Parameters
| Name | Direction | Description |
|---|---|---|
s1 |
in | First string. |
s2 |
in | Second string. |
Success
Returns 0 if equal, <0 if s1<s2, >0 if s1>s2.
Failure
Aborts via LOG_FATAL when either string pointer is NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Zstr.c:22:
}
i32 ZstrCompare(Zstr s1, Zstr s2) {
if (!s1 || !s2) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:67:
}
cmp = ZstrCompare(*a, *b);
if (cmp < 0) {
return -1;- In
ArgParse.c:56:
static bool zstr_eq(Zstr a, Zstr b) {
return a && b && ZstrCompare(a, b) == 0;
}- In
Str.c:215:
i32 str_cmp_zstr(const Str *s, Zstr other) {
ValidateStr(s);
return ZstrCompare(StrBegin(s), other);
}- In
PdbCache.c:96:
for (size i = 0; i < VecLen(&self->entries); ++i) {
PdbCacheEntry *e = VecPtrAt(&self->entries, i);
if (StrBegin(&e->module_path) && ZstrCompare(StrBegin(&e->module_path), module_path) == 0) {
return e;
} // different positions of the raw buffer if the kernel
// generated separate copies — fall back to string compare.
if (e->path && path && ZstrCompare(e->path, path) == 0) {
return e;
}- In
Dir.c:98:
do {
// Skip "." and ".." entries
if (ZstrCompare(findFileData.cFileName, ".") == 0 || ZstrCompare(findFileData.cFileName, "..") == 0) {
continue;
}- In
Dir.c:548:
DirEntry *e = VecPtrAt(&dc, i);
Zstr entry_nm = StrBegin(&e->name);
if (ZstrCompare(entry_nm, ".") == 0 || ZstrCompare(entry_nm, "..") == 0) {
continue;
}- In
MachoCache.c:42:
for (size i = 0; i < VecLen(&self->entries); ++i) {
MachoCacheEntry *e = VecPtrAt(&self->entries, i);
if (StrBegin(&e->module_path) && ZstrCompare(StrBegin(&e->module_path), module_path) == 0) {
return e;
}- In
Dns.c:503:
// 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
Http.c:63:
}
VecForeachPtr(headers, header) {
if (0 == ZstrCompare(StrBegin(&header->key), key)) {
return header;
}- In
MachO.c:489:
for (size i = 0; i < VecLen(&self->sections); ++i) {
const MachoSection *s = VecPtrAt(&self->sections, i);
if (ZstrCompare(s->segment, segment) == 0 && ZstrCompare(s->section, section) == 0) {
return s;
}- In
Elf.c:541:
for (u64 i = 0; i < VecLen(&self->sections); ++i) {
const ElfSection *s = VecPtrAt(&self->sections, i);
if (s->name && ZstrCompare(s->name, name) == 0) {
return s;
}- In
Pe.c:582:
for (size i = 0; i < VecLen(&self->sections); ++i) {
const PeSection *s = VecPtrAt(&self->sections, i);
if (ZstrCompare(s->name, name) == 0) {
return s;
}- In
Str.Remove.c:33:
// Check that the character was popped correctly
bool result = (c == 'o' && ZstrCompare(StrBegin(&s), "Hell") == 0);
// Pop another character without storing it - avoid passing NULL directly
- In
Str.Remove.c:40:
// Check that the character was removed
result = result && (ZstrCompare(StrBegin(&s), "Hel") == 0);
StrDeinit(&s);- In
Str.Remove.c:60:
// Check that the character was popped correctly
bool result = (c == 'H' && ZstrCompare(StrBegin(&s), "ello") == 0);
// Pop another character without storing it - avoid passing NULL directly
- In
Str.Remove.c:67:
// Check that the character was removed
result = result && (ZstrCompare(StrBegin(&s), "llo") == 0);
StrDeinit(&s);- In
Str.Remove.c:87:
// Check that the character was removed correctly
bool result = (c == 'l' && ZstrCompare(StrBegin(&s), "Helo") == 0);
// Remove another character without storing it - avoid passing NULL directly
- In
Str.Remove.c:94:
// Check that the character was removed
result = result && (ZstrCompare(StrBegin(&s), "Hlo") == 0);
StrDeinit(&s);- In
Str.Remove.c:117:
// Check that the characters were removed correctly
bool result = (ZstrCompare(buffer, " Worl") == 0 && ZstrCompare(StrBegin(&s), "Hellod") == 0);
// Remove another range without storing it - use a temporary buffer instead of NULL
- In
Str.Remove.c:124:
// Check that the characters were removed
result = result && (ZstrCompare(StrBegin(&s), "Hell") == 0);
StrDeinit(&s);- In
Str.Remove.c:143:
// Check that the character was deleted
bool result = (ZstrCompare(StrBegin(&s), "Hell") == 0);
// Delete another character
- In
Str.Remove.c:149:
// Check that the character was deleted
result = result && (ZstrCompare(StrBegin(&s), "Hel") == 0);
StrDeinit(&s);- In
Str.Remove.c:168:
// Check that the character was deleted
bool result = (ZstrCompare(StrBegin(&s), "Helo") == 0);
// Delete another character
- In
Str.Remove.c:174:
// Check that the character was deleted
result = result && (ZstrCompare(StrBegin(&s), "Hlo") == 0);
StrDeinit(&s);- In
Str.Remove.c:193:
// Check that the characters were deleted
bool result = (ZstrCompare(StrBegin(&s), "Hello") == 0);
// Delete another range
- In
Str.Remove.c:199:
// Check that the characters were deleted
result = result && (ZstrCompare(StrBegin(&s), "Heo") == 0);
StrDeinit(&s);- In
Http.c:24:
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:25:
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);
HttpHeader *host = HttpHeadersFind(&req.headers, "Host");- In
Http.c:28:
HttpHeader *host = HttpHeadersFind(&req.headers, "Host");
ok = ok && host && ZstrCompare(StrBegin(&host->value), "example.com") == 0;
HttpRequestDeinit(&req);- In
Str.Memory.c:164:
// Check that the string was reversed
bool result = (ZstrCompare(StrBegin(&s), "olleH") == 0);
// Test with an even-length string
- In
Str.Memory.c:174:
// Check that the string was reversed
result = result && (ZstrCompare(StrBegin(&s), "dcba") == 0);
// Test with a single-character string
- In
Str.Memory.c:184:
// Check that the string is unchanged
result = result && (ZstrCompare(StrBegin(&s), "a") == 0);
// Test with an empty string
result = result && !GraphHasEdge(&graph, blue, green);
result = result && !GraphHasEdge(&graph, red, blue);
result = result && (ZstrCompare(*GraphNodePtrAt(&graph, red), "red") == 0);
GraphDeinit(&graph);- In
Str.Ops.c:72:
// Test StrFind (Str * key) with match at end
Zstr found1 = StrFind(&haystack, &needle1);
bool result = (found1 != NULL && ZstrCompare(found1, "World") == 0);
// Test StrFind (Str * key) with match at beginning
- In
Str.Ops.c:76:
// Test StrFind (Str * key) with match at beginning
Zstr found2 = StrFind(&haystack, &needle2);
result = result && (found2 != NULL && ZstrCompare(found2, "Hello World") == 0);
// Test StrFind (Str * key) with no match
- In
Str.Ops.c:84:
// Test StrFind (Zstr key)
Zstr found4 = StrFind(&haystack, "World");
result = result && (found4 != NULL && ZstrCompare(found4, "World") == 0);
// Test StrFind (Cstr key, key_len)
- In
Str.Ops.c:172:
Str s1 = StrInitFromZstr("Hello World", &alloc);
StrReplace(&s1, "World", "Universe", 1);
bool result = (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
// Test multiple replacements
- In
Str.Ops.c:178:
s1 = StrInitFromZstr("Hello Hello Hello", &alloc);
StrReplace(&s1, "Hello", "Hi", 2);
result = result && (ZstrCompare(StrBegin(&s1), "Hi Hi Hello") == 0);
// Test Cstr-form (fixed-length views) - use the full "World" string instead of just "Wo"
- In
Str.Ops.c:184:
s1 = StrInitFromZstr("Hello World", &alloc);
StrReplace(&s1, "World", 5, "Universe", 8, 1);
result = result && (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
// Test Str-form
- In
Str.Ops.c:192:
Str replace = StrInitFromZstr("Universe", &alloc);
StrReplace(&s1, &find, &replace, 1);
result = result && (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
StrDeinit(&s1);- In
Str.Ops.c:213:
bool result = (VecLen(&split) == 3);
if (VecLen(&split) >= 3) {
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);- In
Str.Ops.c:214:
if (VecLen(&split) >= 3) {
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);
}- In
Str.Ops.c:215:
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);
}- In
Str.Ops.c:231:
char buffer1[10] = {0};
MemCopy(buffer1, iter1->data, StrIterLength(iter1));
result = result && (ZstrCompare(buffer1, "Hello") == 0);
StrIter *iter2 = VecPtrAt(&iters, 1);- In
Str.Ops.c:236:
char buffer2[10] = {0};
MemCopy(buffer2, iter2->data, StrIterLength(iter2));
result = result && (ZstrCompare(buffer2, "World") == 0);
StrIter *iter3 = VecPtrAt(&iters, 2);- In
Str.Ops.c:241:
char buffer3[10] = {0};
MemCopy(buffer3, iter3->data, StrIterLength(iter3));
result = result && (ZstrCompare(buffer3, "Test") == 0);
}- In
Str.Ops.c:259:
Str s1 = StrInitFromZstr(" Hello ", &alloc);
Str stripped = StrLStrip(&s1, NULL);
bool result = (ZstrCompare(StrBegin(&stripped), "Hello ") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:264:
// Test StrRStrip
stripped = StrRStrip(&s1, NULL);
result = result && (ZstrCompare(StrBegin(&stripped), " Hello") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:269:
// Test StrStrip
stripped = StrStrip(&s1, NULL);
result = result && (ZstrCompare(StrBegin(&stripped), "Hello") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:277:
stripped = StrLStrip(&s1, "*");
result = result && (ZstrCompare(StrBegin(&stripped), "Hello***") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:281:
stripped = StrRStrip(&s1, "*");
result = result && (ZstrCompare(StrBegin(&stripped), "***Hello") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:285:
stripped = StrStrip(&s1, "*");
result = result && (ZstrCompare(StrBegin(&stripped), "Hello") == 0);
StrDeinit(&stripped);- In
Int.Convert.c:49:
bool result = IntBitLength(&value) == 4;
result = result && (IntToU64(&value) == 13);
result = result && (ZstrCompare(StrBegin(&text), "1101") == 0);
StrDeinit(&text);- In
Int.Convert.c:70:
bool result = written == 4;
result = result && (MemCompare(out, bytes, sizeof(bytes)) == 0);
result = result && (ZstrCompare(StrBegin(&text), "cdef1234") == 0);
StrDeinit(&text);- In
Int.Convert.c:91:
bool result = written == 4;
result = result && (MemCompare(out, bytes, sizeof(bytes)) == 0);
result = result && (ZstrCompare(StrBegin(&text), "12345678") == 0);
StrDeinit(&text);
bool result = IntToU64(&value) == 11;
result = result && (ZstrCompare(StrBegin(&text), "1011") == 0);
StrDeinit(&text); Str text = IntToStr(&value);
bool result = ZstrCompare(StrBegin(&text), digits) == 0;
StrDeinit(&text);
bool result = IntToU64(&value) == 1295;
result = result && (ZstrCompare(StrBegin(&text), "zz") == 0);
StrDeinit(&text); Str text = IntToStrRadix(&value, 16, true);
bool result = ZstrCompare(StrBegin(&text), "BEEF") == 0;
StrDeinit(&text); ok = int_try_to_str_radix(&text, &value, 16, true, ALLOCATOR_OF(&alloc));
bool result = ok && (ZstrCompare(StrBegin(&text), "BEEF") == 0) &&
(StrAllocator(&text)->effort == alloc.base.effort) &&
(StrAllocator(&text)->retry_limit == alloc.base.retry_limit); result = result && (IntToU64(&zero, &error) == 0);
result = result && !error;
result = result && (ZstrCompare(StrBegin(&text), "0") == 0);
StrDeinit(&text);
bool result = IntToU64(&value) == 493;
result = result && (ZstrCompare(StrBegin(&text), "755") == 0);
StrDeinit(&text); Str text = IntToHexStr(&value);
bool result = ZstrCompare(StrBegin(&text), hex) == 0;
StrDeinit(&text);- In
PdbCache.c:297:
u32 offset = 0;
bool ok = PdbCacheResolve(&cache, (Zstr)pe_path, module_base, ip, &name, &offset);
ok = ok && name && ZstrCompare(name, "winproc") == 0 && offset == 0;
// Second resolution should hit the cache (not strictly verifiable
- In
PdbCache.c:305:
offset = 0;
ok = ok && PdbCacheResolve(&cache, (Zstr)pe_path, module_base, ip2, &name, &offset);
ok = ok && name && ZstrCompare(name, "winproc") == 0 && offset == 0x10;
PdbCacheDeinit(&cache);- In
Str.Convert.c:39:
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromU64(&s, 12345, &config);
bool result = (ZstrCompare(StrBegin(&s), "12345") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '12345', got '{}'\n", s);- In
Str.Convert.c:48:
config = (StrIntFormat) {.base = 16, .uppercase = false, .use_prefix = true};
StrFromU64(&s, 0xABCD, &config);
result = result && (ZstrCompare(StrBegin(&s), "0xabcd") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0xabcd', got '{}'\n", s);- In
Str.Convert.c:57:
config = (StrIntFormat) {.base = 16, .uppercase = true, .use_prefix = true};
StrFromU64(&s, 0xABCD, &config);
result = result && (ZstrCompare(StrBegin(&s), "0xABCD") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0xABCD', got '{}'\n", s);- In
Str.Convert.c:66:
config = (StrIntFormat) {.base = 2, .uppercase = false, .use_prefix = true};
StrFromU64(&s, 42, &config);
result = result && (ZstrCompare(StrBegin(&s), "0b101010") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0b101010', got '{}'\n", s);- In
Str.Convert.c:75:
config = (StrIntFormat) {.base = 8, .uppercase = false, .use_prefix = true};
StrFromU64(&s, 42, &config);
result = result && (ZstrCompare(StrBegin(&s), "0o52") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0o52', got '{}'\n", s);- In
Str.Convert.c:84:
config = (StrIntFormat) {.base = 10, .uppercase = false};
StrFromU64(&s, 0, &config);
result = result && (ZstrCompare(StrBegin(&s), "0") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0', got '{}'\n", s); StrIntFormat config = {.base = 10, .uppercase = false};
StrFromI64(&s, 12345, &config);
bool result = (ZstrCompare(StrBegin(&s), "12345") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '12345', got '{}'\n", StrBegin(&s)); config = (StrIntFormat) {.base = 10, .uppercase = false};
StrFromI64(&s, -12345, &config);
result = result && (ZstrCompare(StrBegin(&s), "-12345") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '-12345', got '{}'\n", StrBegin(&s)); config = (StrIntFormat) {.base = 10, .uppercase = false};
StrFromI64(&s, 0, &config);
result = result && (ZstrCompare(StrBegin(&s), "0") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0', got '{}'\n", StrBegin(&s)); config = (StrIntFormat) {.base = 2, .uppercase = false, .use_prefix = true};
StrFromI64(&s, 42, &config);
result = result && (ZstrCompare(StrBegin(&s), "0b101010") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '0b101010', got '{}'\n", StrBegin(&s)); StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, 123.0, &config);
bool result = (ZstrCompare(StrBegin(&s), "123.00") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '123.00', got '{}'\n", StrBegin(&s)); config = (StrFloatFormat) {.precision = 3, .force_sci = false, .uppercase = false};
StrFromF64(&s, 123.456, &config);
result = result && (ZstrCompare(StrBegin(&s), "123.456") == 0);
if (!result) {
WriteFmt(" FAIL: Expected '123.456', got '{}'\n", StrBegin(&s)); config = (StrFloatFormat) {.precision = 3, .force_sci = false, .uppercase = false};
StrFromF64(&s, -123.456, &config);
result = result && (ZstrCompare(StrBegin(&s), "-123.456") == 0);
// Test scientific notation (forced)
config = (StrFloatFormat) {.precision = 3, .force_sci = true, .uppercase = false};
StrFromF64(&s, 123.456, &config);
result = result && (ZstrCompare(StrBegin(&s), "1.235e+02") == 0);
// Test scientific notation (uppercase)
config = (StrFloatFormat) {.precision = 3, .force_sci = true, .uppercase = true};
StrFromF64(&s, 123.456, &config);
result = result && (ZstrCompare(StrBegin(&s), "1.235E+02") == 0);
// Test very small number (auto scientific notation)
config = (StrFloatFormat) {.precision = 3, .force_sci = false, .uppercase = false};
StrFromF64(&s, 0.0000123, &config);
result = result && (ZstrCompare(StrBegin(&s), "1.230e-05") == 0);
// Test very large number (auto scientific notation)
config = (StrFloatFormat) {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, 1234567890123.0, &config);
result = result && (ZstrCompare(StrBegin(&s), "1.23e+12") == 0);
// Test zero
config = (StrFloatFormat) {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, 0.0, &config);
result = result && (ZstrCompare(StrBegin(&s), "0.00") == 0);
// Test infinity
config = (StrFloatFormat) {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, F64_INFINITY, &config);
result = result && (ZstrCompare(StrBegin(&s), "inf") == 0);
// Test negative infinity
config = (StrFloatFormat) {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, -F64_INFINITY, &config);
result = result && (ZstrCompare(StrBegin(&s), "-inf") == 0);
// Test NaN
config = (StrFloatFormat) {.precision = 2, .force_sci = false, .uppercase = false};
StrFromF64(&s, F64_NAN, &config);
result = result && (ZstrCompare(StrBegin(&s), "nan") == 0);
StrDeinit(&s);- In
Socket.c:102:
}
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:113:
}
Str rendered = SocketAddrFormat(&addr, alloc_base);
ok = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "[::1]:8080") == 0;
StrDeinit(&rendered);
}- In
MachO.c:136:
ok = ok && m.has_uuid && MemCompare(m.uuid, kUuid, 16) == 0;
ok = ok && VecLen(&m.segments) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "__TEXT") == 0;
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;- In
MachO.c:138:
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "__TEXT") == 0;
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;- In
MachO.c:139:
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;
ok = ok && VecPtrAt(&m.symbols, 0)->name && ZstrCompare(VecPtrAt(&m.symbols, 0)->name, "my_function") == 0;- In
MachO.c:141:
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;
ok = ok && VecPtrAt(&m.symbols, 0)->name && ZstrCompare(VecPtrAt(&m.symbols, 0)->name, "my_function") == 0;
ok = ok && VecPtrAt(&m.symbols, 0)->value == 0x100000010ull;- In
MachO.c:163:
// Address at the function start.
const MachoSymbol *s = MachoResolveAddress(&m, 0x100000010ull);
bool ok = s && s->name && ZstrCompare(s->name, "my_function") == 0;
// Address just past the start, still inside the function body.
- In
MachO.c:167:
// Address just past the start, still inside the function body.
s = MachoResolveAddress(&m, 0x100000020ull);
ok = ok && s && ZstrCompare(s->name, "my_function") == 0;
// Address below the symbol value: no match.
Point2D p = {.x = 3, .y = 4};
bool ok = StrAppendFmt(&out, "{}", p);
ok = ok && (ZstrCompare(StrBegin(&out), "(3, 4)") == 0);
StrDeinit(&out); i32 count = 7;
bool ok = StrAppendFmt(&out, "got {} hits at {}", count, p);
ok = ok && (ZstrCompare(StrBegin(&out), "got 7 hits at (-1, 2)") == 0);
StrDeinit(&out); };
bool ok = StrAppendFmt(&out, "{}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "[(0, 0)..(10, 20)]") == 0);
StrDeinit(&out); };
bool ok = StrAppendFmt(&out, "{}", r);
ok = ok && (ZstrCompare(StrBegin(&out), "42:[(0, 0)..(100, 50)]@(50, 25)") == 0);
StrDeinit(&out); // types and built-ins coexist in one IOFMT expansion.
bool ok = StrAppendFmt(&out, "score={.1} region={} origin={}", score, region, origin);
ok = ok && (ZstrCompare(StrBegin(&out), "score=1.5 region=7:[(1, 2)..(3, 4)]@(2, 3) origin=(0, 0)") == 0);
StrDeinit(&out);- In
SysDns.c:94:
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:119:
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
// SocketAddrFormat emits the bracketed form for IPv6.
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;
StrDeinit(&s);
}- In
SysDns.c:174:
if (ok) {
Str s = SocketAddrFormat(&one, a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "127.0.0.1:80") == 0;
StrDeinit(&s);
}- In
Io.Read.c:344:
z = "Allocator-backed";
StrReadFmt(z, "{s}", ZstrIO(zs, alloc_base));
success = success && (ZstrCompare(zs, "Allocator-backed") == 0);
z = "\"Allocator-backed replacement\"";- In
Io.Read.c:348:
z = "\"Allocator-backed replacement\"";
StrReadFmt(z, "{s}", ZstrIO(zs, alloc_base));
success = success && (ZstrCompare(zs, "Allocator-backed replacement") == 0);
zstr_deinit(&zs, alloc_base);
}- In
Io.Read.c:822:
StrReadFmt(z, "{}", bv1);
Str result1 = BitVecToStr(&bv1);
success = success && (ZstrCompare(StrBegin(&result1), "10110") == 0);
WriteFmt(
"Test 1 - Binary: {}, Success: {}\n",- In
Io.Read.c:826:
"Test 1 - Binary: {}, Success: {}\n",
result1,
(ZstrCompare(StrBegin(&result1), "10110") == 0) ? "true" : "false"
);
StrDeinit(&result1);- In
Io.Read.c:851:
StrReadFmt(z, "{}", bv4);
Str result4 = BitVecToStr(&bv4);
success = success && (ZstrCompare(StrBegin(&result4), "1101") == 0);
WriteFmt(
"Test 4 - Whitespace: {}, Success: {}\n",- In
Io.Read.c:855:
"Test 4 - Whitespace: {}, Success: {}\n",
result4,
(ZstrCompare(StrBegin(&result4), "1101") == 0) ? "true" : "false"
);
StrDeinit(&result4);- In
Io.Read.c:864:
StrReadFmt(z, "{}", bv5);
Str result5 = BitVecToStr(&bv5);
success = success && (ZstrCompare(StrBegin(&result5), "0") == 0);
WriteFmt(
"Test 5 - Zero: {}, Success: {}\n",- In
Io.Read.c:868:
"Test 5 - Zero: {}, Success: {}\n",
result5,
(ZstrCompare(StrBegin(&result5), "0") == 0) ? "true" : "false"
);
StrDeinit(&result5);- In
Io.Read.c:900:
StrReadFmt(z, "{}", dec);
dec_text = IntToStr(&dec);
success = success && (ZstrCompare(StrBegin(&dec_text), "123456789012345678901234567890") == 0);
z = "deadbeefcafebabe1234";- In
Io.Read.c:905:
StrReadFmt(z, "{x}", hex);
hex_text = IntToHexStr(&hex);
success = success && (ZstrCompare(StrBegin(&hex_text), "deadbeefcafebabe1234") == 0);
z = "10100011";- In
Io.Read.c:910:
StrReadFmt(z, "{b}", bin);
bin_text = IntToBinary(&bin);
success = success && (ZstrCompare(StrBegin(&bin_text), "10100011") == 0);
z = "755";- In
Io.Read.c:915:
StrReadFmt(z, "{o}", oct);
oct_text = IntToOctStr(&oct);
success = success && (ZstrCompare(StrBegin(&oct_text), "755") == 0);
StrDeinit(&dec_text);- In
Io.Read.c:950:
StrReadFmt(z, "{}", dec);
dec_text = FloatToStr(&dec);
success = success && (ZstrCompare(StrBegin(&dec_text), "1234567890.012345") == 0);
z = "1.234567e+04";- In
Io.Read.c:955:
StrReadFmt(z, "{e}", sci);
sci_text = FloatToStr(&sci);
success = success && (ZstrCompare(StrBegin(&sci_text), "12345.67") == 0);
z = "-0.00125";- In
Io.Read.c:960:
StrReadFmt(z, "{}", neg);
neg_text = FloatToStr(&neg);
success = success && (ZstrCompare(StrBegin(&neg_text), "-0.00125") == 0);
StrDeinit(&dec_text);- In
Graph.Init.c:90:
bool result = GraphNodeIdIndex(node_id) == 0 && StrBegin(&name) != NULL && GraphNodeCount(&graph) == 1 &&
ZstrCompare(StrBegin(stored_name), "alpha") == 0 && StrBegin(stored_name) != StrBegin(&name);
StrDeinit(&name);- In
Graph.Init.c:114:
bool result = GraphNodeIdIndex(node_id) == 0 && GraphNodeCount(&graph) == 1 && StrBegin(stored_name) != NULL &&
ZstrCompare(StrBegin(stored_name), "alpha") == 0;
GraphDeinit(&graph);- In
Float.Type.c:60:
bool result = FloatEQ(&clone, &expected);
result = result && (ZstrCompare(StrBegin(&text), "-12.5") == 0);
result = result && !FloatEQ(&clone, &original); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "42") == 0;
result = result && !FloatIsNegative(&value); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "-42") == 0;
result = result && FloatIsNegative(&value); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "12345678901234567890") == 0;
IntDeinit(&integer); bool result = FloatToInt(&result_value, &value);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345") == 0);
FloatDeinit(&value); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "-123.45") == 0;
StrDeinit(&text); ok = float_try_to_str(&text, &value, ALLOCATOR_OF(&alloc));
bool result = ok && (ZstrCompare(StrBegin(&text), "-123.45") == 0) &&
(StrAllocator(&text)->effort == alloc.base.effort) &&
(StrAllocator(&text)->retry_limit == alloc.base.retry_limit); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;
StrDeinit(&text); Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "1230") == 0;
StrDeinit(&text);- In
Io.Write.c:43:
StrAppendFmt(&output, "Hello, world!");
success = success && (ZstrCompare(StrBegin(&output), "Hello, world!") == 0);
StrClear(&output);- In
Io.Write.c:47:
StrAppendFmt(&output, "{{Hello}}");
success = success && (ZstrCompare(StrBegin(&output), "{Hello}") == 0);
StrClear(&output);- In
Io.Write.c:51:
StrAppendFmt(&output, "{{{{");
success = success && (ZstrCompare(StrBegin(&output), "{{") == 0);
StrDeinit(&output);- In
Io.Write.c:68:
Zstr str = "Hello";
StrAppendFmt(&output, "{}", str);
success = success && (ZstrCompare(StrBegin(&output), "Hello") == 0);
StrClear(&output);- In
Io.Write.c:77:
StrAppendFmt(&output, "{>10}", str);
success = success && (ZstrCompare(StrBegin(&output), " Hello") == 0);
StrClear(&output);- In
Io.Write.c:81:
StrAppendFmt(&output, "{<10}", str);
success = success && (ZstrCompare(StrBegin(&output), "Hello ") == 0);
StrClear(&output);- In
Io.Write.c:85:
StrAppendFmt(&output, "{^10}", str);
success = success && (ZstrCompare(StrBegin(&output), " Hello ") == 0);
StrClear(&output);- In
Io.Write.c:90:
Str s = StrInitFromZstr("World", &alloc);
StrAppendFmt(&output, "{}", s);
success = success && (ZstrCompare(StrBegin(&output), "World") == 0);
StrDeinit(&s);- In
Io.Write.c:108:
i8 i8_val = -42;
StrAppendFmt(&output, "{}", i8_val);
success = success && (ZstrCompare(StrBegin(&output), "-42") == 0);
StrClear(&output);- In
Io.Write.c:113:
i16 i16_val = -1234;
StrAppendFmt(&output, "{}", i16_val);
success = success && (ZstrCompare(StrBegin(&output), "-1234") == 0);
StrClear(&output);- In
Io.Write.c:118:
i32 i32_val = -123456;
StrAppendFmt(&output, "{}", i32_val);
success = success && (ZstrCompare(StrBegin(&output), "-123456") == 0);
StrClear(&output);- In
Io.Write.c:123:
i64 i64_val = -1234567890LL;
StrAppendFmt(&output, "{}", i64_val);
success = success && (ZstrCompare(StrBegin(&output), "-1234567890") == 0);
StrClear(&output);- In
Io.Write.c:128:
u8 u8_val = 42;
StrAppendFmt(&output, "{}", u8_val);
success = success && (ZstrCompare(StrBegin(&output), "42") == 0);
StrClear(&output);- In
Io.Write.c:133:
u16 u16_val = 1234;
StrAppendFmt(&output, "{}", u16_val);
success = success && (ZstrCompare(StrBegin(&output), "1234") == 0);
StrClear(&output);- In
Io.Write.c:138:
u32 u32_val = 123456;
StrAppendFmt(&output, "{}", u32_val);
success = success && (ZstrCompare(StrBegin(&output), "123456") == 0);
StrClear(&output);- In
Io.Write.c:143:
u64 u64_val = 1234567890ULL;
StrAppendFmt(&output, "{}", u64_val);
success = success && (ZstrCompare(StrBegin(&output), "1234567890") == 0);
StrClear(&output);- In
Io.Write.c:148:
i8 i8_max = 127;
StrAppendFmt(&output, "{}", i8_max);
success = success && (ZstrCompare(StrBegin(&output), "127") == 0);
StrClear(&output);- In
Io.Write.c:153:
i8 i8_min = -128;
StrAppendFmt(&output, "{}", i8_min);
success = success && (ZstrCompare(StrBegin(&output), "-128") == 0);
StrClear(&output);- In
Io.Write.c:158:
u8 u8_max = 255;
StrAppendFmt(&output, "{}", u8_max);
success = success && (ZstrCompare(StrBegin(&output), "255") == 0);
StrClear(&output);- In
Io.Write.c:163:
u8 u8_min = 0;
StrAppendFmt(&output, "{}", u8_min);
success = success && (ZstrCompare(StrBegin(&output), "0") == 0);
StrDeinit(&output);- In
Io.Write.c:180:
u32 val = 0xDEADBEEF;
StrAppendFmt(&output, "{x}", val);
success = success && (ZstrCompare(StrBegin(&output), "0xdeadbeef") == 0);
StrClear(&output);- In
Io.Write.c:184:
StrAppendFmt(&output, "{X}", val);
success = success && (ZstrCompare(StrBegin(&output), "0xDEADBEEF") == 0);
StrDeinit(&output);- In
Io.Write.c:201:
u8 val = 0xA5; // 10100101 in binary
StrAppendFmt(&output, "{b}", val);
success = success && (ZstrCompare(StrBegin(&output), "0b10100101") == 0);
StrDeinit(&output);- In
Io.Write.c:218:
u16 val = 0777;
StrAppendFmt(&output, "{o}", val);
success = success && (ZstrCompare(StrBegin(&output), "0o777") == 0);
StrDeinit(&output);- In
Io.Write.c:235:
f32 f32_val = 3.14159f;
StrAppendFmt(&output, "{}", f32_val);
success = success && (ZstrCompare(StrBegin(&output), "3.141590") == 0);
StrClear(&output);- In
Io.Write.c:240:
f64 f64_val = 2.71828;
StrAppendFmt(&output, "{}", f64_val);
success = success && (ZstrCompare(StrBegin(&output), "2.718280") == 0);
StrDeinit(&output);- In
Io.Write.c:258:
StrAppendFmt(&output, "{.2}", val);
success = success && (ZstrCompare(StrBegin(&output), "3.14") == 0);
StrClear(&output);- In
Io.Write.c:262:
StrAppendFmt(&output, "{.0}", val);
success = success && (ZstrCompare(StrBegin(&output), "3") == 0);
StrClear(&output);- In
Io.Write.c:266:
StrAppendFmt(&output, "{.10}", val);
success = success && (ZstrCompare(StrBegin(&output), "3.1415926536") == 0);
StrDeinit(&output);- In
Io.Write.c:283:
f64 pos_inf = F64_INFINITY;
StrAppendFmt(&output, "{}", pos_inf);
success = success && (ZstrCompare(StrBegin(&output), "inf") == 0);
StrClear(&output);- In
Io.Write.c:288:
f64 neg_inf = -F64_INFINITY;
StrAppendFmt(&output, "{}", neg_inf);
success = success && (ZstrCompare(StrBegin(&output), "-inf") == 0);
StrClear(&output);- In
Io.Write.c:293:
f64 nan_val = F64_NAN;
StrAppendFmt(&output, "{}", nan_val);
success = success && (ZstrCompare(StrBegin(&output), "nan") == 0);
StrDeinit(&output);- In
Io.Write.c:310:
i32 val = 42;
StrAppendFmt(&output, "{5}", val);
success = success && (ZstrCompare(StrBegin(&output), " 42") == 0);
StrClear(&output);- In
Io.Write.c:314:
StrAppendFmt(&output, "{<5}", val);
success = success && (ZstrCompare(StrBegin(&output), "42 ") == 0);
StrClear(&output);- In
Io.Write.c:318:
StrAppendFmt(&output, "{^5}", val);
success = success && (ZstrCompare(StrBegin(&output), " 42 ") == 0);
StrClear(&output);- In
Io.Write.c:323:
Zstr str = "abc";
StrAppendFmt(&output, "{5}", str);
success = success && (ZstrCompare(StrBegin(&output), " abc") == 0);
StrClear(&output);- In
Io.Write.c:327:
StrAppendFmt(&output, "{<5}", str);
success = success && (ZstrCompare(StrBegin(&output), "abc ") == 0);
StrClear(&output);- In
Io.Write.c:331:
StrAppendFmt(&output, "{^5}", str);
success = success && (ZstrCompare(StrBegin(&output), " abc ") == 0);
StrDeinit(&output);- In
Io.Write.c:351:
StrAppendFmt(&output, "{} {} {}", hello, num, pi);
success = success && (ZstrCompare(StrBegin(&output), "Hello 42 3.140000") == 0);
StrClear(&output);- In
Io.Write.c:355:
StrAppendFmt(&output, "{} {} {}", pi, hello, num);
success = success && (ZstrCompare(StrBegin(&output), "3.140000 Hello 42") == 0);
StrDeinit(&output);- In
Io.Write.c:372:
Zstr mixed_case = "MiXeD CaSe";
StrAppendFmt(&output, "{c}", mixed_case);
success = success && (ZstrCompare(StrBegin(&output), "MiXeD CaSe") == 0);
StrClear(&output);- In
Io.Write.c:376:
StrAppendFmt(&output, "{a}", mixed_case);
success = success && (ZstrCompare(StrBegin(&output), "mixed case") == 0);
StrClear(&output);- In
Io.Write.c:380:
StrAppendFmt(&output, "{A}", mixed_case);
success = success && (ZstrCompare(StrBegin(&output), "MIXED CASE") == 0);
StrClear(&output);- In
Io.Write.c:386:
StrAppendFmt(&output, "{c}", s);
success = success && (ZstrCompare(StrBegin(&output), "MiXeD CaSe") == 0);
StrClear(&output);- In
Io.Write.c:390:
StrAppendFmt(&output, "{a}", s);
success = success && (ZstrCompare(StrBegin(&output), "mixed case") == 0);
StrClear(&output);- In
Io.Write.c:394:
StrAppendFmt(&output, "{A}", s);
success = success && (ZstrCompare(StrBegin(&output), "MIXED CASE") == 0);
StrClear(&output);- In
Io.Write.c:401:
StrAppendFmt(&output, "{c}", upper_char);
success = success && (ZstrCompare(StrBegin(&output), "M") == 0);
StrClear(&output);- In
Io.Write.c:405:
StrAppendFmt(&output, "{a}", upper_char);
success = success && (ZstrCompare(StrBegin(&output), "m") == 0);
StrClear(&output);- In
Io.Write.c:409:
StrAppendFmt(&output, "{A}", lower_char);
success = success && (ZstrCompare(StrBegin(&output), "M") == 0);
StrClear(&output);- In
Io.Write.c:532:
BitVec bv1 = BitVecFromStr("10110", alloc_base);
StrAppendFmt(&output, "{}", bv1);
success = success && (ZstrCompare(StrBegin(&output), "10110") == 0);
StrClear(&output);- In
Io.Write.c:542:
BitVec bv2 = BitVecFromInteger(0xABCD, 16, alloc_base);
StrAppendFmt(&output, "{x}", bv2);
success = success && (ZstrCompare(StrBegin(&output), "0xabcd") == 0);
StrClear(&output);- In
Io.Write.c:546:
StrAppendFmt(&output, "{X}", bv2);
success = success && (ZstrCompare(StrBegin(&output), "0xABCD") == 0);
StrClear(&output);- In
Io.Write.c:551:
BitVec bv3 = BitVecFromInteger(0755, 10, alloc_base);
StrAppendFmt(&output, "{o}", bv3);
success = success && (ZstrCompare(StrBegin(&output), "0o755") == 0);
StrClear(&output);- In
Io.Write.c:555:
StrAppendFmt(&output, "{>10}", bv1);
success = success && (ZstrCompare(StrBegin(&output), " 10110") == 0);
StrClear(&output);- In
Io.Write.c:559:
StrAppendFmt(&output, "{<10}", bv1);
success = success && (ZstrCompare(StrBegin(&output), "10110 ") == 0);
StrClear(&output);- In
Io.Write.c:563:
StrAppendFmt(&output, "{^10}", bv1);
success = success && (ZstrCompare(StrBegin(&output), " 10110 ") == 0);
StrClear(&output);- In
Io.Write.c:568:
BitVec bv_zero = BitVecFromInteger(0, 1, alloc_base);
StrAppendFmt(&output, "{x}", bv_zero);
success = success && (ZstrCompare(StrBegin(&output), "0x0") == 0);
StrClear(&output);- In
Io.Write.c:572:
StrAppendFmt(&output, "{o}", bv_zero);
success = success && (ZstrCompare(StrBegin(&output), "0o0") == 0);
StrClear(&output);- In
Io.Write.c:600:
StrAppendFmt(&output, "{}", big_dec);
success = success && (ZstrCompare(StrBegin(&output), "123456789012345678901234567890") == 0);
StrClear(&output);- In
Io.Write.c:604:
StrAppendFmt(&output, "{x}", hex_val);
success = success && (ZstrCompare(StrBegin(&output), "deadbeefcafebabe1234") == 0);
StrClear(&output);- In
Io.Write.c:608:
StrAppendFmt(&output, "{X}", hex_val);
success = success && (ZstrCompare(StrBegin(&output), "DEADBEEFCAFEBABE1234") == 0);
StrClear(&output);- In
Io.Write.c:612:
StrAppendFmt(&output, "{b}", bin_val);
success = success && (ZstrCompare(StrBegin(&output), "10100011") == 0);
StrClear(&output);- In
Io.Write.c:616:
StrAppendFmt(&output, "{o}", oct_val);
success = success && (ZstrCompare(StrBegin(&output), "755") == 0);
StrClear(&output);- In
Io.Write.c:620:
StrAppendFmt(&output, "{>34}", big_dec);
success = success && (ZstrCompare(StrBegin(&output), " 123456789012345678901234567890") == 0);
IntDeinit(&big_dec);- In
Io.Write.c:644:
StrAppendFmt(&output, "{}", exact);
success = success && (ZstrCompare(StrBegin(&output), "1234567890.012345") == 0);
StrClear(&output);- In
Io.Write.c:648:
StrAppendFmt(&output, "{e}", sci);
success = success && (ZstrCompare(StrBegin(&output), "1.234567e+04") == 0);
StrClear(&output);- In
Io.Write.c:652:
StrAppendFmt(&output, "{E}", sci);
success = success && (ZstrCompare(StrBegin(&output), "1.234567E+04") == 0);
StrClear(&output);- In
Io.Write.c:656:
StrAppendFmt(&output, "{.3}", short_v);
success = success && (ZstrCompare(StrBegin(&output), "1.200") == 0);
StrClear(&output);- In
Io.Write.c:660:
StrAppendFmt(&output, "{>18}", sci);
success = success && (ZstrCompare(StrBegin(&output), " 12345.67") == 0);
FloatDeinit(&exact);- In
Str.Insert.c:39:
// Check that the character was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "He!llo") == 0);
// Insert a character at the beginning
- In
Str.Insert.c:45:
// Check that the character was inserted correctly
result = result && (ZstrCompare(StrBegin(&s), "?He!llo") == 0);
// Insert a character at the end
- In
Str.Insert.c:51:
// Check that the character was inserted correctly
result = result && (ZstrCompare(StrBegin(&s), "?He!llo.") == 0);
StrDeinit(&s);- In
Str.Insert.c:70:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
StrDeinit(&s);- In
Str.Insert.c:90:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
StrDeinit(&s);- In
Str.Insert.c:109:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
StrDeinit(&s);- In
Str.Insert.c:128:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
StrDeinit(&s);- In
Str.Insert.c:147:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:166:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:185:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:204:
// Check that the string was inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:228:
// Check that the characters were inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:252:
// Check that the characters were inserted correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
StrDeinit(&s);- In
Str.Insert.c:276:
// Check that the strings were merged correctly
bool result = (ZstrCompare(StrBegin(&s1), "Hello World") == 0);
// Check that s2 was reset - data should be NULL, length should be 0
- In
Str.Insert.c:300:
// Check that the strings were merged correctly
bool result = (ZstrCompare(StrBegin(&s1), "Hello World") == 0);
// Check that s2 was not reset
- In
Str.Insert.c:303:
// Check that s2 was not reset
result = result && (StrLen(&s2) == 6 && ZstrCompare(StrBegin(&s2), " World") == 0);
StrDeinit(&s1);- In
Str.Insert.c:324:
// Check that the strings were merged correctly
bool result = (ZstrCompare(StrBegin(&s1), "Hello World") == 0);
// s2 was zeroed on take per L-form contract
- In
Str.Insert.c:348:
// Check that the string was appended correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello World 2023") == 0);
StrDeinit(&s);- In
Float.Math.c:36:
text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "-12.5") == 0;
StrDeinit(&text);- In
Float.Math.c:41:
FloatAbs(&value);
text = FloatToStr(&value);
result = result && (ZstrCompare(StrBegin(&text), "12.5") == 0);
StrDeinit(&text);- In
Float.Math.c:62:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "1.23") == 0;
StrDeinit(&text);- In
Float.Math.c:85:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_THREES) == 0;
StrDeinit(&text);- In
Float.Math.c:108:
FloatAdd(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "2") == 0;
StrDeinit(&text);- In
Float.Math.c:113:
FloatAdd(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);
StrDeinit(&text);- In
Float.Math.c:118:
FloatAdd(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);
StrDeinit(&text);- In
Float.Math.c:123:
FloatAdd(&result_value, &a, -1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "0.25") == 0);
StrDeinit(&text);- In
Float.Math.c:128:
FloatAdd(&result_value, &a, 0.75f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2") == 0);
StrDeinit(&text);- In
Float.Math.c:133:
FloatAdd(&result_value, &a, 0.75);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2") == 0);
FloatDeinit(&a);- In
Float.Math.c:157:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "-0.5") == 0;
StrDeinit(&text);- In
Float.Math.c:180:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_TWOS) == 0;
StrDeinit(&text);- In
Float.Math.c:203:
FloatSub(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "5") == 0;
StrDeinit(&text);- In
Float.Math.c:208:
FloatSub(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);
StrDeinit(&text);- In
Float.Math.c:213:
FloatSub(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);
StrDeinit(&text);- In
Float.Math.c:218:
FloatSub(&result_value, &a, -2);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "7.5") == 0);
StrDeinit(&text);- In
Float.Math.c:223:
FloatSub(&result_value, &a, 0.5f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "5") == 0);
FloatDeinit(&a);- In
Float.Math.c:247:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "-2.5") == 0;
StrDeinit(&text);- In
Float.Math.c:270:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_TWOS) == 0;
StrDeinit(&text);- In
Float.Math.c:293:
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "3") == 0;
StrDeinit(&text);- In
Float.Math.c:298:
FloatMul(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);
StrDeinit(&text);- In
Float.Math.c:303:
FloatMul(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);
StrDeinit(&text);- In
Float.Math.c:308:
FloatMul(&result_value, &a, -2);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "-3") == 0);
StrDeinit(&text);- In
Float.Math.c:313:
FloatMul(&result_value, &a, 0.5f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "0.75") == 0);
FloatDeinit(&a);- In
Float.Math.c:337:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "0.125") == 0;
StrDeinit(&text);- In
Float.Math.c:360:
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;
StrDeinit(&text);- In
Float.Math.c:383:
FloatDiv(&result_value, &a, &b, 1);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "3") == 0;
StrDeinit(&text);- In
Float.Math.c:388:
FloatDiv(&result_value, &a, &whole, 1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2.5") == 0);
StrDeinit(&text);- In
Float.Math.c:393:
FloatDiv(&result_value, &a, 3u, 1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2.5") == 0);
StrDeinit(&text);- In
Float.Math.c:398:
FloatDiv(&result_value, &a, -3, 1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "-2.5") == 0);
StrDeinit(&text);- In
Float.Math.c:403:
FloatDiv(&result_value, &a, 0.5f, 1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "15") == 0);
StrDeinit(&text);- In
Float.Math.c:408:
FloatDiv(&result_value, &a, 0.5, 1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "15") == 0);
FloatDeinit(&a);- In
Int.Math.c:110:
bool result = IntToU64(&result_value) == 256;
result = result && (ZstrCompare(StrBegin(&text), "100000000") == 0);
StrDeinit(&text);- In
Int.Math.c:142:
IntAdd(&result_value, &huge, 10);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "123456789012345678901234567900") == 0);
IntDeinit(&base);- In
Int.Math.c:195:
result = result && IntSub(&result_value, &huge, 90);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345678901234567800") == 0);
result = result && !IntSub(&preserved, &base, 50);- In
Int.Math.c:261:
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "308641972530864197250") == 0;
IntDeinit(&value);- In
Int.Math.c:321:
IntPow(&result_value, &base, 20u);
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "79792266297612001") == 0;
StrDeinit(&text);- In
Int.Math.c:326:
IntPow(&result_value, &base, &exponent);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "79792266297612001") == 0);
IntDeinit(&base);- In
Int.Math.c:349:
qtext = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&qtext), "127275040218913071") == 0;
result = result && (IntToU64(&remainder) == 3);- In
Int.Math.c:389:
bool result = IntDivExact(&result_value, ÷nd, 90u);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "137174210013717421") == 0);
IntDeinit(÷nd);- In
Int.Math.c:430:
text = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&text), "127275040218913071") == 0;
result = result && (IntToU64(&remainder) == 3);- In
Int.Math.c:900:
text = IntToStr(&next);
bool result = ok && ZstrCompare(StrBegin(&text), "1000000007") == 0;
IntDeinit(&value);- In
File.c:55:
bool result = (got == (i64)ZstrLen("hello from file")) && (StrLen(&body) == (size)ZstrLen("hello from file")) &&
ZstrCompare(StrBegin(&body), "hello from file") == 0;
StrDeinit(&body);- 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
Str.Type.c:36:
StrPushBackR(&s, 'o');
bool result = (StrLen(&s) == 5 && ZstrCompare(StrBegin(&s), "Hello") == 0);
StrDeinit(&s);- In
Str.Type.c:67:
Str *str2 = &VecAt(&sv, 1);
result = result && (ZstrCompare(StrBegin(str1), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(str2), "World") == 0);
}- In
Str.Type.c:68:
result = result && (ZstrCompare(StrBegin(str1), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(str2), "World") == 0);
} if ((a->name && !b->name) || (!a->name && b->name))
return false;
if (a->name && b->name && ZstrCompare(a->name, b->name) != 0)
return false;
// The vector's copy should still have the original values
result = result && (ZstrCompare(VecAt(&vec, 0).name, "Test Item") == 0);
result = result && (VecAt(&vec, 0).values[0] == 1);
// Check items order: item2, item1, item3
result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 3") == 0); // Check items order: item2, item1, item3
result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 3") == 0); result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 3") == 0);
// Check values
// Check items order: item2, item3, item1
result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 3") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 1") == 0); // Check items order: item2, item3, item1
result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 3") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 1") == 0); result = result && (ZstrCompare(VecAt(&vec, 0).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec, 1).name, "Item 3") == 0);
result = result && (ZstrCompare(VecAt(&vec, 2).name, "Item 1") == 0);
// Clean up
// Check items in vec1: item1, item2, item3
result = result && (ZstrCompare(VecAt(&vec1, 0).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 1).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 2).name, "Item 3") == 0); // Check items in vec1: item1, item2, item3
result = result && (ZstrCompare(VecAt(&vec1, 0).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 1).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 2).name, "Item 3") == 0); result = result && (ZstrCompare(VecAt(&vec1, 0).name, "Item 1") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 1).name, "Item 2") == 0);
result = result && (ZstrCompare(VecAt(&vec1, 2).name, "Item 3") == 0);
// Now test VecMergeL which transfers ownership
// Check items in vec3: item4, item5
result = result && (ZstrCompare(VecAt(&vec3, 0).name, "Item 4") == 0);
result = result && (ZstrCompare(VecAt(&vec3, 1).name, "Item 5") == 0); // Check items in vec3: item4, item5
result = result && (ZstrCompare(VecAt(&vec3, 0).name, "Item 4") == 0);
result = result && (ZstrCompare(VecAt(&vec3, 1).name, "Item 5") == 0);
// Clean up
ok = BitVecTryToStr(&str, &bv);
result = result && ok && (StrAllocator(&str)->effort == alloc.base.effort) &&
(StrAllocator(&str)->retry_limit == alloc.base.retry_limit) && (ZstrCompare(StrBegin(&str), "101001") == 0);
StrDeinit(&str);
// Should get exact same string back
result = result && (ZstrCompare(StrBegin(&str), patterns[i]) == 0);
StrDeinit(&str); // Test string conversion consistency
Str str = BitVecToStr(&bv);
result = result && (ZstrCompare(StrBegin(&str), test_cases[i].pattern) == 0);
StrDeinit(&str); u64 value = BitVecToInteger(&bv);
// We test that we get a consistent value (not necessarily the exact expected one)
result = result && (value > 0 || ZstrCompare(test_cases[i].pattern, "00000000") == 0);
// Test byte conversion
// At least two of them should match (bit order might affect one)
bool cross_match = (ZstrCompare(StrBegin(&str1), StrBegin(&str2)) == 0) ||
(ZstrCompare(StrBegin(&str1), StrBegin(&str3)) == 0) ||
(ZstrCompare(StrBegin(&str2), StrBegin(&str3)) == 0); // At least two of them should match (bit order might affect one)
bool cross_match = (ZstrCompare(StrBegin(&str1), StrBegin(&str2)) == 0) ||
(ZstrCompare(StrBegin(&str1), StrBegin(&str3)) == 0) ||
(ZstrCompare(StrBegin(&str2), StrBegin(&str3)) == 0);
result = result && cross_match; bool cross_match = (ZstrCompare(StrBegin(&str1), StrBegin(&str2)) == 0) ||
(ZstrCompare(StrBegin(&str1), StrBegin(&str3)) == 0) ||
(ZstrCompare(StrBegin(&str2), StrBegin(&str3)) == 0);
result = result && cross_match;- In
Pdb.c:296:
if (ok) {
const PdbFunction *f = VecPtrAt(&pdb.functions, 0);
ok = ok && f->rva == 0x1100 && f->name && ZstrCompare(f->name, "my_function") == 0;
}- In
Pdb.c:302:
if (ok) {
const PdbFunction *f = PdbResolveRva(&pdb, 0x1100);
ok = f && ZstrCompare(f->name, "my_function") == 0;
}- In
MachoCache.c:197:
u32 offset = 0;
bool ok = MachoCacheResolve(&cache, bin_path, slide, runtime_ip, &name, &offset);
ok = ok && name && ZstrCompare(name, "real_main_proc") == 0 && offset == 0x10;
MachoCacheDeinit(&cache);- In
MachoCache.c:234:
u32 offset = 0;
bool ok = MachoCacheResolve(&cache, bin_path, slide, runtime_ip, &name, &offset);
ok = ok && name && ZstrCompare(name, "dsym_only_fn") == 0 && offset == 0x8;
MachoCacheDeinit(&cache);- In
Map.Ops.c:57:
result = result && (MapValueCountForKey(&map, "alpha") == 2);
stored_value = MapGetFirstPtr(&map, "alpha");
result = result && stored_value && (*stored_value != value) && (ZstrCompare(*stored_value, "first") == 0);
MapForeachValueForKey(&map, "alpha", entry_value) {
if ((ZstrCompare(entry_value, "first") == 0) || (ZstrCompare(entry_value, "second") == 0)) {- In
Map.Ops.c:59:
result = result && stored_value && (*stored_value != value) && (ZstrCompare(*stored_value, "first") == 0);
MapForeachValueForKey(&map, "alpha", entry_value) {
if ((ZstrCompare(entry_value, "first") == 0) || (ZstrCompare(entry_value, "second") == 0)) {
value_count += 1;
}- In
Map.Ops.c:96:
(MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
result = result && (MapValueCountForKey(&map, "red") == 2);
result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
result = result && MapGetFirstPtr(&map, "yellow") && (ZstrCompare(*MapGetFirstPtr(&map, "yellow"), "banana") == 0);
result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);- In
Map.Ops.c:97:
result = result && (MapValueCountForKey(&map, "red") == 2);
result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
result = result && MapGetFirstPtr(&map, "yellow") && (ZstrCompare(*MapGetFirstPtr(&map, "yellow"), "banana") == 0);
result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
MapForeachValueForKey(&map, "red", red_value) {- In
Map.Ops.c:98:
result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
result = result && MapGetFirstPtr(&map, "yellow") && (ZstrCompare(*MapGetFirstPtr(&map, "yellow"), "banana") == 0);
result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
MapForeachValueForKey(&map, "red", red_value) {
if ((ZstrCompare(red_value, "apple") == 0) || (ZstrCompare(red_value, "cherry") == 0)) {- In
Map.Ops.c:100:
result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
MapForeachValueForKey(&map, "red", red_value) {
if ((ZstrCompare(red_value, "apple") == 0) || (ZstrCompare(red_value, "cherry") == 0)) {
red_count += 1;
}- In
Dns.c:162:
match = r0->type == DNS_TYPE_A && r0->ttl == 300 && r0->ipv4[0] == 93 && r0->ipv4[1] == 184 &&
r0->ipv4[2] == 216 && r0->ipv4[3] == 34 && StrLen(&r0->name) > 0 &&
ZstrCompare(StrBegin(&r0->name), "example.com") == 0;
}
if (match) {- In
Dns.c:296:
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_CNAME && StrLen(&r->target) > 0 &&
ZstrCompare(StrBegin(&r->target), "example.com") == 0;
}- In
Str.Init.c:76:
// Check that it's initialized correctly
bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
StrDeinit(&s);- In
Str.Init.c:94:
ValidateStr(&s);
bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
StrDeinit(&s);- In
Str.Init.c:115:
// Check that dst is initialized correctly
bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Str.Init.c:137:
// Check that dst is initialized correctly
bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Str.Init.c:158:
// Check that it's initialized correctly
bool result = (ZstrCompare(StrBegin(&s), "Hello, World!") == 0);
StrDeinit(&s);- In
Str.Init.c:178:
ValidateStr(&stack_str);
if (ZstrCompare(StrBegin(&stack_str), "Hello, Stack!") != 0) {
result = false;
}- In
Str.Init.c:210:
// Check that the copy was successful
bool result = (success && StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
StrDeinit(&src);- In
Str.Init.c:238:
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
Str.Init.c:239:
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;
StrDeinit(&src);- In
Map.Type.c:107:
custom_policy.max_probe_count = 0;
bool result = ZstrCompare(MapPolicy(&map).name, "custom-linear") == 0 &&
MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
MapPolicy(&map).next_capacity == custom_next_capacity &&- In
Str.Foreach.c:48:
// The result should be "H0e1l2l3o4"
bool success = (ZstrCompare(StrBegin(&result), "H0e1l2l3o4") == 0);
StrDeinit(&s);- In
Str.Foreach.c:72:
}
bool success = (ZstrCompare(StrBegin(&result), "o4l3l2e1H0") == 0);
WriteFmt(" (Index 0 was processed)\n");
// The result should be "H0e1l2l3o4"
bool success = (ZstrCompare(StrBegin(&result), "H0e1l2l3o4") == 0);
// The original string should now be "HELLO" (all uppercase)
// The original string should now be "HELLO" (all uppercase)
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0);
StrDeinit(&s);
bool success = false;
success = (ZstrCompare(StrBegin(&result), "o4l3l2e1H0") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0); // All uppercase
WriteFmt(" (Index 0 was processed)\n"); bool success = false;
success = (ZstrCompare(StrBegin(&result), "o4l3l2e1H0") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0); // All uppercase
WriteFmt(" (Index 0 was processed)\n");
// The result should be "Hello"
bool success = (ZstrCompare(StrBegin(&result), "Hello") == 0);
StrDeinit(&s); bool success = false;
if (char_count == StrLen(&s)) {
success = (ZstrCompare(StrBegin(&result), "olleH") == 0);
WriteFmt(" (All characters were processed)\n");
} else { WriteFmt(" (All characters were processed)\n");
} else {
success = (ZstrCompare(StrBegin(&result), "olle") == 0);
WriteFmt(" (First character was NOT processed - bug in macro)\n");
}
// The result should be "Hello" (original values before modification)
bool success = (ZstrCompare(StrBegin(&result), "Hello") == 0);
// The original string should now be "HELLO" (all uppercase)
// The original string should now be "HELLO" (all uppercase)
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0);
StrDeinit(&s); bool success = false;
if (char_count == StrLen(&s)) {
success = (ZstrCompare(StrBegin(&result), "olleH") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0); // All uppercase
WriteFmt(" (All characters were processed)\n"); if (char_count == StrLen(&s)) {
success = (ZstrCompare(StrBegin(&result), "olleH") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0); // All uppercase
WriteFmt(" (All characters were processed)\n");
} else { WriteFmt(" (All characters were processed)\n");
} else {
success = (ZstrCompare(StrBegin(&result), "olle") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLo") == 0); // All uppercase except first char
WriteFmt(" (First character was NOT processed - bug in macro)\n"); } else {
success = (ZstrCompare(StrBegin(&result), "olle") == 0);
success = success && (ZstrCompare(StrBegin(&s), "HELLo") == 0); // All uppercase except first char
WriteFmt(" (First character was NOT processed - bug in macro)\n");
}
// The result should be "W6o7r8l9d10" (characters from index 6-10 with their indices)
bool success = (ZstrCompare(StrBegin(&result), "W6o7r8l9d10") == 0);
// Test with empty range
// The result should be "Hello" (first 5 characters)
bool success = (ZstrCompare(StrBegin(&result), "Hello") == 0);
// Test with range at the end of the string
// The end_result should be "World" (last 5 characters)
success = success && (ZstrCompare(StrBegin(&end_result), "World") == 0);
StrDeinit(&s);
// The result should be "W6o7r8l9d10" (characters from index 6-10 with their indices)
bool success = (ZstrCompare(StrBegin(&result), "W6o7r8l9d10") == 0);
// The original string should now have "WORLD" in uppercase
// The original string should now have "WORLD" in uppercase
success = success && (ZstrCompare(StrBegin(&s), "Hello WORLD") == 0);
StrDeinit(&s);
// The result should be "Hello" (first 5 characters)
bool success = (ZstrCompare(StrBegin(&result), "Hello") == 0);
// The original string should now have "HELLO" in uppercase
// The original string should now have "HELLO" in uppercase
success = success && (ZstrCompare(StrBegin(&s), "HELLO World") == 0);
StrDeinit(&s);- In
ArgParse.c:22:
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && listen && ZstrCompare(listen, "0.0.0.0:8080") == 0;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
ArgParse.c:38:
ArgRun rc = ArgParseRun(&p, 2, argv);
bool ok = (rc == ARG_RUN_OK) && listen && ZstrCompare(listen, "0.0.0.0:8080") == 0;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
ArgParse.c:54:
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && listen && ZstrCompare(listen, "127.0.0.1:9") == 0;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
ArgParse.c:168:
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && ZstrCompare(src, "a.txt") == 0 && ZstrCompare(dst, "b.txt") == 0;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
ArgParse.c:188:
ArgRun rc = ArgParseRun(&p, 4, argv);
bool ok = (rc == ARG_RUN_OK) && ZstrCompare(src, "a.txt") == 0 && ZstrCompare(dst, "b.txt") == 0 && verbose == true;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
ArgParse.c:381:
ArgRun rc = ArgParseRun(&p, 3, argv);
bool ok = (rc == ARG_RUN_OK) && ZstrCompare(file, "--unusual-name") == 0;
ArgParseDeinit(&p);
DefaultAllocatorDeinit(&a);- In
Pe.c:170:
ok = pe.machine == PE_MACHINE_X86_64 && pe.is_pe32_plus && pe.image_base == 0x140000000ull;
ok = ok && VecLen(&pe.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&pe.sections, 0)->name, ".debug") == 0;
ok = ok && VecPtrAt(&pe.sections, 0)->virtual_address == SECTION_VA;
ok = ok && pe.codeview.present;- In
Pe.c:175:
ok = ok && pe.codeview.age == 0x2a;
ok = ok && MemCompare(pe.codeview.guid, kGuid, 16) == 0;
ok = ok && pe.codeview.pdb_path && ZstrCompare(pe.codeview.pdb_path, kPdbPath) == 0;
PeDeinit(&pe);
Last updated on