diff options
| author | Federico Igne <git@federicoigne.com> | 2020-06-09 19:37:37 +0100 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-11-03 18:54:52 +0000 |
| commit | 12c8aedd5dfae75ec6bde982968bc77b70550374 (patch) | |
| tree | f838b0bd6d15262a13c95c4115669e34accfb123 /gigasecond/tests/gigasecond.rs | |
| parent | 0fa3d7fe5a27b87bcffb89fb30ffd294a0c2c40a (diff) | |
| download | exercism-12c8aedd5dfae75ec6bde982968bc77b70550374.tar.gz exercism-12c8aedd5dfae75ec6bde982968bc77b70550374.zip | |
[rust] Gigasecond
Diffstat (limited to 'gigasecond/tests/gigasecond.rs')
| -rw-r--r-- | gigasecond/tests/gigasecond.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gigasecond/tests/gigasecond.rs b/gigasecond/tests/gigasecond.rs new file mode 100644 index 0000000..4fe139b --- /dev/null +++ b/gigasecond/tests/gigasecond.rs | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | use chrono::{TimeZone, Utc}; | ||
| 2 | |||
| 3 | #[test] | ||
| 4 | fn test_date() { | ||
| 5 | let start_date = Utc.ymd(2011, 4, 25).and_hms(0, 0, 0); | ||
| 6 | |||
| 7 | assert_eq!( | ||
| 8 | gigasecond::after(start_date), | ||
| 9 | Utc.ymd(2043, 1, 1).and_hms(1, 46, 40) | ||
| 10 | ); | ||
| 11 | } | ||
| 12 | |||
| 13 | #[test] | ||
| 14 | fn test_another_date() { | ||
| 15 | let start_date = Utc.ymd(1977, 6, 13).and_hms(0, 0, 0); | ||
| 16 | |||
| 17 | assert_eq!( | ||
| 18 | gigasecond::after(start_date), | ||
| 19 | Utc.ymd(2009, 2, 19).and_hms(1, 46, 40) | ||
| 20 | ); | ||
| 21 | } | ||
| 22 | |||
| 23 | #[test] | ||
| 24 | fn test_third_date() { | ||
| 25 | let start_date = Utc.ymd(1959, 7, 19).and_hms(0, 0, 0); | ||
| 26 | |||
| 27 | assert_eq!( | ||
| 28 | gigasecond::after(start_date), | ||
| 29 | Utc.ymd(1991, 3, 27).and_hms(1, 46, 40) | ||
| 30 | ); | ||
| 31 | } | ||
| 32 | |||
| 33 | #[test] | ||
| 34 | fn test_datetime() { | ||
| 35 | let start_date = Utc.ymd(2015, 1, 24).and_hms(22, 0, 0); | ||
| 36 | |||
| 37 | assert_eq!( | ||
| 38 | gigasecond::after(start_date), | ||
| 39 | Utc.ymd(2046, 10, 2).and_hms(23, 46, 40) | ||
| 40 | ); | ||
| 41 | } | ||
| 42 | |||
| 43 | #[test] | ||
| 44 | fn test_another_datetime() { | ||
| 45 | let start_date = Utc.ymd(2015, 1, 24).and_hms(23, 59, 59); | ||
| 46 | |||
| 47 | assert_eq!( | ||
| 48 | gigasecond::after(start_date), | ||
| 49 | Utc.ymd(2046, 10, 3).and_hms(1, 46, 39) | ||
| 50 | ); | ||
| 51 | } | ||
