stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r417904 [1/5] - in /incubator/stdcxx/trunk/tests: self/ src/ strings/
Date Wed, 28 Jun 2006 23:47:11 GMT
Author: sebor
Date: Wed Jun 28 16:47:10 2006
New Revision: 417904

URL: http://svn.apache.org/viewvc?rev=417904&view=rev
Log:
2006-06-28  Martin Sebor  <sebor@roguewave.com>

	* src/char.cpp (_rw_get_char): New helper to parse <char>@<count>
	directives and Unicode <Unnn...> sequences denoting UCS characters.
	(_rw_expand): Called _rw_get_char.
	(rw_match): Called _rw_get_char, optimized and simplified.
	* test/0.char.cpp (test_rw_match): Added test cases and exercised
	the handling of <Unnn...> sequences.
	* 21.string.replace.cpp: Made use of the <Unnnn> directive and
	replaced NUL characters embedded in hardcoded string literals with
	the <U0> Unicode sequence (denoting NUL).

2006-06-28  Anton Pevtsov   <antonp@moscow.vdiweb.com>

	* 21.string.access.cpp: Made use of the <Unnnn> directive and
	replaced NUL characters embedded in hardcoded string literals with
	the <U0> Unicode sequence (denoting NUL).
	* 21.string.access.cpp: Same.
	* 21.string.append.cpp: Same.
	* 21.string.assign.cpp: Same.
	* 21.string.capacity.cpp: Same.
	* 21.string.cons.cpp: Same.
	* 21.string.copy.cpp: Same.
	* 21.string.erase.cpp: Same.
	* 21.string.insert.cpp: Same.
	* 21.string.iterators.cpp: Same.
	* 21.string.operators.cpp: Same.
	* 21.string.plus.cpp: Same.
	* 21.string.plus_equal.cpp: Same.
	* 21.string.substr.cpp: Same.
	* 21.string.swap.cpp: Same.

Modified:
    incubator/stdcxx/trunk/tests/self/0.char.cpp
    incubator/stdcxx/trunk/tests/src/char.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.access.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.append.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.capacity.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.cons.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.copy.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.erase.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.iterators.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.op.plus.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.operators.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.substr.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.swap.cpp

Modified: incubator/stdcxx/trunk/tests/self/0.char.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/self/0.char.cpp?rev=417904&r1=417903&r2=417904&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.char.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.char.cpp Wed Jun 28 16:47:10 2006
@@ -732,33 +732,6 @@
 
 /***********************************************************************/
 
-static size_t
-length (const char *s)
-{
-    return s ? strlen (s) : 0;
-}
-
-
-static size_t
-length (const wchar_t *ws)
-{
-    size_t len = 0;
-    if (ws)
-        for (len = 0; ws [len]; ++len);
-    return len;
-}
-
-
-static size_t
-length (const UserChar *us)
-{
-    size_t len = 0;
-    if (us)
-        for (len = 0; us [len].f || us [len].c; ++len);
-    return len;
-}
-
-
 static const UserChar*
 make_user_string (const char *s, size_t len)
 {
@@ -786,48 +759,155 @@
     //////////////////////////////////////////////////////////////////
     rw_info (0, 0, 0, "rw_match(char*, const char*, size_t)");
 
-    const size_t size_max = _RWSTD_SIZE_MAX;
     size_t result;
 
-#define LEN(T, s, len) \
-  int (size_max == size_t (len) ? length ((const T*)s) : size_t (len))
-
 #undef TEST
 #define TEST(s1, s2, len, expect)                                       \
   result = rw_match ((const char*)s1, (const char*)s2, size_t (len));   \
   rw_assert (expect == result,                                          \
              0, __LINE__,                                               \
              "rw_match(%{#*s}, %{#*s}, %zu) == %zu, got %zu",           \
-             LEN (char, s1, len), s1, LEN (char, s2, len),              \
-             s2, len, expect, result)
+             int (sizeof s1 - 1), s1, int (sizeof s2 - 1), s2, len,     \
+             expect, result)
 
     TEST (0,      0,        -1, 0);
     TEST ("",     0,        -1, 0);
     TEST (0,      "",       -1, 0);
-    TEST ("",     "",       -1, 0);
+    TEST ("",     "",       -1, 1);
 
-    // when invoked with NULL as the first string returns
-    // the length of the second string (if non-NULL)
+    // same as above but using the <char>@<count> directive
+    TEST ("a@0",  "",       -1, 1);
+    TEST ("",     "b@0",    -1, 1);
+    TEST ("a@0",  "b@0",    -1, 1);
+
+    // when invoked with NULL as the first argument returns
+    // the length of the second string with all directives
+    // expanded
     TEST (0,      "a",      -1, 1);
     TEST (0,      "ab",     -1, 2);
     TEST (0,      "abc",    -1, 3);
+    TEST (0,      "a@0",    -1, 0);
+    TEST (0,      "a@1",    -1, 1);
+    TEST (0,      "a@2",    -1, 2);
+    TEST (0,      "a@2b@0", -1, 2);
+    TEST (0,      "a@2b@1", -1, 3);
+    TEST (0,      "a@2b@2", -1, 4);
 
     // same as above but with the arguments reversed
-    TEST ("a",    0,        -1, 1);
-    TEST ("ab",   0,        -1, 2);
-    TEST ("abc",  0,        -1, 3);
+    TEST ("a",      0,      -1, 1);
+    TEST ("ab",     0,      -1, 2);
+    TEST ("abc",    0,      -1, 3);
+    TEST ("a@0",    0,      -1, 0);
+    TEST ("a@1",    0,      -1, 1);
+    TEST ("a@2",    0,      -1, 2);
+    TEST ("a@2b@0", 0,      -1, 2);
+    TEST ("a@2b@1", 0,      -1, 3);
+    TEST ("a@2b@2", 0,      -1, 4);
 
     TEST ("",     "a",      -1, 0);
     TEST ("a",    "",       -1, 0);
-    TEST ("a",    "a",      -1, 1);
+    TEST ("a",    "a",      -1, 2);
+
+    // same as above but using the <char>@<count> directive
+    TEST ("",     "a@1",    -1, 0);
+    TEST ("a@1",  "",       -1, 0);
+    TEST ("a",    "a@1",    -1, 2);
+    TEST ("a@1",  "a",      -1, 2);
+    TEST ("a@1",  "a@1",    -1, 2);
+
+    TEST ("\0ab",       "\0ac",   2, 2);
+    TEST ("\0@0ab",     "ab",     2, 2);
+    TEST ("\0@0a\0@0b", "ab",     2, 2);
+    TEST ("\0@1ab",     "\0@1ac", 2, 2);
+    TEST ("\0@1ab",     "\0@1ac", 2, 2);
 
-    TEST ("a\0bc", "a\0bd", -1, 1);
+    TEST ("a\0bc", "a\0bd", -1, 2);
     TEST ("a\0bc", "a\0bd",  0, 0);
     TEST ("a\0bc", "a\0bd",  1, 1);
     TEST ("a\0bc", "a\0bd",  2, 2);
     TEST ("a\0bc", "a\0bd",  3, 3);
     TEST ("a\0bc", "a\0bd",  4, 3);
 
+    TEST ("aaaaa",    "a@5",  -1, 6);
+    TEST ("aaaaaa@0", "a@5",  -1, 6);
+    TEST ("aaaaa@1",  "a@5",  -1, 6);
+    TEST ("aaaa@2",   "a@5",  -1, 6);
+    TEST ("aaa@3",    "a@5",  -1, 6);
+    TEST ("aa@4",     "a@5",  -1, 6);
+    TEST ("a@5",      "a@5",  -1, 6);
+    TEST ("a@4a",     "a@5",  -1, 6);
+    TEST ("a@3aa",    "a@5",  -1, 6);
+    TEST ("a@2aaa",   "a@5",  -1, 6);
+    TEST ("a@1aaaa",  "a@5",  -1, 6);
+    TEST ("a@0aaaaa", "a@5",  -1, 6);
+
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0", -1, 7);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  0, 0);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  1, 1);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  2, 2);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  3, 3);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  4, 4);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  5, 5);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  6, 6);
+    TEST ("a@0a@1a@2a@3", "a@3a@2a@1a@0",  7, 7);
+
+    TEST ("a@0\0a@1a@2\0a@3\0", "\0a@3\0a@2a@1a@0\0", 10, 10);
+    TEST ("a@0*a@1a@2\0a@3\0",  "\0a@3\0a@2a@1a@0\0", 10,  0);
+    TEST ("a@0\0a@1a@2*a@3\0",  "\0a@3\0a@2a@1a@0\0", 10,  4);
+    TEST ("a@0\0a@1a@2\0a@3*",  "\0a@3\0a@2a@1a@0\0", 10,  8);
+    TEST ("a@11aa@12aaa@13b",   "a@13aa@12aaa@11c",   -1, 39);
+
+    // invalid directives
+    TEST ("a@b",   "a@0a@b",   -1, 4);
+    TEST ("a@b@c", "a@0a@b@c", -1, 6);
+
+    //////////////////////////////////////////////////////////////////
+    // exercise Unicode escape sequences
+    TEST ("<U0>",     "",        -1, 1);
+    TEST ("<U00>",    "",        -1, 1);
+    TEST ("<U000>",   "",        -1, 1);
+    TEST ("<U0000>",  "",        -1, 1);
+    TEST ("",         "<U0>",    -1, 1);
+    TEST ("",         "<U00>",   -1, 1);
+    TEST ("",         "<U000>",  -1, 1);
+    TEST ("",         "<U0000>", -1, 1);
+    TEST ("<U0>",     "<U0000>", -1, 1);
+    TEST ("<U00>",    "<U000>",  -1, 1);
+    TEST ("<U000>",   "<U00>",   -1, 1);
+    TEST ("<U0000>",  "<U0>",    -1, 1);
+
+    TEST ("<U1>",                   0, -1, 1);
+    TEST ("<U1><U02>",              0, -1, 2);
+    TEST ("<U1><U02><U003>",        0, -1, 3);
+    TEST ("<U1><U02><U003><U0004>", 0, -1, 4);
+
+#if 'A' == 0x41   // ASCII
+    TEST ("<UA>",      "\n",     -1, 2);
+    TEST ("<U0A>",     "\n",     -1, 2);
+    TEST ("<U00A>",    "\n",     -1, 2);
+    TEST ("<U000A>",   "\n",     -1, 2);
+    TEST ("<U0000A>",  "\n",     -1, 2);
+    TEST ("<U41>",     "A",      -1, 2);
+    TEST ("<U41>A",    "AA",     -1, 3);
+    TEST ("A<U41>A",   "AAA",    -1, 4);
+    TEST ("A<U41>@3A", "AAAAA",  -1, 6);
+
+    TEST ("<U41>@0<U42>@1<U43>@2<U44>@3", "BCCDDD", -1, 7);
+#elif 'A' == 0xC1   // EBCDIC
+    TEST ("<U25>",     "\n",     -1, 2);
+    TEST ("<U025>",    "\n",     -1, 2);
+    TEST ("<U025>",    "\n",     -1, 2);
+    TEST ("<U0025>",   "\n",     -1, 2);
+    TEST ("<UC1>",     "A",      -1, 2);
+    TEST ("<UC1>A",    "AA",     -1, 3);
+    TEST ("A<UC1>A",   "AAA",    -1, 4);
+    TEST ("A<UC1>@3A", "AAAAA",  -1, 6);
+
+    TEST ("<UC1>@0<UC2>@1<UC3>@2<UC4>@3", "BCCDDD", -1, 7);
+#else   // unknown
+    rw_warn (0, 0, "unknown character set (neither ASCII nor EBCDIC)");
+#endif
+
     //////////////////////////////////////////////////////////////////
     rw_info (0, 0, 0, "rw_match(char*, const wchar_t*, size_t)");
 
