Author: sebor
Date: Sun Mar 30 11:06:19 2008
New Revision: 642790
URL: http://svn.apache.org/viewvc?rev=642790&view=rev
Log:
2008-03-30 Martin Sebor <[EMAIL PROTECTED]>
* tests/self/0.braceexp.cpp (test): Used size_t instead
of the _RWSTD_SIZE_T macro.
(run_tests): Added tests for embedded whitespace.
(run_brace_expand_tests): Ditto.
(run_shell_expand_tests): Ditto.
Modified:
stdcxx/trunk/tests/self/0.braceexp.cpp
Modified: stdcxx/trunk/tests/self/0.braceexp.cpp
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/tests/self/0.braceexp.cpp?rev=642790&r1=642789&r2=642790&view=diff
==============================================================================
--- stdcxx/trunk/tests/self/0.braceexp.cpp (original)
+++ stdcxx/trunk/tests/self/0.braceexp.cpp Sun Mar 30 11:06:19 2008
@@ -1,6 +1,7 @@
/************************************************************************
*
- * 0.braceexp.cpp - tests exercising the rw_brace_expand() helper
+ * 0.braceexp.cpp - tests exercising the rw_brace_expand()
+ * and rw_shell_expand() helper functions
*
* $Id$
*
@@ -27,7 +28,7 @@
#include <rw_braceexp.h>
#include <environ.h> // for rw_putenv()
-#include <stdio.h> // for fprintf(), stderr
+#include <stdio.h> // for fprintf(), size_t, stderr
#include <stdlib.h> // for free()
#include <string.h> // for strcmp()
@@ -35,9 +36,9 @@
static int nerrors;
static void
-test (int line, const char* brace_expr, _RWSTD_SIZE_T n, const char* expect,
+test (int line, const char* brace_expr, size_t n, const char* expect,
const char* fname,
- char* (fn)(const char*, _RWSTD_SIZE_T, char*, _RWSTD_SIZE_T, char))
+ char* (fn)(const char*, size_t, char*, size_t, char))
{
char buf [128];
@@ -69,7 +70,7 @@
static void
run_tests (const char* fname,
- char* (fn)(const char*, _RWSTD_SIZE_T, char*, _RWSTD_SIZE_T, char))
+ char* (fn)(const char*, size_t, char*, size_t, char))
{
#undef TEST
#define TEST(s,e) test (__LINE__, s, strlen (s), e, fname, fn)
@@ -77,6 +78,13 @@
// run our tests
TEST ("", "");
+ // test plain and escaped whitespace
+ TEST ("\\ ", " ");
+ TEST ("\\ \\ ", " ");
+ TEST ("\\ \\\t\\ ", " \t ");
+ TEST ("a\\ b", "a b");
+ TEST ("a b", "a b");
+
TEST ("a", "a");
TEST ("a\\b", "ab");
@@ -166,6 +174,10 @@
TEST ("{abc,{,d,e,f,}}{x,y}", "abcx abcy x y dx dy ex ey fx fy x y");
TEST ("{abc,{,d\\,e\\,f,}}", "abc d,e,f");
+ // list expansion with embedded whitespace
+ TEST ("a{b\\ ,c}", "ab ac");
+ TEST ("a{b\\ \\ ,c\\ }", "ab ac ");
+
// series of list and sequence expansions
TEST ("A{0..3}", "A0 A1 A2 A3");
TEST ("A{0..2}{6..7}", "A06 A07 A16 A17 A26 A27");
@@ -274,6 +286,20 @@
TEST ("a {1,2} b", "a 1 b a 2 b");
TEST ("a\t\t{1,2}\t\tb", "a\t\t1\t\tb a\t\t2\t\tb");
+ // test whitespace
+ TEST (" ", " ");
+ TEST (" ", " ");
+ TEST (" \t", " \t");
+ TEST ("a b", "a b");
+ TEST (" a b ", " a b ");
+ TEST (" a{b,c}", " ab ac");
+ TEST ("a {b,c}", "a b a c");
+ TEST ("a{ b,c}", "a b ac");
+ TEST ("a{b ,c}", "ab ac");
+ TEST ("a{b, c}", "ab a c");
+ TEST ("a{b,c }", "ab ac ");
+ TEST ("a{b,c} ", "ab ac ");
+
TEST ("{ }", " ");
TEST ("{{ }}", " ");
TEST ("{{ }", 0); // brace mismatch
@@ -290,6 +316,20 @@
// rw_shell_expand does whitespace collapse
TEST ("a {1,2} b", "a 1 2 b");
TEST ("a\t\t{1,2}\t\tb", "a 1 2 b");
+
+ // test whitespace
+ TEST (" ", "");
+ TEST (" ", "");
+ TEST (" \t", "");
+ TEST ("a b", "a b");
+ TEST (" a b ", "a b");
+ TEST (" a{b,c}", "ab ac");
+ TEST ("a {b,c}", "a b c");
+ TEST ("a{ b,c}", 0);
+ TEST ("a{b ,c}", 0);
+ TEST ("a{b, c}", 0);
+ TEST ("a{b,c }", 0);
+ TEST ("a{b,c} ", "ab ac");
TEST ("{ }", 0); // brace mismatch
TEST ("{{ }}", 0); // brace mismatch