mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 14:34:05 +00:00
Make escape_test an ordinary function
This did not need to be a macro.
This commit is contained in:
parent
7b0f9fd5f8
commit
a99fa201b6
1 changed files with 23 additions and 25 deletions
|
@ -97,8 +97,7 @@ fn test_escape_var() {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! escape_test {
|
||||
($escape_style:expr, $unescape_style:expr) => {
|
||||
fn escape_test(escape_style: EscapeStringStyle, unescape_style: UnescapeStringStyle) {
|
||||
setlocale();
|
||||
let seed: u128 = 92348567983274852905629743984572;
|
||||
let mut rng = Pcg64Mcg::new(seed);
|
||||
|
@ -113,29 +112,28 @@ macro_rules! escape_test {
|
|||
.push(char::from_u32((rng.next_u32() % ESCAPE_TEST_CHAR as u32) + 1).unwrap());
|
||||
}
|
||||
|
||||
escaped_string = escape_string(&random_string, $escape_style);
|
||||
let Some(unescaped_string) = unescape_string(&escaped_string, $unescape_style) else {
|
||||
escaped_string = escape_string(&random_string, escape_style);
|
||||
let Some(unescaped_string) = unescape_string(&escaped_string, unescape_style) else {
|
||||
let slice = escaped_string.as_char_slice();
|
||||
panic!("Failed to unescape string {slice:?}");
|
||||
};
|
||||
assert_eq!(random_string, unescaped_string, "Escaped and then unescaped string {random_string:?}, but got back a different string {unescaped_string:?}. The intermediate escape looked like {escaped_string:?}.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escape_random_script() {
|
||||
escape_test!(EscapeStringStyle::default(), UnescapeStringStyle::default());
|
||||
escape_test(EscapeStringStyle::default(), UnescapeStringStyle::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escape_random_var() {
|
||||
escape_test!(EscapeStringStyle::Var, UnescapeStringStyle::Var);
|
||||
escape_test(EscapeStringStyle::Var, UnescapeStringStyle::Var);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escape_random_url() {
|
||||
escape_test!(EscapeStringStyle::Url, UnescapeStringStyle::Url);
|
||||
escape_test(EscapeStringStyle::Url, UnescapeStringStyle::Url);
|
||||
}
|
||||
|
||||
#[widestrs]
|
||||
|
|
Loading…
Reference in a new issue