mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 21:38:33 +00:00
Add test for null terminated slices with embedded null bytes
This commit is contained in:
parent
b38dea37c7
commit
788900c35c
@ -1385,6 +1385,10 @@ test "slice" {
|
||||
const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero];
|
||||
try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value});
|
||||
}
|
||||
{
|
||||
const null_term_slice: [:0]const u8 = "\x00hello\x00";
|
||||
try testFmt("buf: \x00hello\x00\n", "buf: {s}\n", .{null_term_slice});
|
||||
}
|
||||
|
||||
try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"});
|
||||
try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user