aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-11-26 09:48:12 +0100
committerAndrew Kelley <andrew@ziglang.org>2021-01-02 17:12:57 -0700
commitdd973fb365dbbe11ce5beac8b4889bfab3fddc4d (patch)
treee82adf746186ec50e1aa11c5bd9f4a677e93046d /lib/std/testing.zig
parent5a06fdfa5525920810005e73eaa1b6e79a6472ca (diff)
downloadzig-dd973fb365dbbe11ce5beac8b4889bfab3fddc4d.tar.gz
zig-dd973fb365dbbe11ce5beac8b4889bfab3fddc4d.zip
std: Use {s} instead of {} when printing strings
Diffstat (limited to 'lib/std/testing.zig')
-rw-r--r--lib/std/testing.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index a6f749b158..d1f025c929 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -29,10 +29,11 @@ pub var zig_exe_path: []const u8 = undefined;
/// and then aborts when actual_error_union is not expected_error.
pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void {
if (actual_error_union) |actual_payload| {
- std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
+ // std.debug.panic("expected error.{s}, found {}", .{ @errorName(expected_error), actual_payload });
+ std.debug.panic("expected error.{s}, found", .{@errorName(expected_error)});
} else |actual_error| {
if (expected_error != actual_error) {
- std.debug.panic("expected error.{}, found error.{}", .{
+ std.debug.panic("expected error.{s}, found error.{s}", .{
@errorName(expected_error),
@errorName(actual_error),
});
@@ -60,7 +61,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void {
.Type => {
if (actual != expected) {
- std.debug.panic("expected type {}, found type {}", .{ @typeName(expected), @typeName(actual) });
+ std.debug.panic("expected type {s}, found type {s}", .{ @typeName(expected), @typeName(actual) });
}
},
@@ -360,7 +361,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void {
for (expected[0..diff_index]) |value| {
if (value == '\n') diff_line_number += 1;
}
- print("First difference occurs on line {}:\n", .{diff_line_number});
+ print("First difference occurs on line {d}:\n", .{diff_line_number});
print("expected:\n", .{});
printIndicatorLine(expected, diff_index);
@@ -416,15 +417,15 @@ fn printWithVisibleNewlines(source: []const u8) void {
while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) {
printLine(source[i .. i + nl]);
}
- print("{}␃\n", .{source[i..]}); // End of Text symbol (ETX)
+ print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX)
}
fn printLine(line: []const u8) void {
if (line.len != 0) switch (line[line.len - 1]) {
- ' ', '\t' => print("{}⏎\n", .{line}), // Carriage return symbol,
+ ' ', '\t' => print("{s}⏎\n", .{line}), // Carriage return symbol,
else => {},
};
- print("{}\n", .{line});
+ print("{s}\n", .{line});
}
test "" {