commit 1dac9e71b525cb14eb358eaf0bc45b1554f5bf55 (tree)
parent 8252c8b9d698ca671413ad4e23c5228dcf505632
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 22 May 2020 00:27:51 -0400
std.testing: fix a crash when printing diffs
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
@@ -320,10 +320,11 @@ fn printWithVisibleNewlines(source: []const u8) void {
}
fn printLine(line: []const u8) void {
- switch (line[line.len - 1]) {
+ if (line.len != 0) switch (line[line.len - 1]) {
' ', '\t' => warn("{}⏎\n", .{line}), // Carriage return symbol,
- else => warn("{}\n", .{line}),
- }
+ else => {},
+ };
+ warn("{}\n", .{line});
}
test "" {