From 9008ee8339bce63f645d7b44bb3f4a36b416e405 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 8 Jul 2018 21:16:43 -0400 Subject: [PATCH] Regenerate tests Need to make this automated --- src/lib.rs | 2 +- src/tests/pycompat_tokenizer.rs | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 334bae2..695667f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1068,7 +1068,6 @@ impl Parser { if hms == 0 { res.hour = Some(value.to_i64().unwrap() as i32); if !close_to_integer(&value) { - // TODO: High probability of issues with rounding here. res.minute = Some((*SIXTY * (value % *ONE)).to_i64().unwrap() as i32); } } else if hms == 1 { @@ -1088,6 +1087,7 @@ impl Parser { } fn parse_min_sec(&self, value: Decimal) -> (i32, Option) { + // UNWRAP: i64 guaranteed to be fine because of preceding floor let minute = value.floor().to_i64().unwrap() as i32; let mut second = None; diff --git a/src/tests/pycompat_tokenizer.rs b/src/tests/pycompat_tokenizer.rs index 6ba6a21..fbf35c8 100644 --- a/src/tests/pycompat_tokenizer.rs +++ b/src/tests/pycompat_tokenizer.rs @@ -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", "."]; 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); +}