zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8f3ab96b0e8cd22dc98f9fe352c5d4fff491dd0e (tree)
parent 0d120fcb892d99417ee361adb79671c473f798ee
Author: r00ster <r00ster91@proton.me>
Date:   Mon, 25 Jul 2022 14:51:22 +0200

std.testing: make the caret indicator line more helpful


Diffstat:
Mlib/std/testing.zig | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/std/testing.zig b/lib/std/testing.zig @@ -543,7 +543,10 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void { while (i < indicator_index) : (i += 1) print(" ", .{}); } - print("^\n", .{}); + if (indicator_index >= source.len) + print("^ (end of string)\n", .{}) + else + print("^ ('\\x{x:0>2}')\n", .{source[indicator_index]}); } fn printWithVisibleNewlines(source: []const u8) void {