aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_eorzea_time.rs84
-rw-r--r--tests/tests.rs20
2 files changed, 84 insertions, 20 deletions
diff --git a/tests/test_eorzea_time.rs b/tests/test_eorzea_time.rs
new file mode 100644
index 0000000..d9b7cef
--- /dev/null
+++ b/tests/test_eorzea_time.rs
@@ -0,0 +1,84 @@
+extern crate ffxiv_chronowatcher;
+
+use ffxiv_chronowatcher::eorzean_time::{convert_to_eorzean_date, convert_to_eorzean_time, earth_sec_to_eorzea_duration, eorzea_duration_to_earth_sec, EorzeanTime, EorzeanDate};
+use chrono::DateTime;
+
+mod time_tests {
+ use super::*;
+ #[test]
+ fn test_convert_to_eorzean_date_astral() {
+ let unix_timestamp = 141414141414;
+ let eorzean_date = convert_to_eorzean_date(unix_timestamp);
+ assert_eq!(eorzean_date.years, 87682);
+ assert_eq!(eorzean_date.suns, 18);
+ assert_eq!(eorzean_date.bells, 16);
+ assert_eq!(eorzean_date.minutes, 4);
+ assert_eq!(eorzean_date.guardian, "Llymlaen");
+ assert_eq!(eorzean_date.phase, "Full Moon");
+ assert_eq!(eorzean_date.moon, "Third Astral Moon");
+ }
+
+ #[test]
+ fn test_convert_to_ez_chrono_datetime(){
+ let timestamp: i64 = 141414141414;
+ let chrono_date = DateTime::from_timestamp(timestamp, 0).expect("Failed to create DateTime");
+ let eorzean_date = convert_to_eorzean_date(chrono_date);
+ assert_eq!(eorzean_date.years, 87682);
+ assert_eq!(eorzean_date.suns, 18);
+ assert_eq!(eorzean_date.bells, 16);
+ assert_eq!(eorzean_date.minutes, 4);
+ assert_eq!(eorzean_date.guardian, "Llymlaen");
+ assert_eq!(eorzean_date.phase, "Full Moon");
+ assert_eq!(eorzean_date.moon, "Third Astral Moon");
+ }
+
+ #[test]
+ fn test_convert_eorzean_date_umbral() {
+ let unix_timestamp = 11223344;
+ let eorzean_date = convert_to_eorzean_date(unix_timestamp);
+ assert_eq!(eorzean_date.years, 6);
+ assert_eq!(eorzean_date.suns, 17);
+ assert_eq!(eorzean_date.bells, 5);
+ assert_eq!(eorzean_date.minutes, 23);
+ assert_eq!(eorzean_date.guardian, "Althyk");
+ assert_eq!(eorzean_date.phase, "Full Moon");
+ assert_eq!(eorzean_date.moon, "Sixth Umbral Moon");
+ }
+
+ #[test]
+ fn test_convert_to_eorzean_time() {
+ let unix_timestamp = 1661114514;
+ let time_tuple = convert_to_eorzean_time(unix_timestamp);
+ assert_eq!(time_tuple.0, 10);
+ assert_eq!(time_tuple.1, 56);
+ }
+
+ #[test]
+ fn test_earth_sec_to_eorzea_sec(){
+ let test_seconds = 70*60; // 70 minutes in seconds, should eq 1 sun = 86400 EZ sec
+ let eorzean_duration = earth_sec_to_eorzea_duration(test_seconds);
+ assert_eq!(eorzean_duration.suns, 1);
+ assert_eq!(eorzean_duration.years, 0);
+ assert_eq!(eorzean_duration.moons, 0);
+ assert_eq!(eorzean_duration.weeks, 0);
+ assert_eq!(eorzean_duration.bells, 0);
+ assert_eq!(eorzean_duration.minutes, 0);
+ }
+
+ #[test]
+ fn test_eorzea_dur_to_earth_sec() {
+ let test_ez_time = EorzeanTime{
+ years: 0,
+ moons: 0,
+ weeks: 1,
+ suns: 1,
+ bells: 0,
+ minutes: 0,
+ seconds: 0
+ };
+ // 37800 seconds in Earth time
+ let seconds = eorzea_duration_to_earth_sec(test_ez_time);
+ assert_eq!(seconds, 37800);
+ }
+}
+
diff --git a/tests/tests.rs b/tests/tests.rs
deleted file mode 100644
index 58d409e..0000000
--- a/tests/tests.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-extern crate ffxiv_chronowatcher;
-
-use ffxiv_chronowatcher::eorzean_time::{convert_to_eorzean_date, EorzeanDate};
-
-mod time_tests {
- use super::*;
- #[test]
- fn test_convert_to_eorzean_date() {
- let unix_timestamp = 1661114514;
- let eorzean_date = convert_to_eorzean_date(unix_timestamp);
- assert_eq!(eorzean_date.years, 1);
- assert_eq!(eorzean_date.suns, 12);
- assert_eq!(eorzean_date.bells, 12);
- assert_eq!(eorzean_date.minutes, 4);
- assert_eq!(eorzean_date.guardian, "Halone");
- assert_eq!(eorzean_date.phase, "Waxing Gibbous");
- assert_eq!(eorzean_date.moon, "First Astral Moon");
- }
-}
-
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage