diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/echo.test | 7 | ||||
-rwxr-xr-x | tests/printf.test | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/echo.test b/tests/echo.test index 248454e7..80774e66 100755 --- a/tests/echo.test +++ b/tests/echo.test @@ -27,11 +27,18 @@ testcmd "-nex hello" "-nex hello" "-nex hello\n" "" "" testcmd "-e octal values" \ "-ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \ "S4 0 0 XYZ ?\n" "" "" +testcmd "-e invalid oct" "-ne 'one\\079two'" "one\a9two" "" "" +testcmd "-e \\0040" "-ne '\0040'" " " "" "" # Hexadecimal value tests testcmd "-e hexadecimal values" \ "-ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\ "S4 0 XYZ ?\n" "" "" +testcmd "-e invalid hex 1" "-e 'one\xvdtwo'" "one\\xvdtwo\n" "" "" +testcmd "-e invalid hex 2" "-e 'one\xavtwo'" "one\nvtwo\n" "" "" + +# GNU extension for ESC +testcmd "-e \e" "-ne '\\e' | xxd -p" "1b\n" "" "" testcmd "-e \p" "-e '\\p'" "\\p\n" "" "" diff --git a/tests/printf.test b/tests/printf.test index eb0e0bec..a341615e 100755 --- a/tests/printf.test +++ b/tests/printf.test @@ -68,3 +68,19 @@ testing "printf posix inconsistency" "$PRINTF '\\0066-%b' '\\0066'" "\x066-6" \ testing "printf \x" "$PRINTF 'A\x1b\x2B\x3Q\xa' | od -An -tx1" \ " 41 1b 2b 03 51 0a\n" "" "" + +testing "printf \c" "$PRINTF 'one\ctwo'" "one" "" "" + +# An extra leading 0 is fine for %b, but not as a direct escape, for some +# reason... +testing "printf octal %b" "$PRINTF '\0007%b' '\0007' | xxd -p" "003707\n" "" "" + +# Unlike echo, printf errors out on bad hex. +testcmd "invalid hex 1" "'one\xvdtwo' 2>/dev/null || echo err" "oneerr\n" "" "" +testcmd "invalid hex 2" "'one\xavtwo'" "one\nvtwo" "" "" +# But bad octal is shown as text. +testcmd "invalid oct" "'one\079two'" "one\a9two" "" "" + +# extension for ESC +testcmd "%b \e" "'%b' '\\e' | xxd -p" "1b\n" "" "" +testcmd "\e" "'\\e' | xxd -p" "1b\n" "" "" |