@@ -839,33 +919,92 @@
   rw_assert (expect == result,                                               \
              0, __LINE__,                                                    \
              "rw_match(%{#*s}, L%{#*ls}, %zu) == %zu, got %zu",              \
-             LEN (char, s1, len), s1, LEN (wchar_t, s2, len), s2,            \
-             len, expect, result)
+             int (sizeof s1 - 1), s1,                                        \
+             int (sizeof (s2) / sizeof *(s2) - 1), s2, len,                  \
+             expect, result)
 
-    TEST (0,       0,        -1, 0);
-    TEST ("",      0,        -1, 0);
-    TEST (0,       L"",      -1, 0);
-    TEST ("",      L"",      -1, 0);
-
-    TEST (0,       L"a",     -1, 1);
-    TEST (0,       L"ab",    -1, 2);
-    TEST (0,       L"abc",   -1, 3);
-
-    TEST ("a",     0,        -1, 1);
-    TEST ("ab",    0,        -1, 2);
-    TEST ("abc",   0,        -1, 3);
-
-    TEST ("",      L"a",     -1, 0);
-    TEST ("a",     L"",      -1, 0);
-    TEST ("a",     L"a",     -1, 1);
+    TEST (0,      (wchar_t*)0, -1, 0);
+    TEST ("",     (wchar_t*)0, -1, 0);
+    TEST (0,      L"",         -1, 0);
+    TEST ("",     L"",         -1, 1);
+
+    // same as above but using the <char>@<count> directive
+    TEST ("a@0",  L"",       -1, 1);
+    TEST ("",     L"",       -1, 1);
+    TEST ("a@0",  L"",       -1, 1);
+
+    // when invoked with NULL as the first argument returns
+    // the length of the second string with all directives
+    // expanded
+    TEST (0, L"a",      -1, 1);
+    TEST (0, L"ab",     -1, 2);
+    TEST (0, L"abc",    -1, 3);
+    TEST (0, L"abcd",   -1, 4);
+    TEST (0, L"abcde",  -1, 5);
+    TEST (0, L"abcdef", -1, 6);
+
+    // same as above but with the arguments reversed
+    TEST ("a",      (wchar_t*)0, -1, 1);
+    TEST ("ab",     (wchar_t*)0, -1, 2);
+    TEST ("abc",    (wchar_t*)0, -1, 3);
+    TEST ("a@0",    (wchar_t*)0, -1, 0);
+    TEST ("a@1",    (wchar_t*)0, -1, 1);
+    TEST ("a@2",    (wchar_t*)0, -1, 2);
+    TEST ("a@2b@0", (wchar_t*)0, -1, 2);
+    TEST ("a@2b@1", (wchar_t*)0, -1, 3);
+    TEST ("a@2b@2", (wchar_t*)0, -1, 4);
+
+    TEST ("",     L"a",      -1, 0);
+    TEST ("a",    L"",       -1, 0);
+    TEST ("a",    L"a",      -1, 2);
+
+    // same as above but using the <char>@<count> directive
+    TEST ("a@1",  L"",       -1, 0);
+    TEST ("a@1",  L"a",      -1, 2);
+
+    TEST ("\0ab",       L"\0ac",   2, 2);
+    TEST ("\0@0ab",     L"ab",     2, 2);
+    TEST ("\0@0a\0@0b", L"ab",     2, 2);
 
-    TEST ("a\0bc", L"a\0bd", -1, 1);
+    TEST ("a\0bc", L"a\0bd", -1, 2);
     TEST ("a\0bc", L"a\0bd",  0, 0);
     TEST ("a\0bc", L"a\0bd",  1, 1);
     TEST ("a\0bc", L"a\0bd",  2, 2);
     TEST ("a\0bc", L"a\0bd",  3, 3);
     TEST ("a\0bc", L"a\0bd",  4, 3);
 
+    TEST ("aaaaa",    L"aaaaa",  -1, 6);
+    TEST ("aaaaaa@0", L"aaaaa",  -1, 6);
+    TEST ("aaaaa@1",  L"aaaaa",  -1, 6);
+    TEST ("aaaa@2",   L"aaaaa",  -1, 6);
+    TEST ("aaa@3",    L"aaaaa",  -1, 6);
+    TEST ("aa@4",     L"aaaaa",  -1, 6);
+    TEST ("a@5",      L"aaaaa",  -1, 6);
+    TEST ("a@4a",     L"aaaaa",  -1, 6);
+    TEST ("a@3aa",    L"aaaaa",  -1, 6);
+    TEST ("a@2aaa",   L"aaaaa",  -1, 6);
+    TEST ("a@1aaaa",  L"aaaaa",  -1, 6);
+    TEST ("a@0aaaaa", L"aaaaa",  -1, 6);
+
+    TEST ("a@0a@1a@2a@3", L"aaaaaa", -1, 7);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  0, 0);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  1, 1);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  2, 2);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  3, 3);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  4, 4);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  5, 5);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  6, 6);
+    TEST ("a@0a@1a@2a@3", L"aaaaaa",  7, 7);
+
+    TEST ("a@0\0a@1a@2\0a@3\0", L"\0aaa\0aaa\0", 10, 10);
+    TEST ("a@0*a@1a@2\0a@3\0",  L"\0aaa\0aaa\0", 10,  0);
+    TEST ("a@0\0a@1a@2*a@3\0",  L"\0aaa\0aaa\0", 10,  4);
+    TEST ("a@0\0a@1a@2\0a@3*",  L"\0aaa\0aaa\0", 10,  8);
+
+    // invalid directives
+    TEST ("a@b",   L"a@b",   -1, 4);
+    TEST ("a@b@c", L"a@b@c", -1, 6);
+
 #else   // if defined (_RWSTD_NO_WCHAR_T)
 
     rw_note (0, 0, 0, "_RWSTD_NO_WCHAR_T #defined, wchar_t test disabled");
@@ -876,38 +1015,86 @@
     rw_info (0, 0, 0, "rw_match(char*, const UserChar*, size_t)");
 
 #undef TEST
-#define TEST(s1, s2, len, expect)                                            \
-  result = rw_match ((const char*)s1,                                        \
-                     make_user_string (s2, sizeof (s2)), size_t (len));      \
-  rw_assert (expect == result,                                               \
-             0, __LINE__,                                                    \
-             "rw_match(%{#*s}, %{#*s}, %zu) == %zu, got %zu",                \
-             LEN (char, s1, len), s1, LEN (char, s2, len), s2,               \
+#define TEST(s1, s2, len, expect)                                       \
+  result = rw_match ((const char*)s1,                                   \
+                     make_user_string (s2, sizeof (s2)), size_t (len)); \
+  rw_assert (expect == result,                                          \
+             0, __LINE__,                                               \
+             "rw_match(%{#*s}, %{#*s}, %zu) == %zu, got %zu",           \
+             int (sizeof s1 - 1), s1, int (sizeof s2 - 1), s2, len,     \
              expect, result)
 
-    TEST (0,       0,       -1, 0);
-    TEST ("",      0,       -1, 0);
-    TEST (0,       "",      -1, 0);
-    TEST ("",      "",      -1, 0);
-
-    TEST (0,       "a",     -1, 1);
-    TEST (0,       "ab",    -1, 2);
-    TEST (0,       "abc",   -1, 3);
-
-    TEST ("a",     0,       -1, 1);
-    TEST ("ab",    0,       -1, 2);
-    TEST ("abc",   0,       -1, 3);
-
-    TEST ("",      "a",     -1, 0);
-    TEST ("a",     "",      -1, 0);
-    TEST ("a",     "a",     -1, 1);
+    TEST (0,      0,  -1, 0);
+    TEST ("",     0,  -1, 0);
+    TEST (0,      "", -1, 0);
+    TEST ("",     "", -1, 1);
+
+    // same as above but using the <char>@<count> directive
+    TEST ("a@0",  "",       -1, 1);
+    TEST ("",     "",       -1, 1);
+    TEST ("a@0",  "",       -1, 1);
+
+    // when invoked with NULL as the first string returns
+    // the length of the second string (if non-NULL)
+    TEST (0,      "a",      -1, 1);
+    TEST (0,      "ab",     -1, 2);
+    TEST (0,      "abc",    -1, 3);
+
+    // same as above but with the arguments reversed
+    TEST ("a",   0, -1, 1);
+    TEST ("ab",  0, -1, 2);
+    TEST ("abc", 0, -1, 3);
 
-    TEST ("a\0bc", "a\0bd", -1, 1);
+    TEST ("",     "a",      -1, 0);
+    TEST ("a",    "",       -1, 0);
+    TEST ("a",    "a",      -1, 2);
+
+    // same as above but using the <char>@<count> directive
+    TEST ("a@1",  "",       -1, 0);
+    TEST ("a@1",  "a",      -1, 2);
+
+    TEST ("\0ab",       "\0ac",   2, 2);
+    TEST ("\0@0ab",     "ab",     2, 2);
+    TEST ("\0@0a\0@0b", "ab",     2, 2);
+
+    TEST ("a\0bc", "a\0bd", -1, 2);
     TEST ("a\0bc", "a\0bd",  0, 0);
     TEST ("a\0bc", "a\0bd",  1, 1);
     TEST ("a\0bc", "a\0bd",  2, 2);
     TEST ("a\0bc", "a\0bd",  3, 3);
     TEST ("a\0bc", "a\0bd",  4, 3);
+
+    TEST ("aaaaa",    "aaaaa",  -1, 6);
+    TEST ("aaaaaa@0", "aaaaa",  -1, 6);
+    TEST ("aaaaa@1",  "aaaaa",  -1, 6);
+    TEST ("aaaa@2",   "aaaaa",  -1, 6);
+    TEST ("aaa@3",    "aaaaa",  -1, 6);
+    TEST ("aa@4",     "aaaaa",  -1, 6);
+    TEST ("a@5",      "aaaaa",  -1, 6);
+    TEST ("a@4a",     "aaaaa",  -1, 6);
+    TEST ("a@3aa",    "aaaaa",  -1, 6);
+    TEST ("a@2aaa",   "aaaaa",  -1, 6);
+    TEST ("a@1aaaa",  "aaaaa",  -1, 6);
+    TEST ("a@0aaaaa", "aaaaa",  -1, 6);
+
+    TEST ("a@0a@1a@2a@3", "aaaaaa", -1, 7);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  0, 0);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  1, 1);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  2, 2);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  3, 3);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  4, 4);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  5, 5);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  6, 6);
+    TEST ("a@0a@1a@2a@3", "aaaaaa",  7, 7);
+
+    TEST ("a@0\0a@1a@2\0a@3\0", "\0aaa\0aaa\0", 10, 10);
+    TEST ("a@0*a@1a@2\0a@3\0",  "\0aaa\0aaa\0", 10,  0);
+    TEST ("a@0\0a@1a@2*a@3\0",  "\0aaa\0aaa\0", 10,  4);
+    TEST ("a@0\0a@1a@2\0a@3*",  "\0aaa\0aaa\0", 10,  8);
+
+    // invalid directives
+    TEST ("a@b",   "a@b",   -1, 4);
+    TEST ("a@b@c", "a@b@c", -1, 6);
 }
 
 /***********************************************************************/

