From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 3/3] time: Add more calendat event tests
Date: Wed, 13 Aug 2025 14:43:45 +0200 [thread overview]
Message-ID: <20250813124347.452585-4-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250813124347.452585-1-m.sandoval@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-time/src/calendar_event.rs | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/proxmox-time/src/calendar_event.rs b/proxmox-time/src/calendar_event.rs
index 6fe453be..6a158b7c 100644
--- a/proxmox-time/src/calendar_event.rs
+++ b/proxmox-time/src/calendar_event.rs
@@ -477,9 +477,15 @@ mod tests {
use std::str::FromStr;
assert!(CalendarEvent::from_str("15:30").is_ok());
+ assert!(CalendarEvent::from_str("0").is_ok());
+ assert!(CalendarEvent::from_str("59").is_ok());
+ assert!(CalendarEvent::from_str("15:30:59").is_ok());
assert!(CalendarEvent::from_str("24:00").is_err());
assert!(CalendarEvent::from_str("40:00").is_err());
+ assert!(CalendarEvent::from_str("60").is_err());
+ assert!(CalendarEvent::from_str("24:61").is_err());
+ assert!(CalendarEvent::from_str("15:30:60").is_err());
}
#[test]
@@ -495,6 +501,10 @@ mod tests {
}
);
+ assert!(parse_time_spec("1:00:00").is_ok());
+ assert!(parse_time_spec("1:00").is_ok());
+ assert!(parse_time_spec("59").is_ok());
+
// These do not strictly fail, but should fail when parsed with FromStr
// since there will be input left to consume.
let (input, data) = parse_time_spec("40:00").unwrap();
@@ -507,5 +517,23 @@ mod tests {
second: vec![DateTimeValue::Single(0)]
}
);
+
+ assert!(parse_time_spec("61").is_err());
+ // This should be 1:00 instead.
+ assert!(parse_time_spec("60").is_err());
+
+ // Can only partially parse
+ let (input, _data) = parse_time_spec("24:61").unwrap();
+ assert_eq!(input, ":61");
+
+
+ assert_eq!(
+ data,
+ TimeSpec {
+ hour: vec![],
+ minute: vec![DateTimeValue::Single(40)],
+ second: vec![DateTimeValue::Single(0)]
+ }
+ );
}
}
--
2.47.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-08-13 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 12:43 [pbs-devel] [PATCH proxmox v2 0/3] fix #6161: time: Split parse_time_spec parser into two Maximiliano Sandoval
2025-08-13 12:43 ` [pbs-devel] [PATCH proxmox v2 1/3] time: Add traits to DateTimeValue and TimeSpec Maximiliano Sandoval
2025-08-13 12:43 ` [pbs-devel] [PATCH proxmox v2 2/3] fix #6161: time: Split parse_time_spec parser into two Maximiliano Sandoval
2025-08-13 12:43 ` Maximiliano Sandoval [this message]
2025-08-26 21:58 ` [pbs-devel] [PATCH proxmox v2 0/3] " Thomas Lamprecht
2025-08-27 8:40 ` Maximiliano Sandoval
2025-08-27 9:02 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250813124347.452585-4-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox