From 3323b3079a0106db6ce9b7f1a08dd093f5fdf56b Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sun, 14 Feb 2021 18:10:50 +0000 Subject: [PATCH] Add test for extended parsing --- src/local/import.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/local/import.rs b/src/local/import.rs index ddccc75..9bf79c7 100644 --- a/src/local/import.rs +++ b/src/local/import.rs @@ -93,3 +93,29 @@ impl Iterator for Zsh { } } } + +#[cfg(test)] +mod test { + use super::parse_extended; + + #[test] + fn test_parse_extended_simple() { + let parsed = parse_extended(": 1613322469:0;cargo install atuin"); + + assert_eq!(parsed.command, "cargo install atuin"); + assert_eq!(parsed.duration, 0); + assert_eq!(parsed.timestamp, 1_613_322_469_000_000_000); + + let parsed = parse_extended(": 1613322469:10;cargo install atuin;cargo update"); + + assert_eq!(parsed.command, "cargo install atuin;cargo update"); + assert_eq!(parsed.duration, 10_000_000_000); + assert_eq!(parsed.timestamp, 1_613_322_469_000_000_000); + + let parsed = parse_extended(": 1613322469:10;cargo :b̷i̶t̴r̵o̴t̴ ̵i̷s̴ ̷r̶e̵a̸l̷"); + + assert_eq!(parsed.command, "cargo :b̷i̶t̴r̵o̴t̴ ̵i̷s̴ ̷r̶e̵a̸l̷"); + assert_eq!(parsed.duration, 10_000_000_000); + assert_eq!(parsed.timestamp, 1_613_322_469_000_000_000); + } +}