Modified: incubator/stdcxx/trunk/tests/src/char.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/char.cpp?rev=417904&r1=417903&r2=417904&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/char.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/char.cpp Wed Jun 28 16:47:10 2006
@@ -526,6 +526,42 @@
 
 /**************************************************************************/
 
+static unsigned long
+_rw_get_char (const char *src, const char** end, size_t *count)
+{
+    unsigned long ch = UChar (*src++);
+
+    if ('<' == char (ch) && 'U' == src [0] && isxdigit (src [1])) {
+        // this looks like the beginning of a <Unnn...>
+        // sequence encoding a Unicode character, look
+        // for a sequence of digits followed by the
+        // closing '>'
+
+        char *tmp_end;
+        const unsigned long val = strtoul (src + 1, &tmp_end, 16);
+        if ('>' == *tmp_end) {
+            ch  = val;
+            src = tmp_end + 1;
+        }
+    }
+
+    if ('@' == src [0] && isdigit (src [1])) {
+        // <char>@<count> denotes a repeat directive representing
+        // <count> consecutive occurrences of the character <char>
+
+        char* tmp_end;
+        *count = strtoul (src + 1, &tmp_end, 10);
+        src    = tmp_end;
+    }
+    else
+        *count = 1;
+
+    *end = src;
+
+    return ch;
+}
+
+
 static void*
 _rw_expand (void *dst, size_t elemsize,
             const char *src, size_t src_len /* = SIZE_MAX */,
@@ -567,31 +603,17 @@
 
     for (const char *psrc = src; ; ) {
 
-        const char c = *psrc;
-
-        unsigned long count;
-
-        if ('@' == psrc [1] && isdigit (UChar (psrc [2]))) {
-            // process directive
-            psrc += 2;
-
-            char *end = 0;
-            count = strtoul (psrc, &end, 10);
-
-            src_len -= (end - psrc) + 2;
-
-            psrc = end;
-
-        }
-        else {
-            count = 1;
-
-            // decrement length unless it's already 0
-            if (src_len)
-                --src_len;
+        size_t count = 0;
+        const char *end = 0;
+        const unsigned long ch = _rw_get_char (psrc, &end, &count);
+
+        const size_t nchars = size_t (end - psrc);
+        if (nchars <= src_len)
+            src_len -= nchars;
+        else
+            src_len = 0;
 
-            ++psrc;
-        }
+        psrc = end;
 
         if (bufsize - buflen <= count) {
             // increase the size of the buffer
@@ -627,16 +649,76 @@
 
         if (sizeof (WChar) == elemsize) {
             for (size_t i = 0; i != count; ++i)
-                ((WChar*)pnext)[i] = WChar (UChar (c));
+                ((WChar*)pnext)[i] = WChar (ch);
         }
         else if (sizeof (UserChar) == elemsize) {
             for (size_t i = 0; i != count; ++i) {
                 ((UserChar*)pnext)[i].f = 0;
-                ((UserChar*)pnext)[i].c = UChar (c);
+                ((UserChar*)pnext)[i].c = UChar (ch);
             }
         }
-        else
-            memset (pnext, UChar (c), count);
+        else if (ch < 0x80U) {
+            memset (pnext, UChar (ch), count);
+        }
+        else {
+#if 1
+            // narrow the wide character to char
+            memset (pnext, UChar (ch), count);
+
+            pnext   = (char*)pnext + count * elemsize;
+            buflen += count;
+            
+#else   // disabled
+
+            // FIXME: enable UCS to UTF-8 conversion
+            // (need to allocate sufficient storage above)
+
+            const char* const pnext_start = pnext;
+
+            // count the number of UTF-8 bytes
+            size_t nbytes = 0;
+
+            for (size_t i = 0; i != count; ++i) {
+                if (ch < 0x800U) {
+                    *pnext++ = UChar (0xc0U | (ch >> 6));
+                    *pnext++ = UChar (0x80U | (ch & 0x3fU));
+                    nbytes  += 2;
+                }
+                else if (ch < 0x10000U) {
+                    *pnext++ = UChar (0xe0U | (ch >> 12));
+                    *pnext++ = UChar (0x80U | (ch >>  6 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch       & 0x3fU));
+                    nbytes  += 3;
+                }
+                else if (ch < 0x200000U) {
+                    *pnext++ = UChar (0xf0U | (ch >> 18));
+                    *pnext++ = UChar (0x80U | (ch >> 12 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >>  6 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch       & 0x3fU));
+                    nbytes  += 4;
+                }
+                else if (ch < 0x4000000U) {
+                    *pnext++ = UChar (0xf8U | (ch >> 24));
+                    *pnext++ = UChar (0x80U | (ch >> 18 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >> 12 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >>  6 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch       & 0x3fU));
+                    nbytes  += 5;
+                }
+                else {
+                    *pnext++ = UChar (0xfcU | (ch >> 30));
+                    *pnext++ = UChar (0x80U | (ch >> 24 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >> 18 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >> 12 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch >>  6 & 0x3fU));
+                    *pnext++ = UChar (0x80U | (ch       & 0x3fU));
+                    nbytes  += 6;
+                }
+            }
+
+#endif   // 0/1
+
+        }
 
         pnext   = (char*)pnext + count * elemsize;
         buflen += count;
@@ -678,59 +760,75 @@
 size_t
 rw_match (const char *s1, const char *s2, size_t len /* = SIZE_MAX */)
 {
+    // the length of the initial subsequence of s1 and s2
+    // consisting solely of characters that compare equal
+    size_t count = 0;
+
     if (0 == s1) {
-        // return the length of s2 if non-null
-        return s2 ? strlen (s2) : 0;
+        s1 = s2;
+        s2 = 0;
     }
 
-    if (0 == s2)
-        return strlen (s1);
+    const char* p1 = s1;
 
-    const char* const s1_save = s1;
+    if (0 == s2) {
+        // when one of the strings is null, compute the length
+        // of the other string when all directives are expanded
+        if (0 == s1 || 0 == *s1)
+            return 0;
 
-    char   s1_buf [256];
-    size_t s1_len = sizeof s1_buf;
+        do {
+            size_t n = 0;
 
-    // see if the first string contains '@' and might need
-    // to be expanded (see rw_expand() for details)
-    bool expand = false;
+            _rw_get_char (p1, &p1, &n);
 
-    if (_RWSTD_SIZE_MAX == len) {
-        expand = 0 != strchr (s1, '@');
-    }
-    else {
-        for (const char *p = s1; *p; ++p) {
-            if (size_t (p - s1) == len)
-                break;
-            if ('@' == *p) {
-                expand = true;
-                break;
-            }
-        }
-    }
+            count += n;
+        } while (p1 && *p1);
 
-    if (expand) {
-        s1  = rw_expand (s1_buf, s1, _RWSTD_SIZE_MAX, &s1_len);
-        len = s1_len;
+        return count;
     }
+    
+    const char* p2 = s2;
+
+    size_t n1 = 0;
+    size_t n2 = 0;
 
-    size_t n = 0;
+    for (unsigned long ch1, ch2; count < len; ) {
 
-    for ( ; n != len && s1 [n] == s2 [n]; ++n) {
-        if (_RWSTD_SIZE_MAX == len && '\0' == s1 [n])
+        while (0 == n1)
+            ch1 = _rw_get_char (p1, &p1, &n1);
+
+        while (0 == n2)
+            ch2 = _rw_get_char (p2, &p2, &n2);
+
+        if (ch1 != ch2)
             break;
-    }
 
-    if (s1 && s1_save != s1 && s1_buf != s1) {
-        // deallocate memory if it was allocated by rw_expand()
-        delete[] s1;
+        if (n1 < n2) {
+            // the repeat count specified by the first directive
+            // is less than the repeat count given by the second
+            count += n1;
+            n2    -= n1;
+            n1     = 0;
+
+        }
+        else if (n2 <= n1) {
+            // the repeat count specified by the second directive
+            // is less than or equal than that given by the first
+            count += n2;
+            n1    -= n2;
+            n2     = 0;
+        }
+
+        if (_RWSTD_SIZE_MAX == len && 0 == ch1)
+            break;
     }
 
-    return n;
+    return len < count ? len : count;
 }
 
 
-#ifndef _RWSTD_WCHAR_T
+#ifndef _RWSTD_NO_WCHAR_T
 
 _TEST_EXPORT
 wchar_t*
@@ -829,35 +927,53 @@
     }
 
     if (0 == s2)
-        return strlen (s1);
+        return rw_match (s1, (char*)0, len);
 
-    const char* const s1_save = s1;
+    const char*    p1 = s1;
+    const wchar_t* p2 = s2;
 
-    char   s1_buf [256];
-    size_t s1_len = sizeof s1_buf;
-    
-    // see if the first string contains '@' and might need
-    // to be expanded  (see rw_expand() for details)
-    if (   _RWSTD_SIZE_MAX == len && strchr (s1, '@')
-        || _RWSTD_SIZE_MAX != len && memchr (s1, '@', len)) {
-        s1 = rw_expand (s1_buf, s1, len, &s1_len);
-        len = s1_len;
-    }
+    // the length of the initial subsequence of s1 and s2
+    // consisting solely of characters that compare equal
+    size_t count = 0;
+
+    size_t n1 = 0;
+    size_t n2 = 0;
 
-    size_t n = 0;
+    for (unsigned long ch1, ch2; count < len; ) {
 
-    for ( ; n != len && UChar (s1 [n]) == unsigned (s2 [n]); ++n) {
-        if (_RWSTD_SIZE_MAX == len && '\0' == s1 [n])
+        while (0 == n1)
+            ch1 = _rw_get_char (p1, &p1, &n1);
+
+        ch2 = _RWSTD_STATIC_CAST (unsigned long, *p2++);
+        n2  = 1;
+
+        if (ch1 != ch2)
             break;
-    }
 
-    if (s1 && s1_save != s1 && s1_buf != s1)
-        delete[] s1;
+        if (n1 < n2) {
+            // the repeat count specified by the first directive
+            // is less than the repeat count given by the second
+            count += n1;
+            n2    -= n1;
+            n1     = 0;
+
+        }
+        else if (n2 <= n1) {
+            // the repeat count specified by the second directive
+            // is less than or equal than that given by the first
+            count += n2;
+            n1    -= n2;
+            n2     = 0;
+        }
+
+        if (_RWSTD_SIZE_MAX == len && L'\0' == ch1)
+            break;
+    }
 
-    return n;
+    return len < count ? len : count;
 }
 
-#endif   // _RWSTD_WCHAR_T
+#endif   // _RWSTD_NO_WCHAR_T
 
 
 _TEST_EXPORT
@@ -958,32 +1074,52 @@
     }
 
     if (0 == s2)
-        return strlen (s1);
+        return rw_match (s1, (char*)0, len);
 
-    const char* const s1_save = s1;
+    const char*     p1 = s1;
+    const UserChar* p2 = s2;
 
-    char   s1_buf [256];
-    size_t s1_len = sizeof s1_buf;
-    
-    // see if the first string contains '@' and might need
-    // to be expanded  (see rw_expand() for details)
-    if (   _RWSTD_SIZE_MAX == len && strchr (s1, '@')
-        || _RWSTD_SIZE_MAX != len && memchr (s1, '@', len)) {
-        s1 = rw_expand (s1_buf, s1, len, &s1_len);
-        len = s1_len;
-    }
+    // the length of the initial subsequence of s1 and s2
+    // consisting solely of characters that compare equal
+    size_t count = 0;
 
-    size_t n = 0;
+    size_t n1 = 0;
+    size_t n2 = 0;
 
-    for ( ; n != len && UChar (s1 [n]) == s2 [n].c; ++n) {
-        if (_RWSTD_SIZE_MAX == len && '\0' == s1 [n])
+    unsigned long ch1;
+
+    for (UserChar ch2; count < len; ) {
+
+        while (0 == n1)
+            ch1 = _rw_get_char (p1, &p1, &n1);
+
+        ch2 = *p2++;
+        n2  = 1;
+
+        if (ch1 != ch2.c)
             break;
-    }
 
-    if (s1 && s1_save != s1 && s1_buf != s1)
-        delete[] s1;
+        if (n1 < n2) {
+            // the repeat count specified by the first directive
+            // is less than the repeat count given by the second
+            count += n1;
+            n2    -= n1;
+            n1     = 0;
+
+        }
+        else if (n2 <= n1) {
+            // the repeat count specified by the second directive
+            // is less than or equal than that given by the first
+            count += n2;
+            n1    -= n2;
+            n2     = 0;
+        }
+
+        if (_RWSTD_SIZE_MAX == len && L'\0' == ch1)
+            break;
+    }
 
-    return n;
+    return len < count ? len : count;
 }
 
 /**************************************************************************/

Modified: incubator/stdcxx/trunk/tests/strings/21.string.access.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.access.cpp?rev=417904&r1=417903&r2=417904&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.access.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.access.cpp Wed Jun 28 16:47:10 2006
@@ -53,35 +53,35 @@
         0, 0, 0, res, 0                          \
     }
 
