Add test setting max year date

pull/4/head
Diego Barrios Romero 2020-05-02 12:37:47 +02:00
parent 9fe57bbdf6
commit 4a455b7828
1 changed files with 27 additions and 2 deletions

View File

@ -222,19 +222,33 @@ macro_rules! invalid_dt_test {
mod $name { mod $name {
use super::*; use super::*;
#[test] #[test]
fn too_small() { fn datetime_too_small() {
let dt = NaiveDate::from_ymd(1999, 1, 2).and_hms(3, 4, 5); let dt = NaiveDate::from_ymd(1999, 1, 2).and_hms(3, 4, 5);
let mut dev = $create_method(&[]); let mut dev = $create_method(&[]);
assert_invalid_input_data!(dev.set_datetime(&dt)); assert_invalid_input_data!(dev.set_datetime(&dt));
$destroy_method(dev); $destroy_method(dev);
} }
#[test] #[test]
fn too_big() { fn datetime_too_big() {
let dt = NaiveDate::from_ymd(2101, 1, 2).and_hms(3, 4, 5); let dt = NaiveDate::from_ymd(2101, 1, 2).and_hms(3, 4, 5);
let mut dev = $create_method(&[]); let mut dev = $create_method(&[]);
assert_invalid_input_data!(dev.set_datetime(&dt)); assert_invalid_input_data!(dev.set_datetime(&dt));
$destroy_method(dev); $destroy_method(dev);
} }
#[test]
fn date_too_small() {
let d = NaiveDate::from_ymd(1999, 1, 2);
let mut dev = $create_method(&[]);
assert_invalid_input_data!(dev.set_date(&d));
$destroy_method(dev);
}
#[test]
fn date_too_big() {
let d = NaiveDate::from_ymd(2101, 1, 2);
let mut dev = $create_method(&[]);
assert_invalid_input_data!(dev.set_date(&d));
$destroy_method(dev);
}
} }
}; };
} }
@ -318,6 +332,17 @@ macro_rules! dt_test {
$destroy_method(dev); $destroy_method(dev);
} }
#[test]
fn set_date_century() {
let d = NaiveDate::from_ymd(2100, 8, 13);
let mut dev = $create_method(&$mac_trans_write!(
DOW,
[0b0000_0110, 0b0001_0011, 0b1000_1000, 0]
));
dev.set_date(&d).unwrap();
$destroy_method(dev);
}
#[test] #[test]
fn get_time() { fn get_time() {
let t = NaiveTime::from_hms(23, 59, 58); let t = NaiveTime::from_hms(23, 59, 58);