From b3a1dee4c682338bb6275d83b088b5583adf2821 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bielewicz Date: Wed, 13 Oct 2021 13:45:55 +0200 Subject: [PATCH] #532 Improve date format validation to include all supported cases | fmt applied --- src/app.rs | 2 +- tests/integration.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 9850b69..86bdf47 100644 --- a/src/app.rs +++ b/src/app.rs @@ -318,7 +318,7 @@ pub fn validate_time_format(formatter: &str) -> Result<(), String> { | Some('W') | Some('w') | Some('Y') | Some('y') => (), Some(c) => return Err(format!("invalid format specifier: %{}{}", n, c)), None => return Err("missing format specifier".to_owned()), - } + }, Some('A') | Some('a') | Some('B') | Some('b') | Some('C') | Some('c') | Some('D') | Some('d') | Some('e') | Some('F') | Some('f') | Some('G') | Some('g') | Some('H') | Some('h') | Some('I') | Some('j') | Some('k') diff --git a/tests/integration.rs b/tests/integration.rs index b3f8073..574768a 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -606,7 +606,11 @@ fn test_date_custom_format_supports_nanos_with_length() { .arg("--ignore-config") .arg(dir.path()) .assert() - .stdout(predicate::str::is_match("testDateFormat\\.[0-9]{3}").unwrap().count(2)); + .stdout( + predicate::str::is_match("testDateFormat\\.[0-9]{3}") + .unwrap() + .count(2), + ); } #[test] @@ -622,5 +626,9 @@ fn test_date_custom_format_supports_padding() { .arg("--ignore-config") .arg(dir.path()) .assert() - .stdout(predicate::str::is_match("testDateFormat[\\s0-9]{2}").unwrap().count(2)); + .stdout( + predicate::str::is_match("testDateFormat[\\s0-9]{2}") + .unwrap() + .count(2), + ); }