summaryrefslogtreecommitdiff
path: root/tests/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests.rs')
-rw-r--r--tests/tests.rs38
1 files changed, 30 insertions, 8 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index a2852d8..1c593be 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1587,18 +1587,40 @@ fn simple_noon_past_and_future() {
fn midnight() {
let d1 = NaiveDate::from_ymd(1969, 5, 7).and_hms(0, 0, 0);
let d2 = d1 + Duration::seconds(1);
- match parse("midnight on May 6, 1969", None) {
- Ok((start, end, _)) => {
- assert_eq!(d1, start);
- assert_eq!(d2, end);
- }
- Err(e) => {
- println!("{:?}", e);
- assert!(false, "didn't match");
+ for phrase in [
+ "midnight on May 6, 1969",
+ // TODO Add 12h representation, whichever is considered midnight?!
+ // Possible am/pm might differ between GB and some colonial time
+ // representations, just as an imperial gallon is roughly 4.5
+ // litres while a US gallon is not even 3.8 liters.
+ "00:00 on May 7, 1969", ].iter()
+ {
+ match parse(phrase, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
}
}
}
+#[test]
+fn invalid_24_00() {
+ // While 24:00 might arguably be an ok time, is not implemented in this crate.
+ let phrase = "24:00";
+ assert!(parse(phrase, None).is_err());
+}
+
+#[test]
+fn super_invalid_24_30() {
+ let phrase = "24:30";
+ assert!(parse(phrase, None).is_err());
+}
+
#[derive(Debug)]
enum Period {
Week,