std: Use {s} instead of {} when printing strings

This commit is contained in:
LemonBoy
2020-11-26 09:48:12 +01:00
committed by Andrew Kelley
parent 5a06fdfa55
commit dd973fb365
32 changed files with 771 additions and 231 deletions

View File

@@ -164,8 +164,8 @@ pub fn format(
) !void {
if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
try std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });
if (self.pre) |pre| try std.fmt.format(out_stream, "-{}", .{pre});
if (self.build) |build| try std.fmt.format(out_stream, "+{}", .{build});
if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build});
}
const expect = std.testing.expect;
@@ -287,9 +287,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !
if (std.mem.eql(u8, result, expected)) return;
std.debug.warn("\n====== expected this output: =========\n", .{});
std.debug.warn("{}", .{expected});
std.debug.warn("{s}", .{expected});
std.debug.warn("\n======== instead found this: =========\n", .{});
std.debug.warn("{}", .{result});
std.debug.warn("{s}", .{result});
std.debug.warn("\n======================================\n", .{});
return error.TestFailed;
}