aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-11-23 14:09:55 -0800
committerPinapelz <yukais@pinapelz.com>2024-11-23 14:09:55 -0800
commit4b013b8b9af0e8db48b10882f64bff252cf7742d (patch)
tree613df605359dfe94580e52cee9ab133391d01b6d /tests
parent0e305e7cecd697a7befe26298abc90bef0fac483 (diff)
add user-defined global weather timing offsetHEADmaster
helper for adjusting final output unix time. Should only be used in single-threaded environment
Diffstat (limited to 'tests')
-rw-r--r--tests/test_eorzea_weather.rs48
1 files changed, 31 insertions, 17 deletions
diff --git a/tests/test_eorzea_weather.rs b/tests/test_eorzea_weather.rs
index a13b994..027097d 100644
--- a/tests/test_eorzea_weather.rs
+++ b/tests/test_eorzea_weather.rs
@@ -1,12 +1,15 @@
extern crate ffxiv_chronowatcher;
-use ffxiv_chronowatcher::eorzean_weather::{calculate_current_weather_interval, find_next_weather_occurance, get_weather_by_time, calculate_forecast, Weather};
-use chrono::DateTime;
+use ffxiv_chronowatcher::eorzean_weather::{
+ calculate_current_weather_interval, calculate_forecast, find_next_weather_occurance,
+ get_global_weather_timing_offset, get_weather_by_time, set_global_weather_timing_offset,
+ Weather,
+};
mod weather_tests {
use super::*;
#[test]
- fn test_calculate_current_weather_interval(){
+ fn test_calculate_current_weather_interval() {
let timestamp = 1724738458;
let (start, end) = calculate_current_weather_interval(timestamp);
assert_eq!(start, 1724738403);
@@ -14,14 +17,13 @@ mod weather_tests {
}
#[test]
- fn test_get_weather_by_time(){
+ fn test_get_weather_by_time() {
let timestamp = 1724738458;
- let weather = get_weather_by_time("Middle La Noscea", timestamp);
- println!("{:?}", weather);
+ get_weather_by_time("Middle La Noscea", timestamp);
}
#[test]
- fn test_calculate_forecast_pos_offset(){
+ fn test_calculate_forecast_pos_offset() {
let timestamp = 1724738458;
let weather = calculate_forecast("Middle La Noscea", timestamp, 8);
assert_eq!(weather.weather, Weather::ClearSkies);
@@ -31,7 +33,7 @@ mod weather_tests {
}
#[test]
- fn test_calculate_forecast_neg_offset(){
+ fn test_calculate_forecast_neg_offset() {
let timestamp = 1724738458;
let weather = calculate_forecast("Middle La Noscea", timestamp, -1);
assert_eq!(weather.weather, Weather::Wind);
@@ -41,7 +43,7 @@ mod weather_tests {
}
#[test]
- fn test_calculate_forecast_zero_offset(){
+ fn test_calculate_forecast_zero_offset() {
let timestamp = 1724738458;
let weather = calculate_forecast("Middle La Noscea", timestamp, 0);
assert_eq!(weather.weather, Weather::Wind);
@@ -51,7 +53,7 @@ mod weather_tests {
}
#[test]
- fn test_find_next_weather_occurance(){
+ fn test_find_next_weather_occurance() {
let timestamp = 1724738458;
let weather = find_next_weather_occurance("Eureka Pagos", timestamp, Weather::Blizzards);
assert_eq!(weather.weather, Weather::Blizzards);
@@ -61,7 +63,7 @@ mod weather_tests {
}
#[test]
- fn test_convert_weather_enum_to_string(){
+ fn test_convert_weather_enum_to_string() {
let weather_variants = vec![
(Weather::AstroMagneticStorm, "Astro-Magnetic Storms"),
(Weather::Blizzards, "Blizzards"),
@@ -90,19 +92,31 @@ mod weather_tests {
}
#[test]
- fn test_calculate_current_weather_interval_day_overflow(){
- let (start, end) = calculate_current_weather_interval(1672531199);
- assert_eq!(1,1);
+ fn test_calculate_current_weather_interval_day_overflow() {
+ let (_, __) = calculate_current_weather_interval(1672531199);
+ assert_eq!(1, 1);
}
#[test]
#[should_panic]
fn get_weather_by_time_panic_zone_not_found() {
let timestamp = 1724738458;
- let weather = get_weather_by_time("Somewhere Not Here", timestamp);
+ get_weather_by_time("Somewhere Not Here", timestamp);
}
+ #[test]
+ fn test_set_global_offset() {
+ set_global_weather_timing_offset(1724738458);
+ assert_eq!(get_global_weather_timing_offset(), 1724738458);
+ set_global_weather_timing_offset(0);
+ }
-
+ #[test]
+ fn test_find_weather_by_time_with_offset() {
+ let timestamp = 1732396696;
+ set_global_weather_timing_offset(40);
+ let weather = find_next_weather_occurance("Eureka Pagos", timestamp, Weather::Fog);
+ assert_eq!(weather.start_time, 1732401962);
+ set_global_weather_timing_offset(0);
+ }
}
-
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage