mirror of
https://github.com/bspeice/dtparse
synced 2024-12-22 12:28:08 -05:00
Regenerate tests
Need to make this automated
This commit is contained in:
parent
c038178583
commit
9008ee8339
@ -1068,7 +1068,6 @@ impl Parser {
|
|||||||
if hms == 0 {
|
if hms == 0 {
|
||||||
res.hour = Some(value.to_i64().unwrap() as i32);
|
res.hour = Some(value.to_i64().unwrap() as i32);
|
||||||
if !close_to_integer(&value) {
|
if !close_to_integer(&value) {
|
||||||
// TODO: High probability of issues with rounding here.
|
|
||||||
res.minute = Some((*SIXTY * (value % *ONE)).to_i64().unwrap() as i32);
|
res.minute = Some((*SIXTY * (value % *ONE)).to_i64().unwrap() as i32);
|
||||||
}
|
}
|
||||||
} else if hms == 1 {
|
} else if hms == 1 {
|
||||||
@ -1088,6 +1087,7 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_min_sec(&self, value: Decimal) -> (i32, Option<i32>) {
|
fn parse_min_sec(&self, value: Decimal) -> (i32, Option<i32>) {
|
||||||
|
// UNWRAP: i64 guaranteed to be fine because of preceding floor
|
||||||
let minute = value.floor().to_i64().unwrap() as i32;
|
let minute = value.floor().to_i64().unwrap() as i32;
|
||||||
let mut second = None;
|
let mut second = None;
|
||||||
|
|
||||||
|
@ -863,3 +863,39 @@ fn test_tokenize142() {
|
|||||||
let comp = vec!["Today", " ", "is", " ", "25", " ", "of", " ", "September", " ", "of", " ", "2003", ",", " ", "exactly", " ", "at", " ", "10", ":", "49", ":", "41", " ", "with", " ", "timezone", " ", "-", "03", ":", "00", "."];
|
let comp = vec!["Today", " ", "is", " ", "25", " ", "of", " ", "September", " ", "of", " ", "2003", ",", " ", "exactly", " ", "at", " ", "10", ":", "49", ":", "41", " ", "with", " ", "timezone", " ", "-", "03", ":", "00", "."];
|
||||||
tokenize_assert("Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", comp);
|
tokenize_assert("Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize143() {
|
||||||
|
let comp = vec!["I", " ", "have", " ", "a", " ", "meeting", " ", "on", " ", "March", " ", "1", ",", " ", "1974"];
|
||||||
|
tokenize_assert("I have a meeting on March 1, 1974", comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize144() {
|
||||||
|
let comp = vec!["On", " ", "June", " ", "8", "th", ",", " ", "2020", ",", " ", "I", " ", "am", " ", "going", " ", "to", " ", "be", " ", "the", " ", "first", " ", "man", " ", "on", " ", "Mars"];
|
||||||
|
tokenize_assert("On June 8th, 2020, I am going to be the first man on Mars", comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize145() {
|
||||||
|
let comp = vec!["Meet", " ", "me", " ", "at", " ", "the", " ", "AM", "/", "PM", " ", "on", " ", "Sunset", " ", "at", " ", "3", ":", "00", " ", "AM", " ", "on", " ", "December", " ", "3", "rd", ",", " ", "2003"];
|
||||||
|
tokenize_assert("Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003", comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize146() {
|
||||||
|
let comp = vec!["Meet", " ", "me", " ", "at", " ", "3", ":", "00", " ", "AM", " ", "on", " ", "December", " ", "3", "rd", ",", " ", "2003", " ", "at", " ", "the", " ", "AM", "/", "PM", " ", "on", " ", "Sunset"];
|
||||||
|
tokenize_assert("Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset", comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize147() {
|
||||||
|
let comp = vec!["Jan", " ", "29", ",", " ", "1945", " ", "14", ":", "45", " ", "AM", " ", "I", " ", "going", " ", "to", " ", "see", " ", "you", " ", "there", "?"];
|
||||||
|
tokenize_assert("Jan 29, 1945 14:45 AM I going to see you there?", comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tokenize148() {
|
||||||
|
let comp = vec!["2017", "-", "07", "-", "17", " ", "06", ":", "15", ":"];
|
||||||
|
tokenize_assert("2017-07-17 06:15:", comp);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user