Replace only the first two occurences of timestamp regex

This commit is contained in:
Tanmay Patil
2024-04-16 10:26:32 +05:30
parent 54c02bdf0b
commit aedd0684d1
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -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);
}};
+4 -1
View File
@@ -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]