aboutsummaryrefslogtreecommitdiff
path: root/tests/wsbatch.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-15 11:51:50 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-15 11:51:50 +0300
commitab6db76c77ea6480b307e43107bf570eb90d95eb (patch)
tree6a91c191411af18825cb50d012c2e38c0efebdc2 /tests/wsbatch.c
parent65ce987f7408a46233d9b0404c2396e4370a12ea (diff)
downloadwydawca-ab6db76c77ea6480b307e43107bf570eb90d95eb.tar.gz
wydawca-ab6db76c77ea6480b307e43107bf570eb90d95eb.tar.bz2
Switch to grecs eb66a000
Diffstat (limited to 'tests/wsbatch.c')
-rw-r--r--tests/wsbatch.c148
1 files changed, 0 insertions, 148 deletions
diff --git a/tests/wsbatch.c b/tests/wsbatch.c
deleted file mode 100644
index aeb8920..0000000
--- a/tests/wsbatch.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* wordsplit - a word splitter
- Copyright (C) 2009, 2010, 2011, 2017, 2019 Sergey Poznyakoff
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wordsplit.h>
-
-size_t errors = 0;
-size_t count = 0;
-
-void
-runtest (const char **input, struct wordsplit *wsinit, int flags)
-{
- int i;
-
- for (i = 0; input[i]; i++)
- {
- size_t j;
- const char *text = input[i];
- struct wordsplit ws = *wsinit;
- i++;
- for (j = 0; input[i+j]; j++);
-
- count++;
- if (wordsplit (text, &ws, flags))
- {
- fprintf (stderr, "E: %s: parse failed\n", text);
- errors++;
- }
- else if (ws.ws_wordc != j)
- {
- fprintf (stderr, "E: %s: wrong number of fields (%lu/%lu)\n",
- text,
- (unsigned long) ws.ws_wordc, (unsigned long) j);
- errors++;
- }
- else
- {
- size_t k;
-
- for (k = 0; k < ws.ws_wordc; k++)
- if (strcmp (ws.ws_wordv[k], input[i + k]))
- {
- fprintf (stderr, "E: %s: word %lu mismatch: %s/%s\n",
- text, (unsigned long) k,
- ws.ws_wordv[k], input[i + k]);
- errors++;
- break;
- }
- }
- i += j;
- }
-}
-
-const char *testv[] = {
- "a bcd", "a", "bcd", NULL,
- "a bcd \tef 13 456", "a", "bcd", "ef", "13", "456", NULL,
- "a \"s p a c e\" b", "a", "s p a c e", "b", NULL,
- "a \"s p \\\" a \\\\ c e\" b", "a", "s p \" a \\ c e", "b", NULL,
- "a\\tb \"a\\tb\" 'a\\tb'", "a\tb", "a\tb", "a\\tb", NULL,
- "\\\\\\a\\b\\f\\n\\r\\t\\v", "\\\a\b\f\n\r\t\v", NULL,
- "a w13ord #comment", "a", "w13ord", "#comment", NULL,
- NULL
-};
-
-const char *testcmt[] = {
- "a bcd", "a", "bcd", NULL,
- "a w13ord #comment", "a", "w13ord", NULL,
- "#comment", NULL,
- NULL
-};
-
-const char *testcol[] = {
- "gray:x:1000:100:Sergey Poznyakoff:/home/gray:/bin/bash",
- "gray",
- "x",
- "1000",
- "100",
- "Sergey Poznyakoff",
- "/home/gray",
- "/bin/bash",
- NULL,
-
- "mail::8:12:\"mail pseudo user\":/:\n",
- "mail",
- "",
- "8",
- "12",
- "\"mail pseudo user\"",
- "/",
- "",
- NULL,
-
- NULL
-};
-
-const char *testcol2[] = {
- "set x=foo,y=bar",
- "set", " ",
- "x", "=",
- "foo", ",",
- "y", "=", "bar",
- NULL,
-
- NULL
-};
-
-int
-main ()
-{
- struct wordsplit ws;
-
- runtest (testv, &ws, WRDSF_DEFFLAGS);
-
- ws.ws_comment = "#";
- runtest (testcmt, &ws, WRDSF_DEFFLAGS|WRDSF_COMMENT);
-
- ws.ws_delim = ":\n";
- runtest (testcol, &ws, WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_DELIM);
-
- ws.ws_delim = " =,";
- runtest (testcol2, &ws,
- WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_DELIM | WRDSF_RETURN_DELIMS);
-
- printf ("Tests: %lu\n", (unsigned long) count);
- if (errors)
- printf ("Failures: %lu\n", (unsigned long) errors);
- return errors ? 1 : 0;
-}
-

Return to:

Send suggestions and report system problems to the System administrator.