aboutsummaryrefslogtreecommitdiff
path: root/rust/gigasecond/tests/gigasecond.rs
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2020-12-26 17:48:38 +0000
committerFederico Igne <git@federicoigne.com>2021-11-03 18:55:08 +0000
commit02481656966b0a8dfc95cf3c22bcc049660ff7d4 (patch)
tree8e39798fcaf27931d91c2088423fd4e97adcfc2d /rust/gigasecond/tests/gigasecond.rs
parent4e2052c4d792540c2f742b2c2a081b11117ed41d (diff)
downloadexercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.tar.gz
exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.zip
Move Rust exercises in a subdirectory
Diffstat (limited to 'rust/gigasecond/tests/gigasecond.rs')
-rw-r--r--rust/gigasecond/tests/gigasecond.rs51
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 @@
1use chrono::{TimeZone, Utc};
2
3#[test]
4fn 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]
14fn 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]
24fn 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]
34fn 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]
44fn 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}