-    //    +--------------------------------- controlled sequence
-    //    |               +----------------- index 
-    //    |               |   +------------- expected result 
-    //    |               |   |     
-    //    V               V   V     
-    TEST ("a",            0, 'a' ), 
-
-    TEST ("\0",           0, '\0'),
-
-    TEST ("abc",          0, 'a' ),  
-    TEST ("abc",          1, 'b' ),  
-    TEST ("abc",          2, 'c' ),  
-
-    TEST ("\0ab\0\0c",    0, '\0'), 
-
-    TEST ("a\0b\0\0c",    0, 'a' ),  
-    TEST ("a\0b\0\0c",    1, '\0'),
-    TEST ("a\0b\0\0c",    2, 'b' ),  
-    TEST ("a\0b\0\0c",    3, '\0'), 
-    TEST ("a\0b\0\0c",    4, '\0'),
-    TEST ("a\0b\0\0c",    5, 'c' ),   
-
-    TEST ("a\0bc\0\0",    5, '\0'), 
-
-    TEST ("x@4096",       0, 'x' ),  
-    TEST ("x@4096",    2048, 'x' ), 
-    TEST ("x@4096",    4095, 'x' ), 
+    //    +--------------------------------------- controlled sequence
+    //    |                     +----------------- index 
+    //    |                     |   +------------- expected result 
+    //    |                     |   |     
+    //    V                     V   V     
+    TEST ("a",                  0, 'a' ), 
+
+    TEST ("<U0>",               0, '\0'),
+
+    TEST ("abc",                0, 'a' ),  
+    TEST ("abc",                1, 'b' ),  
+    TEST ("abc",                2, 'c' ),  
+
+    TEST ("<U0>ab<U0><U0>c",    0, '\0'), 
+
+    TEST ("a<U0>b<U0><U0>c",    0, 'a' ),  
+    TEST ("a<U0>b<U0><U0>c",    1, '\0'),
+    TEST ("a<U0>b<U0><U0>c",    2, 'b' ),  
+    TEST ("a<U0>b<U0><U0>c",    3, '\0'), 
+    TEST ("a<U0>b<U0><U0>c",    4, '\0'),
+    TEST ("a<U0>b<U0><U0>c",    5, 'c' ),   
+
+    TEST ("a<U0>bc<U0><U0>",    5, '\0'), 
+
+    TEST ("x@4096",             0, 'x' ),  
+    TEST ("x@4096",          2048, 'x' ), 
+    TEST ("x@4096",          4095, 'x' ), 
 
-    TEST ("last",         3, 't' )  
+    TEST ("last",               3, 't' )  
 };
 
 /**************************************************************************/
@@ -98,42 +98,42 @@
         0, 0, 0, res, 0                          \
     }
 
-    //    +--------------------------------- controlled sequence
-    //    |               +----------------- index 
-    //    |               |   +------------- expected result 
-    //    |               |   |     
-    //    V               V   V     
-    TEST ("a",            0, 'a' ),  
-    TEST ("a",            1, NPOS), 
-
-    TEST ("",             0, NPOS), 
-
-    TEST ("\0",           0, '\0'),
-    TEST ("\0",           1, NPOS), 
-
-    TEST ("abc",          0, 'a' ),  
-    TEST ("abc",          1, 'b' ),  
-    TEST ("abc",          2, 'c' ),  
-    TEST ("abc",          3, NPOS), 
-
-    TEST ("\0ab\0\0c",    0, '\0'), 
-
-    TEST ("a\0b\0\0c",    0, 'a' ),  
-    TEST ("a\0b\0\0c",    1, '\0'),
-    TEST ("a\0b\0\0c",    2, 'b' ),  
-    TEST ("a\0b\0\0c",    3, '\0'), 
-    TEST ("a\0b\0\0c",    4, '\0'),
-    TEST ("a\0b\0\0c",    5, 'c' ),  
-    TEST ("a\0b\0\0c",    6, NPOS), 
-
-    TEST ("a\0bc\0\0",    5, '\0'), 
-
-    TEST ("x@4096",       0, 'x' ),  
-    TEST ("x@4096",    2048, 'x' ), 
-    TEST ("x@4096",    4095, 'x' ), 
-    TEST ("x@4096",    4096, NPOS),
+    //    +--------------------------------------- controlled sequence
+    //    |                     +----------------- index 
+    //    |                     |   +------------- expected result 
+    //    |                     |   |     
+    //    V                     V   V     
+    TEST ("a",                  0, 'a' ),  
+    TEST ("a",                  1, NPOS), 
+
+    TEST ("",                   0, NPOS), 
+
+    TEST ("<U0>",               0, '\0'),
+    TEST ("<U0>",               1, NPOS), 
+
+    TEST ("abc",                0, 'a' ),  
+    TEST ("abc",                1, 'b' ),  
+    TEST ("abc",                2, 'c' ),  
+    TEST ("abc",                3, NPOS), 
+
+    TEST ("<U0>ab<U0><U0>c",    0, '\0'), 
+
+    TEST ("a<U0>b<U0><U0>c",    0, 'a' ),  
+    TEST ("a<U0>b<U0><U0>c",    1, '\0'),
+    TEST ("a<U0>b<U0><U0>c",    2, 'b' ),  
+    TEST ("a<U0>b<U0><U0>c",    3, '\0'), 
+    TEST ("a<U0>b<U0><U0>c",    4, '\0'),
+    TEST ("a<U0>b<U0><U0>c",    5, 'c' ),  
+    TEST ("a<U0>b<U0><U0>c",    6, NPOS), 
+
+    TEST ("a<U0>bc<U0><U0>",    5, '\0'), 
+
+    TEST ("x@4096",             0, 'x' ),  
+    TEST ("x@4096",          2048, 'x' ), 
+    TEST ("x@4096",          4095, 'x' ), 
+    TEST ("x@4096",          4096, NPOS),
 
-    TEST ("last",         3, 't' )  
+    TEST ("last",               3, 't' )  
 };
 
 /**************************************************************************/
@@ -153,45 +153,45 @@
         0, 0, 0, res, bthrow                    \
     }
 
-    //    +--------------------------------- controlled sequence
-    //    |               +----------------- index 
-    //    |               |  +-------------- expected result 
-    //    |               |  |        +----- exception info 
-    //    |               |  |        |      0 - no exception
-    //    |               |  |        |      1 - out_of_range
-    //    |               |  |        |
-    //    V               V  V        V
-    TEST ("a",            0, 'a',     0),
-    TEST ("a",            1, NPOS,    1),
-
-    TEST ("",             0, NPOS,    1),
-
-    TEST ("\0",           0, '\0',    0),
-    TEST ("\0",           1, NPOS,    1),
-
-    TEST ("abc",          0, 'a',     0),
-    TEST ("abc",          1, 'b',     0),
-    TEST ("abc",          2, 'c',     0),
-    TEST ("abc",          3, NPOS,    1),
-
-    TEST ("\0ab\0\0c",    0, '\0',    0),
-
-    TEST ("a\0b\0\0c",    0, 'a',     0),
-    TEST ("a\0b\0\0c",    1, '\0',    0),
-    TEST ("a\0b\0\0c",    2, 'b',     0),
-    TEST ("a\0b\0\0c",    3, '\0',    0),
-    TEST ("a\0b\0\0c",    4, '\0',    0),
-    TEST ("a\0b\0\0c",    5, 'c',     0),
-    TEST ("a\0b\0\0c",    6, NPOS,    1),
-
-    TEST ("a\0bc\0\0",    5, '\0',    0),
-
-    TEST ("x@4096",       0, 'x',     0),
-    TEST ("x@4096",    2048, 'x',     0),
-    TEST ("x@4096",    4095, 'x',     0),
-    TEST ("x@4096",    4096, NPOS,    1),
+    //    +--------------------------------------- controlled sequence
+    //    |                     +----------------- index 
+    //    |                     |  +-------------- expected result 
+    //    |                     |  |        +----- exception info 
+    //    |                     |  |        |      0 - no exception
+    //    |                     |  |        |      1 - out_of_range
+    //    |                     |  |        |
+    //    V                     V  V        V
+    TEST ("a",                  0, 'a',     0),
+    TEST ("a",                  1, NPOS,    1),
+
+    TEST ("",                   0, NPOS,    1),
+
+    TEST ("<U0>",               0, '\0',    0),
+    TEST ("<U0>",               1, NPOS,    1),
+
+    TEST ("abc",                0, 'a',     0),
+    TEST ("abc",                1, 'b',     0),
+    TEST ("abc",                2, 'c',     0),
+    TEST ("abc",                3, NPOS,    1),
+
+    TEST ("<U0>ab<U0><U0>c",    0, '\0',    0),
+
+    TEST ("a<U0>b<U0><U0>c",    0, 'a',     0),
+    TEST ("a<U0>b<U0><U0>c",    1, '\0',    0),
+    TEST ("a<U0>b<U0><U0>c",    2, 'b',     0),
+    TEST ("a<U0>b<U0><U0>c",    3, '\0',    0),
+    TEST ("a<U0>b<U0><U0>c",    4, '\0',    0),
+    TEST ("a<U0>b<U0><U0>c",    5, 'c',     0),
+    TEST ("a<U0>b<U0><U0>c",    6, NPOS,    1),
+
+    TEST ("a<U0>bc<U0><U0>",    5, '\0',    0),
+
+    TEST ("x@4096",             0, 'x',     0),
+    TEST ("x@4096",          2048, 'x',     0),
+    TEST ("x@4096",          4095, 'x',     0),
+    TEST ("x@4096",          4096, NPOS,    1),
 
