diff options
| author | Federico Igne <git@federicoigne.com> | 2020-12-26 17:48:38 +0000 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-11-03 18:55:08 +0000 |
| commit | 02481656966b0a8dfc95cf3c22bcc049660ff7d4 (patch) | |
| tree | 8e39798fcaf27931d91c2088423fd4e97adcfc2d /rust/gigasecond/tests | |
| parent | 4e2052c4d792540c2f742b2c2a081b11117ed41d (diff) | |
| download | exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.tar.gz exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.zip | |
Move Rust exercises in a subdirectory
Diffstat (limited to 'rust/gigasecond/tests')
| -rw-r--r-- | rust/gigasecond/tests/gigasecond.rs | 51 |
1 files changed, 51 insertions, 0 deletions
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 @@ | |||
| 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 | } | ||
