aboutsummaryrefslogtreecommitdiff
path: root/tests/echo.test
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-08-17 19:53:56 -0700
committerRob Landley <rob@landley.net>2019-08-19 11:23:41 -0500
commit81518f643d4d53b035b2cefbce25f06bd3cb5079 (patch)
tree9420219c83f68c0345b770a31d7958dc1eb6295a /tests/echo.test
parentaa88ba047fa4210c03c3ad1168f84261167c3644 (diff)
downloadtoybox-81518f643d4d53b035b2cefbce25f06bd3cb5079.tar.gz
echo/printf: expand test cases, fix \x corner cases.
The behavior with "\xAV" (where the second hex digit is invalid) is different from the behavior with "\xVA", and echo and printf differ from each other.
Diffstat (limited to 'tests/echo.test')
-rwxr-xr-xtests/echo.test7
1 files changed, 7 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" "" ""