diff options
author | Bruno Haible <bruno@clisp.org> | 2012-05-09 03:23:29 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2012-05-09 03:23:29 +0200 |
commit | e19862ceafbaaa82e8eb869e1c1ba45d0ecba515 (patch) | |
tree | 89348b9d4f2be58607d02c6e6fe8dd8e1594df6b /tests | |
parent | 2c19fe9c2316d113610aa895d5203a9252cb692d (diff) | |
download | gnulib-e19862ceafbaaa82e8eb869e1c1ba45d0ecba515.tar.gz |
sh-quote tests: Make tests stricter.
* tests/test-sh-quote.c (check_one): Check the return value of
shell_quote_copy.
(main): Check a string with a CR character. Check a string that
contains UCHAR_MAX.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-sh-quote.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/test-sh-quote.c b/tests/test-sh-quote.c index 8ca154121f..2b4657c26b 100644 --- a/tests/test-sh-quote.c +++ b/tests/test-sh-quote.c @@ -43,6 +43,7 @@ check_one (const char *input, const char *expected) memset (buf, '\0', output_len + 1); buf[output_len + 1] = '%'; bufend = shell_quote_copy (buf, input); + ASSERT (bufend == buf + output_len); ASSERT (memcmp (buf, output, output_len + 1) == 0); ASSERT (buf[output_len + 1] == '%'); @@ -68,6 +69,7 @@ main (void) /* Whitespace would be interpreted as argument separator by the shell. */ check_one ("foo\tbar", "'foo\tbar'"); check_one ("foo\nbar", "'foo\nbar'"); + check_one ("foo\rbar", "'foo\rbar'"); check_one ("foo bar", "'foo bar'"); /* '!' at the beginning of argv[0] would introduce a negated command. */ @@ -154,7 +156,7 @@ main (void) check_one ("foo'bar\"baz", "'foo'\\''bar\"baz'"); /* or "\"foo'bar\\\"baz\"" */ /* All other characters don't need quoting. */ - for (c = 1; c < UCHAR_MAX; c++) + for (c = 1; c <= UCHAR_MAX; c++) if (strchr ("\t\n\r !\"#$&'()*;<=>?^[\\]`{|}~", c) == NULL) { char s[5]; |