add newlines on line formatting
This commit is contained in:
parent
7dc4336474
commit
f0b382375e
2 changed files with 13 additions and 13 deletions
|
|
@ -425,7 +425,7 @@ test "handler: format line 1" {
|
||||||
try handleWeather(&harness.opts, ht.req, ht.res, client_ip);
|
try handleWeather(&harness.opts, ht.req, ht.res, client_ip);
|
||||||
|
|
||||||
try ht.expectStatus(200);
|
try ht.expectStatus(200);
|
||||||
try ht.expectBody("☀️ +20°C");
|
try ht.expectBody("☀️ +20°C\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
test "handler: format line 2" {
|
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 handleWeather(&harness.opts, ht.req, ht.res, client_ip);
|
||||||
|
|
||||||
try ht.expectStatus(200);
|
try ht.expectStatus(200);
|
||||||
try ht.expectBody("☀️ 🌡️+20°C 🌬️↓5km/h");
|
try ht.expectBody("☀️ 🌡️+20°C 🌬️↓5km/h\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
test "handler: format line 3" {
|
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 handleWeather(&harness.opts, ht.req, ht.res, client_ip);
|
||||||
|
|
||||||
try ht.expectStatus(200);
|
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");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
.@"1" => {
|
.@"1" => {
|
||||||
try writer.print("{s} {s}{d:.0}{s}", .{
|
try writer.print("{s} {s}{d:.0}{s}\n", .{
|
||||||
emoji.getWeatherEmoji(data.current.weather_code),
|
emoji.getWeatherEmoji(data.current.weather_code),
|
||||||
sign,
|
sign,
|
||||||
abs_temp,
|
abs_temp,
|
||||||
|
|
@ -28,7 +28,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"2" => {
|
.@"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),
|
emoji.getWeatherEmoji(data.current.weather_code),
|
||||||
sign,
|
sign,
|
||||||
abs_temp,
|
abs_temp,
|
||||||
|
|
@ -39,7 +39,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"3" => {
|
.@"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,
|
data.display_name orelse data.location,
|
||||||
emoji.getWeatherEmoji(data.current.weather_code),
|
emoji.getWeatherEmoji(data.current.weather_code),
|
||||||
sign,
|
sign,
|
||||||
|
|
@ -48,7 +48,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, format: Format, u
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"4" => {
|
.@"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,
|
data.display_name orelse data.location,
|
||||||
emoji.getWeatherEmoji(data.current.weather_code),
|
emoji.getWeatherEmoji(data.current.weather_code),
|
||||||
sign,
|
sign,
|
||||||
|
|
@ -89,7 +89,7 @@ test "format 1" {
|
||||||
|
|
||||||
const output = output_buf[0..writer.end];
|
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" {
|
test "format 2 with imperial units" {
|
||||||
|
|
@ -100,7 +100,7 @@ test "format 2 with imperial units" {
|
||||||
|
|
||||||
const output = output_buf[0..writer.end];
|
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" {
|
test "format 3 with metric units" {
|
||||||
|
|
@ -111,7 +111,7 @@ test "format 3 with metric units" {
|
||||||
|
|
||||||
const output = output_buf[0..writer.end];
|
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)" {
|
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];
|
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" {
|
test "format 4 with metric units" {
|
||||||
|
|
@ -135,7 +135,7 @@ test "format 4 with metric units" {
|
||||||
|
|
||||||
const output = output_buf[0..writer.end];
|
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" {
|
test "format 4 with imperial units" {
|
||||||
|
|
@ -146,5 +146,5 @@ test "format 4 with imperial units" {
|
||||||
|
|
||||||
const output = output_buf[0..writer.end];
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue