diff --git a/src/http/handler.zig b/src/http/handler.zig index 479b6d3..1507829 100644 --- a/src/http/handler.zig +++ b/src/http/handler.zig @@ -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"); } diff --git a/src/render/Line.zig b/src/render/Line.zig index 65bb6fc..dde35a1 100644 --- a/src/render/Line.zig +++ b/src/render/Line.zig @@ -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); }