changeset 16839:85883252217c

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.
author Bruno Haible <bruno@clisp.org>
date Wed, 09 May 2012 03:23:29 +0200
parents a43ad261663e
children e99c8c949ff7
files ChangeLog tests/test-sh-quote.c
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-08  Bruno Haible  <bruno@clisp.org>
+
+	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.
+
 2012-05-08  Akim Demaille  <akim@lrde.epita.fr>
 
 	warnings.m4: provide a means to specify the program to compile.
--- a/tests/test-sh-quote.c
+++ b/tests/test-sh-quote.c
@@ -43,6 +43,7 @@
   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 @@
     /* 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 @@
     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];