use crate::brain::tools::bash::posix_single_quote;
#[test]
fn plain_path_is_wrapped_in_single_quotes() {
assert_eq!(posix_single_quote("/tmp/file"), "'/tmp/file'");
}
#[test]
fn empty_string_becomes_empty_quoted_string() {
assert_eq!(posix_single_quote(""), "''");
}
#[test]
fn spaces_are_preserved_inside_quotes() {
assert_eq!(
posix_single_quote("/tmp/with space/x"),
"'/tmp/with space/x'"
);
}
#[test]
fn dollar_signs_are_inert_inside_single_quotes() {
assert_eq!(posix_single_quote("/tmp/$HOME/x"), "'/tmp/$HOME/x'");
}
#[test]
fn backticks_are_inert_inside_single_quotes() {
assert_eq!(posix_single_quote("/tmp/`id`/x"), "'/tmp/`id`/x'");
}
#[test]
fn double_quotes_are_inert_inside_single_quotes() {
assert_eq!(posix_single_quote("/tmp/\"x\"/y"), "'/tmp/\"x\"/y'");
}
#[test]
fn embedded_single_quote_is_escaped() {
assert_eq!(posix_single_quote("a'b"), "'a'\\''b'");
}
#[test]
fn multiple_single_quotes_are_each_escaped() {
assert_eq!(posix_single_quote("'x'"), "''\\''x'\\'''");
}
#[test]
fn newline_inside_quotes_is_preserved_verbatim() {
assert_eq!(posix_single_quote("a\nb"), "'a\nb'");
}