std.testing: make the caret indicator line more helpful

This commit is contained in:
r00ster 2022-07-25 14:51:22 +02:00 committed by GitHub
parent 0d120fcb89
commit 8f3ab96b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {