Skip to content

Commit

Permalink
added test, added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixhead committed Jul 10, 2024
1 parent f9141fb commit 81fae4c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/uucore/src/lib/features/quoting_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ impl EscapedChar {
}
}

/// Create a new c shell styled `EscapedChar`
///
/// # Arguments
/// * `c` - The character to create the `EscapedChar` for.
/// * `quotes` - The type of quotes to use for escaping.
/// * `force_escape` - A list of extra characters that should be treated as
/// escaped characters for a specific context.
fn new_c(c: char, quotes: Quotes, force_escape: &[char]) -> Self {
use EscapeState::*;
let init_state = match c {
Expand Down Expand Up @@ -853,6 +860,34 @@ mod tests {
],
&[':'],
);
check_names(
"one:two:three",
&[
("one:two:three", "literal"),
("'one:two:three'", "shell"),
("'one:two:three'", "shell-always"),
("'one:two:three'", "shell-escape"),
("'one:two:three'", "shell-escape-always"),
("\"one\\:two\\:three\"", "c"),
("one\\:two\\:three", "escape"),
],
&[':'],
);
// note: this is just to check multiple escaped chars are working
// properly no util has this behavior.
check_names(
"one:two@three",
&[
("one:two@three", "literal"),
("'one:two@three'", "shell"),
("'one:two@three'", "shell-always"),
("'one:two@three'", "shell-escape"),
("'one:two@three'", "shell-escape-always"),
("\"one\\:two\\@three\"", "c"),
("one\\:two\\@three", "escape"),
],
&[':', '@'],
);
}

#[test]
Expand Down

0 comments on commit 81fae4c

Please sign in to comment.