diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-12 18:24:26 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-14 17:24:34 +0200 |
commit | 65ec04fffcab128deb14ce55b46c0149a8622e8c (patch) | |
tree | e22107c94856cdaf1949a3ac82e5555ee8091c3f /src/timetype.rs | |
parent | df2aaeb88a885440b2e7bcf3c28c9709a8700cf0 (diff) |
Add tests to test adding incorrect instances to moments
Diffstat (limited to 'src/timetype.rs')
-rw-r--r-- | src/timetype.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs index fdc28ba..ed32f43 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -1913,6 +1913,41 @@ mod moment_plus_amount_tests { expected = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 1, 1); } + generate_test_moment_plus_amount! { + name = test_moment_plus_invalid_months; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::months(13); + expected = NaiveDate::from_ymd(2001, 2, 1).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_invalid_days; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::days(31); + expected = NaiveDate::from_ymd(2000, 2, 1).and_hms(0, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_invalid_hours; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::hours(25); + expected = NaiveDate::from_ymd(2000, 1, 2).and_hms(1, 0, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_invalid_minutes; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::minutes(61); + expected = NaiveDate::from_ymd(2000, 1, 1).and_hms(1, 1, 0); + } + + generate_test_moment_plus_amount! { + name = test_moment_plus_invalid_seconds; + base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); + amount = TT::seconds(61); + expected = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 1, 1); + } + generate_test_moment_minus_amount! { name = test_moment_minus_nothing; base = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); |