Skip to content

Commit

Permalink
Replace only the first two occurences of timestamp regex
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmayPatil105 committed Apr 16, 2024
1 parent 54c02bd commit aedd068
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}};
Expand Down
5 changes: 4 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit aedd068

Please sign in to comment.