-    TEST ("last",         3, 't',     0)
+    TEST ("last",               3, 't',     0)
 };
 
 /**************************************************************************/

Modified: incubator/stdcxx/trunk/tests/strings/21.string.append.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.append.cpp?rev=417904&r1=417903&r2=417904&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.append.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.append.cpp Wed Jun 28 16:47:10 2006
@@ -61,61 +61,61 @@
         arg, sizeof arg - 1, res, sizeof res - 1, bthrow        \
     }
 
-    //    +----------------------------------------- controlled sequence
-    //    |             +--------------------------- sequence to be appended
-    //    |             |             +------------- expected result sequence
-    //    |             |             |        +---- exception info
-    //    |             |             |        |         0 - no exception
-    //    |             |             |        |         1 - out_of_range
-    //    |             |             |        |         2 - length_error
-    //    |             |             |        |        -1 - exc. safety
-    //    |             |             |        |
-    //    |             |             |        +--------------+
-    //    V             V             V                       V
-    TEST ("ab",         "c",          "abc",                  0),
-
-    TEST ("",           "",           "",                     0),
-    TEST ("",           "\0",         "",                     0),
-    TEST ("",           "abc",        "abc",                  0),
-
-    TEST ("\0",         "",           "\0",                   0),
-    TEST ("\0",         "a",          "\0a",                  0),
-    TEST ("\0",         "\0\0",       "\0",                   0),
-
-    TEST ("ab",         "cd",         "abcd",                 0),
-    TEST ("bcd",        "a",          "bcda",                 0),
-    TEST ("cde",        "ab",         "cdeab",                0),
-    TEST ("abc",        "",           "abc",                  0),
-    TEST ("ab",         "c\0e",       "abc",                  0),
-
-    TEST ("\0\0ab",     "cdefghij",   "\0\0abcdefghij",       0),
-    TEST ("a\0\0b",     "cdefghij",   "a\0\0bcdefghij",       0),
-    TEST ("ab\0\0",     "cdefghij",   "ab\0\0cdefghij",       0),
-    TEST ("a\0b\0\0c",  "e\0",        "a\0b\0\0ce",           0),
-    TEST ("\0ab\0\0c",  "e\0",        "\0ab\0\0ce",           0),
-    TEST ("abcdefghij", "abcdefghij", "abcdefghijabcdefghij", 0),
-
-    TEST ("",           "x@4096",     "x@4096",               0),
-    TEST ("x@4096",     "",           "x@4096",               0),
-    TEST ("x@4096",     "x@4096",     "x@8192",               0),
-
-    TEST ("x@10",       "x@118",      "x@128",                0),
-    TEST ("x@128",      "x@79",       "x@207",                0),
-    TEST ("x@207",      "x@127",      "x@334",                0),
-    TEST ("x@334",      "x@206",      "x@540",                0),
-    TEST ("x@540",      "x@333",      "x@873",                0),
-    TEST ("x@539",      "x@873",      "x@1412",               0),
-    TEST ("x@872",      "x@1412",     "x@2284",               0),
-    TEST ("x@1411",     "x@2284",     "x@3695",               0),
-    TEST ("x@1412",     "x@2284",     "x@3696",               0),
-
-    TEST ("",           0,            "",                     0),
-    TEST ("abc",        0,            "abcabc",               0),
-    TEST ("a\0\0bc",    0,            "a\0\0bca",             0),
-    TEST ("\0\0abc",    0,            "\0\0abc",              0),
-    TEST ("abc\0\0",    0,            "abc\0\0abc",           0),
+    //    +------------------------------------------ controlled sequence
+    //    |                  +----------------------- sequence to be appended
+    //    |                  |            +---------- expected result sequence
+    //    |                  |            |        +- exception info
+    //    |                  |            |        |    0 - no exception
+    //    |                  |            |        |    1 - out_of_range
+    //    |                  |            |        |    2 - length_error
+    //    |                  |            |        |   -1 - avoid exc. safety
+    //    |                  |            |        |
+    //    |                  |            |        +--------------+
+    //    V                  V            V                       V
+    TEST ("ab",             "c",          "abc",                  0),
+
+    TEST ("",               "",           "",                     0),
+    TEST ("",               "<U0>",       "",                     0),
+    TEST ("",               "abc",        "abc",                  0),
+
+    TEST ("<U0>",           "",           "<U0>",                 0),
+    TEST ("<U0>",           "a",          "<U0>a",                0),
+    TEST ("<U0>",           "<U0>@2",     "<U0>",                 0),
+
+    TEST ("ab",             "cd",         "abcd",                 0),
+    TEST ("bcd",            "a",          "bcda",                 0),
+    TEST ("cde",            "ab",         "cdeab",                0),
+    TEST ("abc",            "",           "abc",                  0),
+    TEST ("ab",             "c<U0>e",     "abc",                  0),
+
+    TEST ("<U0>@2ab",       "cdefghij",   "<U0>@2abcdefghij",     0),
+    TEST ("a<U0>@2b",       "cdefghij",   "a<U0>@2bcdefghij",     0),
+    TEST ("ab<U0>@2",       "cdefghij",   "ab<U0>@2cdefghij",     0),
+    TEST ("a<U0>b<U0>@2c",  "e<U0>",      "a<U0>b<U0>@2ce",       0),
+    TEST ("<U0>ab<U0>@2c",  "e<U0>",      "<U0>ab<U0>@2ce",       0),
+    TEST ("abcdefghij",     "abcdefghij", "abcdefghijabcdefghij", 0),
+
+    TEST ("",               "x@4096",     "x@4096",               0),
+    TEST ("x@4096",         "",           "x@4096",               0),
+    TEST ("x@4096",         "x@4096",     "x@8192",               0),
+
+    TEST ("x@10",           "x@118",      "x@128",                0),
+    TEST ("x@128",          "x@79",       "x@207",                0),
+    TEST ("x@207",          "x@127",      "x@334",                0),
+    TEST ("x@334",          "x@206",      "x@540",                0),
+    TEST ("x@540",          "x@333",      "x@873",                0),
+    TEST ("x@539",          "x@873",      "x@1412",               0),
+    TEST ("x@872",          "x@1412",     "x@2284",               0),
+    TEST ("x@1411",         "x@2284",     "x@3695",               0),
+    TEST ("x@1412",         "x@2284",     "x@3696",               0),
+
+    TEST ("",                      0,     "",                     0),
+    TEST ("abc",                   0,     "abcabc",               0),
+    TEST ("a<U0>@2bc",             0,     "a<U0>@2bca",           0),
+    TEST ("<U0>@2abc",             0,     "<U0>@2abc",            0),
+    TEST ("abc<U0>@2",             0,     "abc<U0>@2abc",         0),
 
-    TEST ("last",       "test",       "lasttest",             0)
+    TEST ("last",             "test",     "lasttest",             0)
 };
 
 /**************************************************************************/
@@ -132,62 +132,62 @@
         arg, sizeof arg - 1, res, sizeof res - 1, bthrow        \
     }
 
