>From 9fe86b15e4de4ea6d28486fff74bd772b8325e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 16 Oct 2016 22:51:30 +0100 Subject: [PATCH] quotearg: fix stale tests * tests/test-quotearg.c [locale_results]: Add the missing str7 entries to the expected results. tests/test-system-quote-main.c (check_one): Don't enforce that we don't write beyond the returned length, since that's no longer the case if we switch to a more concise quoting style. * tests/test-sh-quote.c (check_one): Likewise. (main): Adjust for the new more concise quoting style. Reported by Bruno Haible. --- tests/test-quotearg.c | 12 ++++++------ tests/test-sh-quote.c | 4 +--- tests/test-system-quote-main.c | 2 -- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/test-quotearg.c b/tests/test-quotearg.c index e43573d..d9a636b 100644 --- a/tests/test-quotearg.c +++ b/tests/test-quotearg.c @@ -37,24 +37,24 @@ static struct result_groups locale_results[] = { /* locale_quoting_style */ { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ}, + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ}, { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } }, + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } }, /* clocale_quoting_style */ { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ }, { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ, LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ, - LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } } + LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } } }; #endif /* ENABLE_NLS */ diff --git a/tests/test-sh-quote.c b/tests/test-sh-quote.c index a2633ba..091da34 100644 --- a/tests/test-sh-quote.c +++ b/tests/test-sh-quote.c @@ -41,11 +41,9 @@ check_one (const char *input, const char *expected) ASSERT (output_len <= sizeof (buf) - 2); 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] == '%'); ASSERT (strcmp (output, expected) == 0); @@ -91,7 +89,7 @@ main (void) check_one ("&", "'&'"); /* "'" would be interpreted as the start of a string. */ - check_one ("'foo'bar", "''\\''foo'\\''bar'"); /* or "\"'foo'bar\"" */ + check_one ("'foo'bar", "\"'foo'bar\""); /* '(' at the beginning of argv[0] would introduce a subshell command. */ check_one ("(", "'('"); diff --git a/tests/test-system-quote-main.c b/tests/test-system-quote-main.c index 8eb6a17..40d7ec6 100644 --- a/tests/test-system-quote-main.c +++ b/tests/test-system-quote-main.c @@ -58,11 +58,9 @@ check_one (enum system_command_interpreter interpreter, const char *prog, ASSERT (output_len <= sizeof (buf) - 2); memset (buf, '\0', output_len + 1); - buf[output_len + 1] = '%'; bufend = system_quote_copy (buf, interpreter, input); ASSERT (bufend == buf + output_len); ASSERT (memcmp (buf, output, output_len + 1) == 0); - ASSERT (buf[output_len + 1] == '%'); /* Store INPUT in EXPECTED_DATA_FILE, for verification by the child process. */ -- 2.5.5