mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Test more cases in parse_{weekday, monthname}
This commit is contained in:
parent
a3e061f0ca
commit
9cf86a5839
1 changed files with 27 additions and 0 deletions
27
src/date.rs
27
src/date.rs
|
@ -659,5 +659,32 @@ mod tests {
|
|||
let (res, parsed) = parse(date, "weekday");
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(parsed.weekday, Some(Weekday::Sat));
|
||||
|
||||
let date = vec![DateToken::Literal("sun".into())];
|
||||
assert!(parse(date, "weekday").0.is_ok());
|
||||
|
||||
let date = vec![DateToken::Literal("snu".into())];
|
||||
assert_eq!(parse(date, "weekday").0, Err("Unknown weekday: snu".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_monthname() {
|
||||
for (i, &s) in [
|
||||
"jan", "feb", "mar", "apr", "may", "june", "jul", "AUGUST", "SEp", "Oct", "novemBer",
|
||||
"dec",
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let date = vec![DateToken::Literal(s.into())];
|
||||
let (res, parsed) = parse(date, "monthname");
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(parsed.month, Some(i as u32 + 1));
|
||||
}
|
||||
|
||||
let date = vec![DateToken::Literal("foobar".into())];
|
||||
let (res, parsed) = parse(date, "monthname");
|
||||
assert_eq!(res, Err("Unknown month name: foobar".into()));
|
||||
assert_eq!(parsed.month, None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue