| ... | ... | @@ -64,7 +64,9 @@ fn peekIsAlign(comptime fmt: []const u8) bool { |
| 64 | 64 | /// - `x` and `X`: |
| 65 | 65 | /// - format the non-numeric value as a string of bytes in hexadecimal notation ("binary dump") in either lower case or upper case |
| 66 | 66 | /// - output numeric value in hexadecimal notation |
| 67 | | /// - `s`: print a pointer-to-many as a c-string, use zero-termination |
| 67 | /// - `s`: |
| 68 | /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination |
| 69 | /// - for slices of u8, print the entire slice as a string without zero-termination |
| 68 | 70 | /// - `z`: escape the string with @"" syntax if it is not a valid Zig identifier. |
| 69 | 71 | /// - `Z`: print the string escaping non-printable characters using Zig escape sequences. |
| 70 | 72 | /// - `B` and `Bi`: output a memory size in either metric (1000) or power-of-two (1024) based notation. works for both float and integer values. |
| ... | ... | @@ -1383,6 +1385,10 @@ test "slice" { |
| 1383 | 1385 | const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero]; |
| 1384 | 1386 | try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value}); |
| 1385 | 1387 | } |
| 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 | } |
| 1386 | 1392 | |
| 1387 | 1393 | try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"}); |
| 1388 | 1394 | try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"}); |