add newlines on line formatting
All checks were successful
Generic zig build / build (push) Successful in 1m37s
Generic zig build / deploy (push) Successful in 13s

This commit is contained in:
Emil Lerch 2026-01-08 21:28:54 -08:00
parent 7dc4336474
commit f0b382375e
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 13 additions and 13 deletions

View file

@ -425,7 +425,7 @@ test "handler: format line 1" {
try handleWeather(&harness.opts, ht.req, ht.res, client_ip);
try ht.expectStatus(200);
try ht.expectBody("☀️ +20°C");
try ht.expectBody("☀️ +20°C\n");
}
test "handler: format line 2" {
@ -446,7 +446,7 @@ test "handler: format line 2" {
try handleWeather(&harness.opts, ht.req, ht.res, client_ip);
try ht.expectStatus(200);
try ht.expectBody("☀️ 🌡️+20°C 🌬↓5km/h");
try ht.expectBody("☀️ 🌡️+20°C 🌬↓5km/h\n");
}
test "handler: format line 3" {
@ -467,5 +467,5 @@ test "handler: format line 3" {
try handleWeather(&harness.opts, ht.req, ht.res, client_ip);
try ht.expectStatus(200);
try ht.expectBody("Union City, California, United States: ☀️ +20°C");
try ht.expectBody("Union City, California, United States: ☀️ +20°C\n");
}

View file

@ -20,7 +20,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
switch (format) {
.@"1" => {
try writer.print("{s} {s}{d:.0}{s}", .{
try writer.print("{s} {s}{d:.0}{s}\n", .{
emoji.getWeatherEmoji(data.current.weather_code),
sign,
abs_temp,
@ -28,7 +28,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
});
},
.@"2" => {
try writer.print("{s} 🌡️{s}{d:.0}{s} 🌬️{s}{d:.0}{s}", .{
try writer.print("{s} 🌡️{s}{d:.0}{s} 🌬️{s}{d:.0}{s}\n", .{
emoji.getWeatherEmoji(data.current.weather_code),
sign,
abs_temp,
@ -39,7 +39,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
});
},
.@"3" => {
try writer.print("{s}: {s} {s}{d:.0}{s}", .{
try writer.print("{s}: {s} {s}{d:.0}{s}\n", .{
data.display_name orelse data.location,
emoji.getWeatherEmoji(data.current.weather_code),
sign,
@ -48,7 +48,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
});
},
.@"4" => {
try writer.print("{s}: {s} 🌡️{s}{d:.0}{s} 🌬️{s}{d:.0}{s}", .{
try writer.print("{s}: {s} 🌡️{s}{d:.0}{s} 🌬️{s}{d:.0}{s}\n", .{
data.display_name orelse data.location,
emoji.getWeatherEmoji(data.current.weather_code),
sign,
@ -89,7 +89,7 @@ test "format 1" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("☀️ +15°C", output);
try std.testing.expectEqualStrings("☀️ +15°C\n", output);
}
test "format 2 with imperial units" {
@ -100,7 +100,7 @@ test "format 2 with imperial units" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("☀️ 🌡️+59°F 🌬↓6mph", output);
try std.testing.expectEqualStrings("☀️ 🌡️+59°F 🌬↓6mph\n", output);
}
test "format 3 with metric units" {
@ -111,7 +111,7 @@ test "format 3 with metric units" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("London: ☀️ +15°C", output);
try std.testing.expectEqualStrings("London: ☀️ +15°C\n", output);
}
test "format 3 with imperial units (display name)" {
@ -124,7 +124,7 @@ test "format 3 with imperial units (display name)" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("Hello, world: ☀️ +59°F", output);
try std.testing.expectEqualStrings("Hello, world: ☀️ +59°F\n", output);
}
test "format 4 with metric units" {
@ -135,7 +135,7 @@ test "format 4 with metric units" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("London: ☀️ 🌡️+15°C 🌬↓10km/h", output);
try std.testing.expectEqualStrings("London: ☀️ 🌡️+15°C 🌬↓10km/h\n", output);
}
test "format 4 with imperial units" {
@ -146,5 +146,5 @@ test "format 4 with imperial units" {
const output = output_buf[0..writer.end];
try std.testing.expectEqualStrings("London: ☀️ 🌡️+59°F 🌬↓6mph", output);
try std.testing.expectEqualStrings("London: ☀️ 🌡️+59°F 🌬↓6mph\n", output);
}