-    //    +----------------------------------------- controlled sequence
-    //    |             +--------------------------- sequence to be appended
-    //    |             |             +------------- expected result sequence
-    //    |             |             |        +---- exception info
-    //    |             |             |        |         0 - no exception
-    //    |             |             |        |         1 - out_of_range
-    //    |             |             |        |         2 - length_error
-    //    |             |             |        |        -1 - exc. safety
-    //    |             |             |        |
-    //    |             |             |        +--------------+
-    //    V             V             V                       V
-    TEST ("ab",         "c",          "abc",                  0),
-
-    TEST ("",           "",           "",                     0),
-    TEST ("",           "\0",         "\0",                   0),
-    TEST ("",           "abc",        "abc",                  0),
-
-    TEST ("\0",         "",           "\0",                   0),
-    TEST ("\0",         "a",          "\0a",                  0),
-    TEST ("\0",         "\0\0",       "\0\0\0",               0),
-
-    TEST ("ab",         "cd",         "abcd",                 0),
-    TEST ("bcd",        "a",          "bcda",                 0),
-    TEST ("cde",        "ab",         "cdeab",                0),
-    TEST ("abc",        "",           "abc",                  0),
-    TEST ("ab",         "c\0e",       "abc\0e",               0),
-
-    TEST ("\0\0ab",     "cdefghij",   "\0\0abcdefghij",       0),
-    TEST ("a\0\0b",     "cdefghij",   "a\0\0bcdefghij",       0),
-    TEST ("ab\0\0",     "cdefghij",   "ab\0\0cdefghij",       0),
-    TEST ("a\0b\0\0c",  "e\0",        "a\0b\0\0ce\0",         0),
-    TEST ("\0ab\0\0c",  "e\0",        "\0ab\0\0ce\0",         0),
-    TEST ("ab\0\0c\0",  "\0e",        "ab\0\0c\0\0e",         0),
-    TEST ("abcdefghij", "abcdefghij", "abcdefghijabcdefghij", 0),
-
-    TEST ("",           "x@4096",     "x@4096",               0),
-    TEST ("x@4096",     "",           "x@4096",               0),
-    TEST ("x@4096",     "x@4096",     "x@8192",               0),
-
-    TEST ("x@10",       "x@118",      "x@128",                0),
-    TEST ("x@128",      "x@79",       "x@207",                0),
-    TEST ("x@207",      "x@127",      "x@334",                0),
-    TEST ("x@334",      "x@206",      "x@540",                0),
-    TEST ("x@540",      "x@333",      "x@873",                0),
-    TEST ("x@539",      "x@873",      "x@1412",               0),
-    TEST ("x@872",      "x@1412",     "x@2284",               0),
-    TEST ("x@1411",     "x@2284",     "x@3695",               0),
-    TEST ("x@1412",     "x@2284",     "x@3696",               0),
-
-    TEST ("",           0,            "",                     0),
-    TEST ("abc",        0,            "abcabc",               0),
-    TEST ("a\0\0bc",    0,            "a\0\0bca\0\0bc",       0),
-    TEST ("\0\0abc",    0,            "\0\0abc\0\0abc",       0),
-    TEST ("abc\0\0",    0,            "abc\0\0abc\0\0",       0),
+    //    +------------------------------------------ controlled sequence
+    //    |                  +----------------------- sequence to be appended
+    //    |                  |            +---------- expected result sequence
+    //    |                  |            |        +- exception info
+    //    |                  |            |        |    0 - no exception
+    //    |                  |            |        |    1 - out_of_range
+    //    |                  |            |        |    2 - length_error
+    //    |                  |            |        |   -1 - avoid exc. safety
+    //    |                  |            |        |
+    //    |                  |            |        +--------------+
+    //    V                  V            V                       V
+    TEST ("ab",             "c",          "abc",                  0),
+
+    TEST ("",               "",           "",                     0),
+    TEST ("",               "<U0>",       "<U0>",                 0),
+    TEST ("",               "abc",        "abc",                  0),
+
+    TEST ("<U0>",           "",           "<U0>",                 0),
+    TEST ("<U0>",           "a",          "<U0>a",                0),
+    TEST ("<U0>",           "<U0>@2",     "<U0>@3",               0),
+
+    TEST ("ab",             "cd",         "abcd",                 0),
+    TEST ("bcd",            "a",          "bcda",                 0),
+    TEST ("cde",            "ab",         "cdeab",                0),
+    TEST ("abc",            "",           "abc",                  0),
+    TEST ("ab",             "c<U0>e",     "abc<U0>e",             0),
+
+    TEST ("<U0>@2ab",       "cdefghij",   "<U0>@2abcdefghij",     0),
+    TEST ("a<U0>@2b",       "cdefghij",   "a<U0>@2bcdefghij",     0),
+    TEST ("ab<U0>@2",       "cdefghij",   "ab<U0>@2cdefghij",     0),
+    TEST ("a<U0>b<U0>@2c",  "e<U0>",      "a<U0>b<U0>@2ce<U0>",   0),
+    TEST ("<U0>ab<U0>@2c",  "e<U0>",      "<U0>ab<U0>@2ce<U0>",   0),
+    TEST ("ab<U0>@2c<U0>",  "<U0>e",      "ab<U0>@2c<U0>@2e",     0),
+    TEST ("abcdefghij",     "abcdefghij", "abcdefghijabcdefghij", 0),
+
+    TEST ("",               "x@4096",     "x@4096",               0),
+    TEST ("x@4096",         "",           "x@4096",               0),
+    TEST ("x@4096",         "x@4096",     "x@8192",               0),
+
+    TEST ("x@10",           "x@118",      "x@128",                0),
+    TEST ("x@128",          "x@79",       "x@207",                0),
+    TEST ("x@207",          "x@127",      "x@334",                0),
+    TEST ("x@334",          "x@206",      "x@540",                0),
+    TEST ("x@540",          "x@333",      "x@873",                0),
+    TEST ("x@539",          "x@873",      "x@1412",               0),
+    TEST ("x@872",          "x@1412",     "x@2284",               0),
+    TEST ("x@1411",         "x@2284",     "x@3695",               0),
+    TEST ("x@1412",         "x@2284",     "x@3696",               0),
+
+    TEST ("",               0,            "",                     0),
+    TEST ("abc",            0,            "abcabc",               0),
+    TEST ("a<U0>@2bc",      0,            "a<U0>@2bca<U0>@2bc",   0),
+    TEST ("<U0>@2abc",      0,            "<U0>@2abc<U0>@2abc",   0),
+    TEST ("abc<U0>@2",      0,            "abc<U0>@2abc<U0>@2",   0),
 
-    TEST ("last",       "test",       "lasttest",             0)
+    TEST ("last",           "test",       "lasttest",             0)
 };
 
 /**************************************************************************/
@@ -204,68 +204,68 @@
         arg, sizeof arg - 1, res, sizeof res - 1, bthrow        \
     }
 
-    //    +-------------------------------------- controlled sequence
-    //    |            +------------------------- sequence to be appended
-    //    |            |            +------------ append() n argument
-    //    |            |            |  +--------- expected result sequence
-    //    |            |            |  |     +--- exception info
-    //    |            |            |  |     |      0 - no exception
-    //    |            |            |  |     |      1 - out_of_range
-    //    |            |            |  |     |      2 - length_error
-    //    |            |            |  |     |     -1 - exc. safety
-    //    |            |            |  |     |
-    //    |            |            |  |     +------------+
-    //    V            V            V  V                  V
-    TEST ("ab",        "c",         1, "abc",             0),
-
-    TEST ("",          "",          0,  "",               0),
-    TEST ("",          "abc",       1,  "a",              0),
-    TEST ("",          "\0",        1,  "\0",             0),
-
-    TEST ("\0",        "",          0,  "\0",             0),
-    TEST ("\0",        "a",         0,  "\0",             0),
-    TEST ("\0",        "a",         1,  "\0a",            0),
-    TEST ("\0",        "\0\0",      1,  "\0\0",           0),
-    TEST ("\0",        "\0\0",      2,  "\0\0\0",         0),
-
-    TEST ("cde",       "ab",        2,  "cdeab",          0),
-    TEST ("cde",       "ab",        1,  "cdea",           0),
-
-    TEST ("\0e\0",     "a\0b\0\0c", 0,  "\0e\0",          0),
-    TEST ("\0e\0",     "\0ab\0\0c", 3,  "\0e\0\0ab",      0),
-
-    TEST ("a\0b\0\0c", "\0e\0",     3,  "a\0b\0\0c\0e\0", 0),
-    TEST ("a\0b\0\0c", "\0\0e\0",   2,  "a\0b\0\0c\0\0",  0),
-    TEST ("\0ab\0\0c", "\0e\0",     1,  "\0ab\0\0c\0",    0),
-    TEST ("a\0bc\0\0", "\0e",       2,  "a\0bc\0\0\0e",   0),
-
-    TEST ("x@10",      "x@118",   118,   "x@128",         0),
-    TEST ("x@128",     "x@79",     79,   "x@207",         0),
-    TEST ("x@207",     "x@127",   127,   "x@334",         0),
-    TEST ("x@207",     "x@207",   127,   "x@334",         0),
-    TEST ("x@334",     "x@206",   206,   "x@540",         0),
-    TEST ("x@540",     "x@333",   333,   "x@873",         0),
-    TEST ("x@539",     "x@873",   873,   "x@1412",        0),
-    TEST ("x@873",     "x@540",   539,   "x@1412",        0),
-    TEST ("x@872",     "x@1412", 1412,   "x@2284",        0),
-    TEST ("x@1411",    "x@2284", 2284,   "x@3695",        0),
-    TEST ("x@1411",    "x@3695", 2284,   "x@3695",        0),
-    TEST ("x@1412",    "x@2284", 2284,   "x@3696",        0),
-
-    TEST ("",          0,           0,  "",               0),
-    TEST ("abc",       0,           0,  "abc",            0),
-    TEST ("abc",       0,           1,  "abca",           0),
-    TEST ("abc",       0,           2,  "abcab",          0),
-    TEST ("a\0bc",     0,           2,  "a\0bca\0",       0),
-    TEST ("\0abc\0\0", 0,           1,  "\0abc\0\0\0",    0),
-    TEST ("a\0bc\0\0", 0,           3,  "a\0bc\0\0a\0b",  0),
-    TEST ("a@4096",    0,        1111,  "a@5207",         0),
-    TEST ("b@4096",    0,        2222,  "b@6318",         0),
+    //    +------------------------------------------ controlled sequence
+    //    |                +------------------------- sequence to be appended
+    //    |                |            +------------ append() n argument
+    //    |                |            |  +--------- expected result sequence
+    //    |                |            |  |    +---- exception info
+    //    |                |            |  |    |       0 - no exception
+    //    |                |            |  |    |       1 - out_of_range
+    //    |                |            |  |    |       2 - length_error
+    //    |                |            |  |    |      -1 - avoid exc. safety
+    //    |                |            |  |    |
+    //    |                |            |  |    +------------+
+    //    V                V            V  V                 V
+    TEST ("ab",            "c",         1, "abc",            0),
+
+    TEST ("",              "",          0,  "",              0),
+    TEST ("",              "abc",       1,  "a",             0),
+    TEST ("",              "<U0>",      1,  "<U0>",          0),
+
+    TEST ("<U0>",          "",          0,  "<U0>",          0),
+    TEST ("<U0>",          "a",         0,  "<U0>",          0),
+    TEST ("<U0>",          "a",         1,  "<U0>a",         0),
+    TEST ("<U0>",          "<U0>@2",    1,  "<U0>@2",        0),
+    TEST ("<U0>",          "<U0>@2",    2,  "<U0>@3",        0),
+
+    TEST ("cde",           "ab",        2,  "cdeab",         0),
+    TEST ("cde",           "ab",        1,  "cdea",          0),
+
+    TEST ("<U0>e<U0>",     "a<U0>b<U0>@2c", 0,  "<U0>e<U0>",              0),
+    TEST ("<U0>e<U0>",     "<U0>ab<U0>@2c", 3,  "<U0>e<U0>@2ab",          0),
+
+    TEST ("a<U0>b<U0>@2c", "<U0>e<U0>",     3,  "a<U0>b<U0>@2c<U0>e<U0>", 0),
+    TEST ("a<U0>b<U0>@2c", "<U0>@2e<U0>",   2,  "a<U0>b<U0>@2c<U0>@2",    0),
+    TEST ("<U0>ab<U0>@2c", "<U0>e<U0>",     1,  "<U0>ab<U0>@2c<U0>",      0),
+    TEST ("a<U0>bc<U0>@2", "<U0>e",         2,  "a<U0>bc<U0>@3e",         0),
+
+    TEST ("x@10",          "x@118",   118,  "x@128",         0),
+    TEST ("x@128",         "x@79",     79,  "x@207",         0),
+    TEST ("x@207",         "x@127",   127,  "x@334",         0),
+    TEST ("x@207",         "x@207",   127,  "x@334",         0),
+    TEST ("x@334",         "x@206",   206,  "x@540",         0),
+    TEST ("x@540",         "x@333",   333,  "x@873",         0),
+    TEST ("x@539",         "x@873",   873,  "x@1412",        0),
+    TEST ("x@873",         "x@540",   539,  "x@1412",        0),
+    TEST ("x@872",         "x@1412", 1412,  "x@2284",        0),
+    TEST ("x@1411",        "x@2284", 2284,  "x@3695",        0),
+    TEST ("x@1411",        "x@3695", 2284,  "x@3695",        0),
+    TEST ("x@1412",        "x@2284", 2284,  "x@3696",        0),
+
+    TEST ("",              0,           0,  "",              0),
+    TEST ("abc",           0,           0,  "abc",           0),
+    TEST ("abc",           0,           1,  "abca",          0),
+    TEST ("abc",           0,           2,  "abcab",         0),
+    TEST ("a<U0>bc",       0,           2,  "a<U0>bca<U0>",         0),
+    TEST ("<U0>abc<U0>@2", 0,           1,  "<U0>abc<U0>@3",        0),
+    TEST ("a<U0>bc<U0>@2", 0,           3,  "a<U0>bc<U0>@2a<U0>b",  0),
+    TEST ("a@4096",        0,        1111,  "a@5207",        0),
+    TEST ("b@4096",        0,        2222,  "b@6318",        0),
 
