From 271abb6776da6ee822838f9749ac82e8e2a04b41 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 16 Oct 2022 20:23:35 +0200 Subject: [PATCH] Added escaping tests --- helix-core/src/shellwords.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/helix-core/src/shellwords.rs b/helix-core/src/shellwords.rs index b9dbaf1e6cff..6edf3cc7e00d 100644 --- a/helix-core/src/shellwords.rs +++ b/helix-core/src/shellwords.rs @@ -243,4 +243,18 @@ mod test { ]; assert_eq!(expected, result); } + + #[cfg(unix)] + fn test_escaping_unix() { + assert_eq!(escape("foobar"), Cow::Borrowed("foobar")); + assert_eq!(escape("foo bar"), Cow::Borrowed("foo\\ bar")); + assert_eq!(escape("foo\tbar"), Cow::Borrowed("foo\\\tbar")); + } + + #[test] + #[cfg(windows)] + fn test_escaping_windows() { + assert_eq!(escape("foobar"), Cow::Borrowed("foobar")); + assert_eq!(escape("foo bar"), Cow::Borrowed("\"foo bar\"")); + } }