From 02481656966b0a8dfc95cf3c22bcc049660ff7d4 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sat, 26 Dec 2020 17:48:38 +0000 Subject: Move Rust exercises in a subdirectory --- rust/gigasecond/tests/gigasecond.rs | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 rust/gigasecond/tests/gigasecond.rs (limited to 'rust/gigasecond/tests/gigasecond.rs') diff --git a/rust/gigasecond/tests/gigasecond.rs b/rust/gigasecond/tests/gigasecond.rs new file mode 100644 index 0000000..4fe139b --- /dev/null +++ b/rust/gigasecond/tests/gigasecond.rs @@ -0,0 +1,51 @@ +use chrono::{TimeZone, Utc}; + +#[test] +fn test_date() { + let start_date = Utc.ymd(2011, 4, 25).and_hms(0, 0, 0); + + assert_eq!( + gigasecond::after(start_date), + Utc.ymd(2043, 1, 1).and_hms(1, 46, 40) + ); +} + +#[test] +fn test_another_date() { + let start_date = Utc.ymd(1977, 6, 13).and_hms(0, 0, 0); + + assert_eq!( + gigasecond::after(start_date), + Utc.ymd(2009, 2, 19).and_hms(1, 46, 40) + ); +} + +#[test] +fn test_third_date() { + let start_date = Utc.ymd(1959, 7, 19).and_hms(0, 0, 0); + + assert_eq!( + gigasecond::after(start_date), + Utc.ymd(1991, 3, 27).and_hms(1, 46, 40) + ); +} + +#[test] +fn test_datetime() { + let start_date = Utc.ymd(2015, 1, 24).and_hms(22, 0, 0); + + assert_eq!( + gigasecond::after(start_date), + Utc.ymd(2046, 10, 2).and_hms(23, 46, 40) + ); +} + +#[test] +fn test_another_datetime() { + let start_date = Utc.ymd(2015, 1, 24).and_hms(23, 59, 59); + + assert_eq!( + gigasecond::after(start_date), + Utc.ymd(2046, 10, 3).and_hms(1, 46, 39) + ); +} -- cgit v1.2.3