-    TEST ("",          "x@4096", 4096,  "x@4096",         0),
-    TEST ("x@4096",    "",          0,  "x@4096",         0),
+    TEST ("",              "x@4096", 4096,  "x@4096",        0),
+    TEST ("x@4096",        "",          0,  "x@4096",        0),
 
-    TEST ("last",      "test",      4, "lasttest",        0)
+    TEST ("last",          "test",      4,  "lasttest",      0)
 };
 
 /**************************************************************************/
@@ -286,83 +286,83 @@
         arg, sizeof arg - 1, res, sizeof res - 1, bthrow        \
     }
 
-    //    +-------------------------------------- controlled sequence
-    //    |            +------------------------- sequence to be appended
-    //    |            |            +------------ append() pos argument
-    //    |            |            |  +--------- append() n argument
-    //    |            |            |  |  +------ expected result sequence
-    //    |            |            |  |  |  +--- exception info
-    //    |            |            |  |  |  |       0 - no exception
-    //    |            |            |  |  |  |       1 - out_of_range
-    //    |            |            |  |  |  |       2 - length_error
-    //    |            |            |  |  |  |      -1 - exc. safety
-    //    |            |            |  |  |  |
-    //    |            |            |  |  |  +----------------+
-    //    V            V            V  V  V                   V
-    TEST ("ab",        "c",         0, 1, "abc",              0),
-
-    TEST ("",          "",          0, 0,  "",                0),
-    TEST ("",          "abc",       1, 1,  "b",               0),
-    TEST ("",          "\0",        0, 1,  "\0",              0),
-
-    TEST ("\0",        "",          0, 0,  "\0",              0),
-
-    TEST ("abc",       "",          0, 0,  "abc",             0),
-
-    TEST ("\0",        "a",         0, 1,  "\0a",             0),
-    TEST ("\0",        "\0\0",      1, 1,  "\0\0",            0),
-    TEST ("\0",        "\0\0",      0, 2,  "\0\0\0",          0),
-    TEST ("\0",        "\0\0",      1, 5,  "\0\0",            0),
-
-    TEST ("cde",       "ab",        0, 2,  "cdeab",           0),
-    TEST ("cde",       "ab",        0, 1,  "cdea",            0),
-    TEST ("cde",       "ab",        1, 5,  "cdeb",            0),
-
-    TEST ("ab",        "c\0e",      0, 3,  "abc\0e",          0),
-    TEST ("ab",        "c\0e",      1, 2,  "ab\0e",           0),
-    TEST ("ab",        "c\0e",      0, 2,  "abc\0",           0),
-
-    TEST ("\0e\0",     "\0ab\0\0c", 0, 9,  "\0e\0\0ab\0\0c",  0),
-    TEST ("\0e\0",     "\0ab\0\0c", 0, 3,  "\0e\0\0ab",       0),
-    TEST ("a\0b\0\0c", "\0e\0",     0, 3,  "a\0b\0\0c\0e\0",  0),
-    TEST ("a\0b\0\0c", "\0\0e\0",   0, 2,  "a\0b\0\0c\0\0",   0),
-    TEST ("\0ab\0\0c", "\0e\0",     2, 1,  "\0ab\0\0c\0",     0),
-    TEST ("a\0bc\0\0", "\0e",       0, 2,  "a\0bc\0\0\0e",    0),
-
-    TEST ("",          0,           0, 0,  "",                0),
-    TEST ("abc",       0,           1, 0,  "abc",             0),
-    TEST ("abc",       0,           1, 1,  "abcb",            0),
-    TEST ("abc",       0,           0, 2,  "abcab",           0),
-    TEST ("a\0bc\0\0", 0,           4, 2,  "a\0bc\0\0\0\0",   0),
-    TEST ("a\0bc\0\0", 0,           1, 3,  "a\0bc\0\0\0bc",   0),
-    TEST ("a\0bc\0\0", 0,           3, 9,  "a\0bc\0\0c\0\0",  0),
-    TEST ("abcdef",    0,           1, 2,  "abcdefbc",        0),
-
-    TEST ("a@1000",    "b@1000",    0,  999, "a@1000b@999",   0),
-    TEST ("a@1000",    "b@1001",    0, 1000, "a@1000b@1000",  0),
-    TEST ("a@1000",    "b@1002",    0,  102, "a@1000b@102",   0),
-    TEST ("",          "x@4096",    0, 4096, "x@4096",        0),
-    TEST ("x@4096",    "",          0,    0, "x@4096",        0),
-    TEST ("x@4096",    "a@4096",  100,   10, "x@4096a@10",    0),
-
-    TEST ("x@10",      "x@118",     0,  118, "x@128",         0),
-    TEST ("x@128",     "x@129",    50,   79, "x@207",         0),
-    TEST ("x@207",     "x@127",     0,  127, "x@334",         0),
-    TEST ("x@207",     "x@207",    10,  127, "x@334",         0),
-    TEST ("x@334",     "x@208",     2,  206, "x@540",         0),
-    TEST ("x@540",     "x@336",     3,  333, "x@873",         0),
-    TEST ("x@539",     "x@873",     0,  873, "x@1412",        0),
-    TEST ("x@873",     "x@540",     1,  539, "x@1412",        0),
-    TEST ("x@872",     "x@1412",    0, 1412, "x@2284",        0),
-    TEST ("x@1411",    "x@2288",    4, 2284, "x@3695",        0),
-    TEST ("x@1411",    "x@3695",  128, 2284, "x@3695",        0),
-    TEST ("x@1412",    "x@2284",    0, 2284, "x@3696",        0),
-
-    TEST ("",          "\0",        2,    0, "",              1),
-    TEST ("",          "a",         2,    0, "",              1),
-    TEST ("",          "x@4096", 4106,    0, "",              1),
+    //    +------------------------------------------ controlled sequence
+    //    |                +------------------------- sequence to be appended
+    //    |                |            +------------ append() pos argument
+    //    |                |            |  +--------- append() n argument
+    //    |                |            |  |  +------ expected result sequence
+    //    |                |            |  |  |  +--- exception info
+    //    |                |            |  |  |  |       0 - no exception
+    //    |                |            |  |  |  |       1 - out_of_range
+    //    |                |            |  |  |  |       2 - length_error
+    //    |                |            |  |  |  |      -1 - exc. safety
+    //    |                |            |  |  |  |
+    //    |                |            |  |  |  +----------------+
+    //    V                V            V  V  V                   V
+    TEST ("ab",            "c",         0, 1, "abc",              0),
+
+    TEST ("",              "",          0, 0,  "",                0),
+    TEST ("",              "abc",       1, 1,  "b",               0),
+    TEST ("",              "<U0>",      0, 1,  "<U0>",            0),
+
+    TEST ("<U0>",          "",          0, 0,  "<U0>",            0),
+
+    TEST ("abc",           "",          0, 0,  "abc",             0),
+
+    TEST ("<U0>",          "a",         0, 1,  "<U0>a",           0),
+    TEST ("<U0>",          "<U0>@2",    1, 1,  "<U0>@2",          0),
+    TEST ("<U0>",          "<U0>@2",    0, 2,  "<U0>@3",          0),
+    TEST ("<U0>",          "<U0>@2",    1, 5,  "<U0>@2",          0),
+
+    TEST ("cde",           "ab",        0, 2,  "cdeab",           0),
+    TEST ("cde",           "ab",        0, 1,  "cdea",            0),
+    TEST ("cde",           "ab",        1, 5,  "cdeb",            0),
+
+    TEST ("ab",            "c<U0>e",    0, 3,  "abc<U0>e",        0),
+    TEST ("ab",            "c<U0>e",    1, 2,  "ab<U0>e",         0),
+    TEST ("ab",            "c<U0>e",    0, 2,  "abc<U0>",         0),
+
+    TEST ("<U0>e<U0>",     "<U0>ab<U0>@2c", 0, 9, "<U0>e<U0>@2ab<U0>@2c",   0),
+    TEST ("<U0>e<U0>",     "<U0>ab<U0>@2c", 0, 3, "<U0>e<U0>@2ab",          0),
+    TEST ("a<U0>b<U0>@2c", "<U0>e<U0>",     0, 3, "a<U0>b<U0>@2c<U0>e<U0>", 0),
+    TEST ("a<U0>b<U0>@2c", "<U0>@2e<U0>",   0, 2, "a<U0>b<U0>@2c<U0>@2",    0),
+    TEST ("<U0>ab<U0>@2c", "<U0>e<U0>",     2, 1, "<U0>ab<U0>@2c<U0>",      0),
+    TEST ("a<U0>bc<U0>@2", "<U0>e",         0, 2, "a<U0>bc<U0>@3e",         0),
+
+    TEST ("",              0,           0, 0,  "",                0),
+    TEST ("abc",           0,           1, 0,  "abc",             0),
+    TEST ("abc",           0,           1, 1,  "abcb",            0),
+    TEST ("abc",           0,           0, 2,  "abcab",           0),
+    TEST ("a<U0>bc<U0>@2", 0,           4, 2,  "a<U0>bc<U0>@3<U0>",     0),
+    TEST ("a<U0>bc<U0>@2", 0,           1, 3,  "a<U0>bc<U0>@3bc",       0),
+    TEST ("a<U0>bc<U0>@2", 0,           3, 9,  "a<U0>bc<U0>@2c<U0>@2",  0),
+    TEST ("abcdef",        0,           1, 2,  "abcdefbc",        0),
+
+    TEST ("a@1000",        "b@1000",    0,  999, "a@1000b@999",   0),
+    TEST ("a@1000",        "b@1001",    0, 1000, "a@1000b@1000",  0),
+    TEST ("a@1000",        "b@1002",    0,  102, "a@1000b@102",   0),
+    TEST ("",              "x@4096",    0, 4096, "x@4096",        0),
+    TEST ("x@4096",        "",          0,    0, "x@4096",        0),
+    TEST ("x@4096",        "a@4096",  100,   10, "x@4096a@10",    0),
+
+    TEST ("x@10",          "x@118",     0,  118, "x@128",         0),
+    TEST ("x@128",         "x@129",    50,   79, "x@207",         0),
+    TEST ("x@207",         "x@127",     0,  127, "x@334",         0),
+    TEST ("x@207",         "x@207",    10,  127, "x@334",         0),
+    TEST ("x@334",         "x@208",     2,  206, "x@540",         0),
+    TEST ("x@540",         "x@336",     3,  333, "x@873",         0),
+    TEST ("x@539",         "x@873",     0,  873, "x@1412",        0),
+    TEST ("x@873",         "x@540",     1,  539, "x@1412",        0),
+    TEST ("x@872",         "x@1412",    0, 1412, "x@2284",        0),
+    TEST ("x@1411",        "x@2288",    4, 2284, "x@3695",        0),
+    TEST ("x@1411",        "x@3695",  128, 2284, "x@3695",        0),
+    TEST ("x@1412",        "x@2284",    0, 2284, "x@3696",        0),
+
+    TEST ("",              "<U0>",      2,    0, "",              1),
+    TEST ("",              "a",         2,    0, "",              1),
+    TEST ("",              "x@4096", 4106,    0, "",              1),
 
