1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #1354 from ccbrown/rewrite-echo

echo: rewrite for readability and tests
This commit is contained in:
Alex Lyon 2019-04-05 18:39:18 -07:00 committed by GitHub
commit 100f6df2bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 92 additions and 103 deletions

View file

@ -48,6 +48,21 @@ fn test_escape_hex() {
new_ucmd!().args(&["-e", "\\x41"]).succeeds().stdout_only("A");
}
#[test]
fn test_escape_short_hex() {
new_ucmd!().args(&["-e", "foo\\xa bar"]).succeeds().stdout_only("foo\n bar");
}
#[test]
fn test_escape_no_hex() {
new_ucmd!().args(&["-e", "foo\\x bar"]).succeeds().stdout_only("foo\\x bar");
}
#[test]
fn test_escape_one_slash() {
new_ucmd!().args(&["-e", "foo\\ bar"]).succeeds().stdout_only("foo\\ bar");
}
#[test]
fn test_escape_newline() {
new_ucmd!().args(&["-e", "\\na"]).succeeds().stdout_only("\na");
@ -55,7 +70,7 @@ fn test_escape_newline() {
#[test]
fn test_escape_no_further_output() {
new_ucmd!().args(&["-e", "a\\cb"]).succeeds().stdout_only("a\n");
new_ucmd!().args(&["-e", "a\\cb", "c"]).succeeds().stdout_only("a\n");
}
#[test]
@ -63,6 +78,16 @@ fn test_escape_octal() {
new_ucmd!().args(&["-e", "\\0100"]).succeeds().stdout_only("@");
}
#[test]
fn test_escape_short_octal() {
new_ucmd!().args(&["-e", "foo\\040bar"]).succeeds().stdout_only("foo bar");
}
#[test]
fn test_escape_no_octal() {
new_ucmd!().args(&["-e", "foo\\0 bar"]).succeeds().stdout_only("foo\\0 bar");
}
#[test]
fn test_escape_tab() {
new_ucmd!().args(&["-e", "\\t"]).succeeds().stdout_only("\t\n");