diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-27 20:42:17 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-27 20:42:17 +0200 |
commit | 47290952ce5f7cbd1c105a1819004d2a1069087a (patch) | |
tree | e5702d16c258eb207c0d2e5a61ff8de81a25c236 | |
parent | 416729fec9cd57957e0eacccedd3143a8cdbd048 (diff) |
Add tests to add more than one larger unit in the smaller unit
-rw-r--r-- | src/timetype.rs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs index 3acfb58..0d2081b 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -2209,6 +2209,75 @@ mod moment_plus_amount_tests { expected = NaiveDate::from_ymd(1999, 1, 1).and_hms(0, 0, 0); } + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_minute_in_seconds; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::seconds(130); + expected = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 2, 10); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_hour_in_minutes; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::minutes(130); + expected = NaiveDate::from_ymd(2000, 1, 1).and_hms(2, 10, 00); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_day_in_hours_1; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::hours(50); + expected = NaiveDate::from_ymd(2000, 1, 3).and_hms(2, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_day_in_hours_2; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::hours(170); + expected = NaiveDate::from_ymd(2000, 1, 8).and_hms(2, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_month_in_days_1; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::days(80); + expected = NaiveDate::from_ymd(2000, 3,21).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_month_in_days_2; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::days(120); + expected = NaiveDate::from_ymd(2000, 4,30).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_month_in_days_3; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::days(150); + expected = NaiveDate::from_ymd(2000, 5,30).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_year_in_months_1; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::months(15); + expected = NaiveDate::from_ymd(2001, 4, 1).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_year_in_months_2; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::months(25); + expected = NaiveDate::from_ymd(2002, 2, 1).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_more_than_one_year_in_months_3; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::months(78); + expected = NaiveDate::from_ymd(2006, 7, 1).and_hms(0, 0, 0); + } } #[cfg(test)] |