authorgravatar for jcmoyer32@gmail.comJ.C. Moyer <jcmoyer32@gmail.com> 2020-10-30 23:48:41-04:00
committergravatar for jcmoyer32@gmail.comJ.C. Moyer <jcmoyer32@gmail.com> 2020-10-30 23:58:23-04:00
log788900c35c99361e4ab0e2b5dd38cfa0737700d7
tree3206daca5a74173b1e16d32628f63f9ef2c05606
parentb38dea37c77d9b2d778e169924efd6af00f9419b

Add test for null terminated slices with embedded null bytes


1 files changed, 4 insertions(+), 0 deletions(-)

lib/std/fmt.zig+4
......@@ -1385,6 +1385,10 @@ test "slice" {
13851385 const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero];
13861386 try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value});
13871387 }
1388 {
1389 const null_term_slice: [:0]const u8 = "\x00hello\x00";
1390 try testFmt("buf: \x00hello\x00\n", "buf: {s}\n", .{null_term_slice});
1391 }
13881392
13891393 try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"});
13901394 try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"});