Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates committed Jul 13, 2024
1 parent c7c089a commit 8c695da
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions fuzz/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ pub fn test_message(data: &[u8]) {
let _ = roundtrip_distinguished::<test_messages::TestDistinguished>(data).unwrap_error();
}

static DATE_RE: LazyLock<Regex> = LazyLock::new(|| {
let year = r"(\d{4}|[+-]\d+)";
let month = r"(0[1-9]|1[0-2])";
let day_of_month = r"([0-2]\d|3[01])";
let date = format!("{year}-{month}-{day_of_month}");
let hour = r"([01]\d|2[0-3])";
let minute = r"[0-5]\d";
let second = r"([0-5]\d|60)";
let fraction = r"\.\d{1,9}";
let time = format!("{hour}:{minute}:{second}({fraction})?");
let offset = r"[+-]\d\d(:?\d\d)?";
let offset_or_zulu = format!("({offset}|[Zz])");

Regex::new(&format!("^{date}[ Tt]{time}( ?{offset_or_zulu})?$")).unwrap()
});

pub fn test_parse_date(data: &[u8]) {
static DATE_RE: LazyLock<Regex> = LazyLock::new(|| {
let year = r"(\d{4}|[+-]\d+)";
let month = r"(0[1-9]|1[0-2])";
let day_of_month = r"([0-2]\d|3[01])";
let date = format!("{year}-{month}-{day_of_month}");
let hour = r"([01]\d|2[0-3])";
let minute = r"[0-5]\d";
let second = r"([0-5]\d|60)";
let fraction = r"\.\d{1-9}";
let time = format!("{hour}:{minute}:{second}({fraction})?");
let offset = r"[+-]\d\d(:?\d\d)?";
let offset_or_zulu = format!("({offset}|[Zz])");

Regex::new(&format!("^{date}[ Tt]{time}( ?{offset_or_zulu})?$")).unwrap()
});
// input must be text
let Ok(s) = from_utf8(data) else {
return;
Expand Down

0 comments on commit 8c695da

Please sign in to comment.