I’m stuck on Stage #GU3
My code passes GU3, and regression for LE5, but fails on YT5. I’ve reworked the way I parse arguments, so it might be my fault, but I’m curious about logs:
remote: [tester::#YT5] Writing file "/tmp/quz/f\n55" with content "grape pineapple."
remote: [tester::#YT5] Writing file "/tmp/quz/f\69" with content "strawberry orange."
remote: [tester::#YT5] Writing file "/tmp/quz/f'\'19" with content "orange strawberry."
remote: [your-program] $ cat "/tmp/quz/f\n55" "/tmp/quz/f\69" "/tmp/quz/f'\'19"
remote: [your-program] /usr/bin/cat: '/tmp/quz/f'$'\n''55': No such file or directory
remote: [tester::#YT5] Output does not match expected value.
remote: [tester::#YT5] Expected: "grape pineapple.strawberry orange.orange strawberry."
remote: [tester::#YT5] Received: "/usr/bin/cat: '/tmp/quz/f'$'\n''55': No such file or directory"
remote: [your-program] strawberry orange.orange strawberry.
remote: [your-program] cat execution error: Command failed with exit code 1
when I try to this input (replace cat
with echo
), I get the next output, and it seems rights
$ echo "/tmp/quz/f\n55" "/tmp/quz/f\69" "/tmp/quz/f'\'19"
/tmp/quz/f
55 /tmp/quz/f\69 /tmp/quz/f'\'19
$
so I need a little explanation about what is real input for this test or might u have issue in tester
if we speak about Stage #YT5 (Quoting - Backslash outside quotes) then it works as expected or not?:
$ echo /tmp/quz/f\n55 /tmp/quz/f\69 /tmp/quz/f'\'19
/tmp/quz/fn55 /tmp/quz/f69 /tmp/quz/f'19
$
here my tests:
#[cfg(test)]
mod tests {
#[test]
fn test_parse_basic() {
assert_eq!(super::parse(""), Vec::<String>::new());
assert_eq!(super::parse("arg1 arg2 arg3"), vec!["arg1", "arg2", "arg3"]);
assert_eq!(super::parse(" arg1 arg2 "), vec!["arg1", "arg2"]);
}
#[test]
fn test_parse_with_single_quotes() {
assert_eq!(
super::parse("'only one quoted arg'"),
vec!["only one quoted arg"]
);
assert_eq!(
super::parse("'/tmp/file name' '/tmp/file name with spaces'"),
vec!["/tmp/file name", "/tmp/file name with spaces"]
);
assert_eq!(
super::parse("'/tmp/file name' yahoo '/tmp/file name with spaces'"),
vec!["/tmp/file name", "yahoo", "/tmp/file name with spaces"]
);
}
#[test]
fn test_parse_with_double_quotes() {
assert_eq!(
super::parse(r#""only one quoted arg""#),
vec!["only one quoted arg"]
);
assert_eq!(
super::parse(r#""/tmp/file name" "/tmp/file name with spaces""#),
vec!["/tmp/file name", "/tmp/file name with spaces"]
);
assert_eq!(
super::parse(r#""/tmp/file name" yahoo "/tmp/file name with spaces""#),
vec!["/tmp/file name", "yahoo", "/tmp/file name with spaces"]
);
assert_eq!(
super::parse(r#""/tmp/qux/"f 96""#),
vec!["/tmp/qux/f", "96"]
)
}
#[test]
fn test_parse_with_mixed_quotes_1() {
assert_eq!(
super::parse(r#""'only one quoted arg'""#),
vec!["'only one quoted arg'"]
);
assert_eq!(
super::parse(r#"'"only one quoted arg"'"#),
vec!["\"only one quoted arg\""]
);
assert_eq!(
super::parse(r#"'"/tmp/file name"' "'/tmp/file name with spaces'""#),
vec![r#""/tmp/file name""#, "'/tmp/file name with spaces'"]
);
}
#[test]
fn test_parse_with_mixed_quotes_2() {
assert_eq!(
super::parse(r#""'only" one "quoted arg'""#),
vec!["'only", "one", "quoted arg'"]
);
}
#[test]
fn test_parse_with_backslashes_outside_quotes() {
assert_eq!(
super::parse(r#"world\ \ \ \ \ \ script"#),
vec!["world script"]
);
assert_eq!(super::parse(r#"before\nafter"#), vec!["beforenafter"]);
assert_eq!(
super::parse(r#"\'\"script world\"\'"#),
vec![r#"'"script"#, r#"world"'"#]
);
}
#[test]
fn test_parse_with_backslashes_within_single_quotes() {
assert_eq!(
super::parse("'shell\\\\\\nscript'"),
vec!["shell\\\\\\nscript"]
);
assert_eq!(
super::parse("'example\\\"testhello\\\"shell'"),
vec!["example\\\"testhello\\\"shell"]
);
}
#[test]
fn test_parse_with_backslashes_within_double_quotes() {
assert_eq!(
super::parse(r#""hello\"insidequotes"script\""#),
vec![r#"hello"insidequotesscript""#]
);
assert_eq!(super::parse(r#""/tmp/bar/f\n99""#), vec!["/tmp/bar/f\n99"]);
}
}