-    TEST ("last",      "test",      0,    4, "lasttest",      0)
+    TEST ("last",          "test",      0,    4, "lasttest",      0)
 };
 
 /**************************************************************************/
@@ -379,58 +379,58 @@
         0, 0, res, sizeof res - 1, bthrow       \
     }
 
-    //    +-------------------------------------- controlled sequence
-    //    |            +------------------------- append() count argument
-    //    |            |   +--------------------- character to be appended
-    //    |            |   |   +----------------- expected result sequence
-    //    |            |   |   |       +--------- exception info
-    //    |            |   |   |       |             0 - no exception
-    //    |            |   |   |       |             1 - out_of_range
-    //    |            |   |   |       |             2 - length_error
-    //    |            |   |   |       |            -1 - exc. safety
-    //    |            |   |   |       |
-    //    |            |   |   |       +-----------+
-    //    V            V   V   V                   V
-    TEST ("ab",        1, 'c', "abc",              0),
-
-    TEST ("",          0, ' ',  "",                0),
-    TEST ("",          1, 'b',  "b",               0),
-    TEST ("",          3, 'b',  "bbb",             0),
-
-    TEST ("\0",        0, ' ',  "\0",              0),
-    TEST ("",          2, '\0', "\0\0",            0),
-
-    TEST ("\0",        1, 'a',  "\0a",             0),
-    TEST ("\0",        1, '\0', "\0\0",            0),
-    TEST ("\0",        2, '\0', "\0\0\0",          0),
-    TEST ("\0",        0, '\0', "\0",              0),
-
-    TEST ("cde",       1, 'a',  "cdea",            0),
-    TEST ("cde",       2, 'a',  "cdeaa",           0),
-    TEST ("cde",       3, 'a',  "cdeaaa",          0),
-
-    TEST ("ab",        2, '\0', "ab\0\0",          0),
-    TEST ("ab",        1, '\0', "ab\0",            0),
-    TEST ("ab",        2, '\0', "ab\0\0",          0),
-
-    TEST ("a\0b\0\0c", 2, '\0', "a\0b\0\0c\0\0",   0),
-    TEST ("a\0b\0\0c", 1, '\0', "a\0b\0\0c\0",     0),
-    TEST ("\0ab\0\0c", 3, '\0', "\0ab\0\0c\0\0\0", 0),
-    TEST ("a\0bc\0\0", 2, 'a',  "a\0bc\0\0aa",     0),
-
-    TEST ("",       4096, 'x', "x@4096",           0),
-    TEST ("x@4096",    0, 'x', "x@4096",           0),
-
-    TEST ("x@127",     1, 'x', "x@128",            0),
-    TEST ("x@200",     7, 'x', "x@207",            0),
-    TEST ("x@331",     3, 'x', "x@334",            0),
-    TEST ("x@539",     1, 'x', "x@540",            0),
-    TEST ("x@539",   873, 'x', "x@1412",           0),
-    TEST ("x@873",  1411, 'x', "x@2284",           0),
-    TEST ("x@3694",    1, 'x', "x@3695",           0),
-    TEST ("x@540",     1, 'x', "x@541",            0),
+    //    +------------------------------------------ controlled sequence
+    //    |                +------------------------- append() count argument
+    //    |                |   +--------------------- character to be appended
+    //    |                |   |   +----------------- expected result sequence
+    //    |                |   |   |       +--------- exception info
+    //    |                |   |   |       |             0 - no exception
+    //    |                |   |   |       |             1 - out_of_range
+    //    |                |   |   |       |             2 - length_error
+    //    |                |   |   |       |            -1 - exc. safety
+    //    |                |   |   |       |
+    //    |                |   |   |       +-----------+
+    //    V                V   V   V                   V
+    TEST ("ab",            1, 'c', "abc",              0),
+
+    TEST ("",              0, ' ',  "",                0),
+    TEST ("",              1, 'b',  "b",               0),
+    TEST ("",              3, 'b',  "bbb",             0),
+
+    TEST ("<U0>",          0, ' ',  "<U0>",            0),
+    TEST ("",              2, '\0', "<U0>@2",          0),
+
+    TEST ("<U0>",          1, 'a',  "<U0>a",           0),
+    TEST ("<U0>",          1, '\0', "<U0>@2",          0),
+    TEST ("<U0>",          2, '\0', "<U0>@3",          0),
+    TEST ("<U0>",          0, '\0', "<U0>",            0),
+
+    TEST ("cde",           1, 'a',  "cdea",            0),
+    TEST ("cde",           2, 'a',  "cdeaa",           0),
+    TEST ("cde",           3, 'a',  "cdeaaa",          0),
+
+    TEST ("ab",            2, '\0', "ab<U0>@2",        0),
+    TEST ("ab",            1, '\0', "ab<U0>",          0),
+    TEST ("ab",            2, '\0', "ab<U0>@2",        0),
+
+    TEST ("a<U0>b<U0>@2c", 2, '\0', "a<U0>b<U0>@2c<U0>@2", 0),
+    TEST ("a<U0>b<U0>@2c", 1, '\0', "a<U0>b<U0>@2c<U0>",   0),
+    TEST ("<U0>ab<U0>@2c", 3, '\0', "<U0>ab<U0>@2c<U0>@3", 0),
+    TEST ("a<U0>bc<U0>@2", 2, 'a',  "a<U0>bc<U0>@2aa",     0),
+
+    TEST ("",           4096, 'x', "x@4096",           0),
+    TEST ("x@4096",        0, 'x', "x@4096",           0),
+
+    TEST ("x@127",         1, 'x', "x@128",            0),
+    TEST ("x@200",         7, 'x', "x@207",            0),
+    TEST ("x@331",         3, 'x', "x@334",            0),
+    TEST ("x@539",         1, 'x', "x@540",            0),
+    TEST ("x@539",       873, 'x', "x@1412",           0),
+    TEST ("x@873",      1411, 'x', "x@2284",           0),
+    TEST ("x@3694",        1, 'x', "x@3695",           0),
+    TEST ("x@540",         1, 'x', "x@541",            0),
 
-    TEST ("last",      4, 't', "lasttttt",         0)
+    TEST ("last",          4, 't', "lasttttt",         0)
 };
 
 /**************************************************************************/
@@ -447,38 +447,38 @@
         0, 0, res, sizeof res - 1, bthrow       \
     }
 
-    //    +-------------------------------------- controlled sequence
-    //    |            +--------------------- character to be appended
-    //    |            |   +----------------- expected result sequence
-    //    |            |   |       +--------- exception info
-    //    |            |   |       |             0 - no exception
-    //    |            |   |       |            -1 - exc. safety
-    //    |            |   |       |
-    //    |            |   |       +------------+
-    //    V            V   V                    V
-    TEST ("ab",        'c', "abc",              0),
-
-    TEST ("",          'a', "a",                0),
-    TEST ("",          '\0', "\0",              0),
-    TEST ("\0",        'a', "\0a",              0),
-    TEST ("\0",        '\0', "\0\0",            0),
-
-    TEST ("a\0b\0\0c", '\0', "a\0b\0\0c\0",     0),
-    TEST ("a\0bc\0\0", 'a', "a\0bc\0\0a",       0),
-    TEST ("\0abc\0\0", 'a', "\0abc\0\0a",       0),
-
-    TEST ("x@4095",    'x', "x@4096",           0),
-
-    TEST ("x@127",     'x',  "x@128",           0),
-    TEST ("x@206",     'x',  "x@207",           0),
-    TEST ("x@333",     'x',  "x@334",           0),
-    TEST ("x@539",     'x',  "x@540",           0),
-    TEST ("x@1411",    'x',  "x@1412",          0),
-    TEST ("x@2283",    'x',  "x@2284",          0),
-    TEST ("x@3694",    'x',  "x@3695",          0),
-    TEST ("x@540",     'x',  "x@541",           0),
+    //    +---------------------------------------- controlled sequence
+    //    |                 +---------------------- character to be appended
+    //    |                 |    +----------------- expected result sequence
+    //    |                 |    |       +--------- exception info
+    //    |                 |    |       |             0 - no exception
+    //    |                 |    |       |            -1 - exc. safety
+    //    |                 |    |       |
+    //    |                 |    |       +------------+
+    //    V                 V    V                    V
+    TEST ("ab",            'c',  "abc",               0),
+
+    TEST ("",              'a',  "a",                 0),
+    TEST ("",              '\0', "<U0>",              0),
+    TEST ("<U0>",          'a',  "<U0>a",             0),
+    TEST ("<U0>",          '\0', "<U0>@2",            0),
+
+    TEST ("a<U0>b<U0>@2c", '\0', "a<U0>b<U0>@2c<U0>", 0),
+    TEST ("a<U0>bc<U0>@2", 'a',  "a<U0>bc<U0>@2a",    0),
+    TEST ("<U0>abc<U0>@2", 'a',  "<U0>abc<U0>@2a",    0),
+
+    TEST ("x@4095",        'x',  "x@4096",            0),
+
+    TEST ("x@127",         'x',  "x@128",             0),
+    TEST ("x@206",         'x',  "x@207",             0),
+    TEST ("x@333",         'x',  "x@334",             0),
+    TEST ("x@539",         'x',  "x@540",             0),
+    TEST ("x@1411",        'x',  "x@1412",            0),
+    TEST ("x@2283",        'x',  "x@2284",            0),
+    TEST ("x@3694",        'x',  "x@3695",            0),
+    TEST ("x@540",         'x',  "x@541",             0),
 
-    TEST ("last",      't', "lastt",            0)
+    TEST ("last",          't',  "lastt",             0)
 };
 
 /**************************************************************************/
@@ -707,7 +707,7 @@
                 // (and only then), also verify that the modified
                 // string matches the expected result
                 const std::size_t match =
-                    rw_match (tcase.res, str.c_str (), tcase.nres);
+                    rw_match (tcase.res, str.c_str (), str.size ());
 
                 rw_assert (match == tdata.reslen_, 0, tcase.line,
                            "line %d. %{$FUNCALL} expected %{/*.*Gs}, "



Mime
View raw message