From aedd0684d199a5b9e0a57e48b7e9a42f6f0ea7ad Mon Sep 17 00:00:00 2001 From: Tanmay Patil Date: Tue, 16 Apr 2024 10:26:32 +0530 Subject: [PATCH] Replace only the first two occurences of timestamp regex --- src/macros.rs | 2 +- src/utils.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 7a3c693..1f1a994 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -18,7 +18,7 @@ macro_rules! assert_diff_eq { let diff = str::from_utf8(&$actual).unwrap(); let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [+-]\d{4}").unwrap(); - let actual = re.replace_all(diff, "TIMESTAMP"); + let actual = re.replacen(diff, 2, "TIMESTAMP"); assert_eq!(actual, $expected); }}; diff --git a/src/utils.rs b/src/utils.rs index 7dc38e4..561f2b9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -154,7 +154,10 @@ mod tests { let current: String = current.format("%Y-%m-%d %H:%M:%S%.9f %z").to_string(); // verify - assert_eq!(current, get_modification_time(&temp.path().to_string_lossy())); + assert_eq!( + current, + get_modification_time(&temp.path().to_string_lossy()) + ); } #[test]