You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/05/25 03:31:03 UTC

svn commit: r409280 [3/4] - in /incubator/stdcxx/trunk/tests: include/ src/ strings/

Modified: incubator/stdcxx/trunk/tests/strings/21.string.compare.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.compare.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.compare.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.compare.cpp Wed May 24 18:31:01 2006
@@ -37,12 +37,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define Compare(which)            StringMembers::compare_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
-
+#define Compare(sig)              StringIds::compare_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -53,8 +48,8 @@
 
 // exercises:
 // compare (const value_type*)
-static const TestCase
-ptr_test_cases [] = {
+static const StringTestCase
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow) {           \
@@ -125,8 +120,8 @@
 
 // exercises:
 // compare (const basic_string&)
-static const TestCase
-str_test_cases [] = {
+static const StringTestCase
+cstr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow) {           \
@@ -200,8 +195,8 @@
 
 // exercises:
 // compare (size_type, size_type, const value_type*)
-static const TestCase
-size_size_ptr_test_cases [] = {
+static const StringTestCase
+size_size_cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, size, arg, res, bthrow) {        \
@@ -293,8 +288,8 @@
 
 // exercises:
 // compare (size_type, size_type, basic_string&)
-static const TestCase
-size_size_str_test_cases [] = {
+static const StringTestCase
+size_size_cstr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, size, arg, res, bthrow) {        \
@@ -399,8 +394,8 @@
 
 // exercises:
 // compare (size_type, size_type, const value_type*, size_type)
-static const TestCase
-size_size_ptr_size_test_cases [] = {
+static const StringTestCase
+size_size_cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, size, arg, size2, res, bthrow) { \
@@ -527,8 +522,8 @@
 
 // exercises:
 // compare (size_type, size_type, basic_string&, size_type, size_type)
-static const TestCase
-size_size_str_size_size_test_cases [] = {
+static const StringTestCase
+size_size_cstr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, size, arg, off2, size2, res, bthrow) {   \
@@ -697,8 +692,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_compare (charT, Traits*, Allocator*,
-                   const Function &func,
-                   const TestCase &tcase)
+                   const StringFunc     &func,
+                   const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename UserTraits<charT>::MemFun           UTMemFun;
@@ -716,8 +711,8 @@
 
     // construct the string object to be modified
     // and the (possibly unused) argument string
-    /* const */ String s_str (wstr, str_len);
-    const       String s_arg (warg, arg_len);
+    const String str (wstr, str_len);
+    const String arg (warg, arg_len);
 
     if (wstr != wstr_buf)
         delete[] wstr;
@@ -731,13 +726,13 @@
     // save the state of the string object before the call
     // to detect wxception safety violations (changes to
     // the state of the object after an exception)
-    const StringState str_state (rw_get_string_state (s_str));
+    const StringState str_state (rw_get_string_state (str));
 
     int res = 0;
 
     // string function argument
-    const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
-    const String&      arg_str = tcase.arg ? s_arg : s_str;
+    const charT* const arg_ptr = tcase.arg ? arg.c_str () : str.c_str ();
+    const String&      arg_str = tcase.arg ? arg : str;
 
     std::size_t total_compare_calls = 0;
     std::size_t n_compare_calls = 0;
@@ -756,7 +751,7 @@
     if (1 == tcase.bthrow)
         expected = exceptions [1];
     else if (   2 == tcase.bthrow
-             && Compare (size_size_str_size_size) == func.which_)
+             && Compare (size_size_cstr_size_size) == func.which_)
         expected = exceptions [1];
     else if (3 == tcase.bthrow)
         expected = exceptions [2];
@@ -770,39 +765,33 @@
 
     try {
         switch (func.which_) {
-            case Compare (ptr): {
-                res = s_str.compare (arg_ptr);
+            case Compare (cptr):
+                res = str.compare (arg_ptr);
                 break;
-            }
 
-            case Compare (str): {
-                res = s_str.compare (arg_str);
+            case Compare (cstr):
+                res = str.compare (arg_str);
                 if (rg_calls)
                     n_compare_calls = rg_calls[UTMemFun::compare];
                 break;
-            }
 
-            case Compare (size_size_ptr): {
-                res = s_str.compare (tcase.off, tcase.size, arg_ptr);
+            case Compare (size_size_cptr):
+                res = str.compare (tcase.off, tcase.size, arg_ptr);
                 break;
-            }
 
-            case Compare (size_size_str): {
-                res = s_str.compare (tcase.off, tcase.size, arg_str);
+            case Compare (size_size_cstr):
+                res = str.compare (tcase.off, tcase.size, arg_str);
                 break;
-            }
 
-            case Compare (size_size_ptr_size): {
-                res = s_str.compare (tcase.off, tcase.size,
+            case Compare (size_size_cptr_size):
+                res = str.compare (tcase.off, tcase.size,
                                     arg_ptr, tcase.size2);
                 break;
-            }
 
-            case Compare (size_size_str_size_size): {
-                res = s_str.compare (tcase.off, tcase.size,
+            case Compare (size_size_cstr_size_size):
+                res = str.compare (tcase.off, tcase.size,
                                     arg_str, tcase.off2, tcase.size2);
                 break;
-            }
 
             default:
                 RW_ASSERT ("test logic error: unknown compare overload");
@@ -819,7 +808,7 @@
                    __LINE__, tcase.nres == NPOS ? -1 : int (tcase.nres), res);
 
         // verify that Traits::length was used
-        if (Compare (str) == func.which_ && rg_calls) {
+        if (Compare (cstr) == func.which_ && rg_calls) {
             rw_assert (n_compare_calls - total_compare_calls > 0,
                        0, tcase.line, "line %d. %{$FUNCALL} doesn't "
                        "use traits::compare()", __LINE__);
@@ -860,7 +849,7 @@
     if (caught) {
         // verify that an exception thrown during allocation
         // didn't cause a change in the state of the object
-        str_state.assert_equal (rw_get_string_state (s_str),
+        str_state.assert_equal (rw_get_string_state (str),
                                 __LINE__, tcase.line, caught);
     }
 
@@ -874,26 +863,26 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::compare_ ## tag, tag ## _test_cases,     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        Compare (sig), sig ## _test_cases,                      \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (size_size_ptr),
-        TEST (size_size_str),
-        TEST (size_size_ptr_size),
-        TEST (size_size_str_size_size)
+        TEST (cptr),
+        TEST (cstr),
+        TEST (size_size_cptr),
+        TEST (size_size_cstr),
+        TEST (size_size_cptr_size),
+        TEST (size_size_cstr_size_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.compare",
-                                    test_compare, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.compare",
+                               test_compare, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.cons.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.cons.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.cons.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.cons.cpp Wed May 24 18:31:01 2006
@@ -33,11 +33,8 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define Ctor(which)               StringMembers::ctor_ ## which
-#define OpSet(which)              StringMembers::op_set_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define Ctor(sig)               StringIds::ctor_ ## sig
+#define OpSet(sig)              StringIds::op_set_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -48,7 +45,7 @@
 
 // exercises:
 // basic_string (void)
-static const TestCase
+static const StringTestCase
 void_test_cases [] = {
 
 #undef TEST
@@ -70,8 +67,8 @@
 
 // exercises:
 // basic_string (const value_type*)
-static const TestCase
-ptr_test_cases [] = {
+static const StringTestCase
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(arg, res) {                            \
@@ -108,8 +105,8 @@
 
 // exercises:
 // basic_string (const basic_string&)
-static const TestCase
-str_test_cases [] = {
+static const StringTestCase
+cstr_test_cases [] = {
 
 #undef TEST
 #define TEST(arg, res) {                            \
@@ -147,8 +144,8 @@
 
 // exercises:
 // basic_string (const value_type*, size_type)
-static const TestCase
-ptr_size_test_cases [] = {
+static const StringTestCase
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(arg, size, res) {                      \
@@ -189,8 +186,8 @@
 
 // exercises:
 // basic_string (const basic_string&, size_type)
-static const TestCase
-str_size_test_cases [] = {
+static const StringTestCase
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(arg, off, res, bthrow) {               \
@@ -236,10 +233,10 @@
 // exercises:
 // basic_string (const basic_string&, size_type, size_type)
 // basic_string (InputIterator, InputIterator)
-static const TestCase
-str_size_size_test_cases [] = {
+static const StringTestCase
+cstr_size_size_test_cases [] = {
 
-#define range_test_cases    str_size_size_test_cases
+#define range_test_cases    cstr_size_size_test_cases
 
 #undef TEST
 #define TEST(arg, off, size, res, bthrow) {         \
@@ -285,7 +282,7 @@
 
 // exercises:
 // basic_string (size_type, value_type)
-static const TestCase
+static const StringTestCase
 size_val_test_cases [] = {
 
 #undef TEST
@@ -318,8 +315,8 @@
 /**************************************************************************/
 // exercises:
 // operator= (const value_type*)
-static const TestCase
-op_set_ptr_test_cases [] = {
+static const StringTestCase
+cptr_op_set_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow) {               \
@@ -374,8 +371,8 @@
 /**************************************************************************/
 // exercises:
 // operator= (const basic_string&)
-static const TestCase
-op_set_str_test_cases [] = {
+static const StringTestCase
+cstr_op_set_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow) {               \
@@ -430,8 +427,8 @@
 
 // exercises:
 // operator= (value_type)
-static const TestCase
-op_set_val_test_cases [] = {
+static const StringTestCase
+val_op_set_test_cases [] = {
 
 #undef TEST
 #define TEST(str, val, res) {                 \
@@ -464,7 +461,7 @@
                       std::size_t     res_len,
                       Traits*, Allocator*,
                       const Iterator &it,
-                      const TestCase &tcase)
+                      const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename String::iterator                    StringIter;
@@ -501,7 +498,7 @@
                       std::size_t  warg_len,
                       std::size_t  res_len,
                       Traits*, Allocator*, 
-                      const TestCase &tcase)
+                      const StringTestCase &tcase)
 {
     if (tcase.bthrow)  // this method doesn't throw
         return;
@@ -523,8 +520,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_ctor (charT, Traits*, Allocator*,
-                const Function &func,
-                const TestCase &tcase)
+                const StringFunc     &func,
+                const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -598,34 +595,54 @@
 
     try {
         switch (func.which_) {
-        case Ctor (void): {
+
+        case Ctor (void):
+            ret_ptr = new String ();
+            break;
+
+        case Ctor (alloc):
             ret_ptr = new String (Allocator ());
             break;
-        }
-        case Ctor (ptr): {
+
+        case Ctor (cptr):
+            ret_ptr = new String (arg_ptr);
+            break;
+
+        case Ctor (cptr_alloc):
             ret_ptr = new String (arg_ptr, Allocator ());
             break;
-        }
-        case Ctor (str): {
+
+        case Ctor (cstr):
             ret_ptr = new String (arg_str);
             break;
-        }
-        case Ctor (ptr_size): {
+
+        case Ctor (cptr_size):
+            ret_ptr = new String (arg_ptr, arg_size);
+            break;
+
+        case Ctor (cptr_size_alloc):
             ret_ptr = new String (arg_ptr, arg_size, Allocator ());
             break;
-        }
-        case Ctor (str_size): {
+
+        case Ctor (cstr_size):
             ret_ptr = new String (arg_str, arg_off);
             break;
-        }
-        case Ctor (str_size_size): {
+
+        case Ctor (cstr_size_size):
+            ret_ptr = new String (arg_str, arg_off, arg_size);
+            break;
+
+        case Ctor (cstr_size_size_alloc):
             ret_ptr = new String (arg_str, arg_off, arg_size, Allocator ());
             break;
-        }
-        case Ctor (size_val): {
+
+        case Ctor (size_val):
+            ret_ptr = new String (tcase.size, arg_val);
+            break;
+
+        case Ctor (size_val_alloc):
             ret_ptr = new String (tcase.size, arg_val, Allocator ());
             break;
-        }
 
         default:
             RW_ASSERT (!"logic error: unknown constructor overload");
@@ -734,8 +751,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_op_set (charT, Traits*, Allocator*,
-                  const Function &func,
-                  const TestCase &tcase)
+                  const StringFunc     &func,
+                  const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename UserTraits<charT>::MemFun           UTMemFun;
@@ -781,7 +798,7 @@
 
     std::size_t total_length_calls = 0;
     std::size_t n_length_calls = 0;
-    std::size_t* const rg_calls = OpSet (ptr) == func.which_ ?
+    std::size_t* const rg_calls = OpSet (cptr) == func.which_ ?
         rw_get_call_counters ((Traits*)0, (charT*)0) : 0;
 
     if (rg_calls)
@@ -822,18 +839,18 @@
 
         try {
             switch (func.which_) {
-            case OpSet (ptr): {
+
+            case OpSet (cptr):
                 str = arg_ptr;
                 break;
-            }
-            case OpSet (str): {
+
+            case OpSet (cstr):
                 str = arg_str;
                 break;
-            }
-            case OpSet (val): {
+
+            case OpSet (val):
                 str = arg_val;
                 break;
-            }
 
             default:
                 RW_ASSERT (!"logic error: unknown operator= overload");
@@ -951,10 +968,10 @@
 
 template <class charT, class Traits, class Allocator>
 void test_cons (charT, Traits*, Allocator*,
-                const Function &func,
-                const TestCase &tcase)
+                const StringFunc     &func,
+                const StringTestCase &tcase)
 {
-    if (OpSet(ptr) <= func.which_)
+    if (StringIds::fid_op_set == (func.which_ & StringIds::fid_mask))
         test_op_set (charT (), (Traits*)0, (Allocator*)0, func, tcase);
     else
         test_ctor (charT (), (Traits*)0, (Allocator*)0, func, tcase);
@@ -966,39 +983,40 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::ctor_ ## tag, tag ## _test_cases,        \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        Ctor (sig), sig ## _test_cases,                         \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
         TEST (void),
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (str_size),
-        TEST (str_size_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cstr_size),
+        TEST (cstr_size_size),
         TEST (size_val),
         TEST (range),
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::tag, tag ## _test_cases,                 \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                             \
+        OpSet (sig), sig ## _op_set_test_cases, \
+          sizeof sig ## _op_set_test_cases      \
+        / sizeof *sig ## _op_set_test_cases     \
     }
 
-        TEST (op_set_ptr),
-        TEST (op_set_str),
-        TEST (op_set_val)
+        TEST (cptr),
+        TEST (cstr),
+        TEST (val)
 
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.cons",
-                                    test_cons, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.cons",
+                               test_cons, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.copy.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.copy.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.copy.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.copy.cpp Wed May 24 18:31:01 2006
@@ -37,11 +37,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define Copy(which)               StringMembers::copy_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define Copy(which)               StringIds::copy_ ## which
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -52,7 +48,7 @@
 
 // exercises:
 // copy (value_type*, size_type)
-static const TestCase
+static const StringTestCase
 ptr_size_test_cases [] = {
 
 #undef TEST
@@ -96,7 +92,7 @@
 
 // exercises:
 // copy (value_type*, size_type, size_type)
-static const TestCase
+static const StringTestCase
 ptr_size_size_test_cases [] = {
 
 #undef TEST
@@ -160,8 +156,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_copy (charT, Traits*, Allocator*,                
-                const Function &func,
-                const TestCase &tcase)
+                const StringFunc     &func,
+                const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -304,14 +300,13 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::copy_ ## tag,                            \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(which) {                                               \
+        Copy (which), which ## _test_cases,                         \
+        sizeof which ## _test_cases / sizeof *which ## _test_cases  \
     }
 
         TEST (ptr_size),
@@ -320,7 +315,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.copy",
-                                    test_copy, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.copy",
+                               test_copy, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.erase.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.erase.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.erase.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.erase.cpp Wed May 24 18:31:01 2006
@@ -26,7 +26,7 @@
  **************************************************************************/
 
 #include <string>           // for string
-#include <cstdlib>          // for free(), size_t
+#include <cstddef>          // for ptrdiff_t, size_t
 #include <stdexcept>        // for out_of_range
 
 #include <21.strings.h>     // for StringMembers
@@ -38,10 +38,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define Erase(which)              StringMembers::erase_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define Erase(sig)                StringIds::erase_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -52,7 +49,8 @@
 
 // used to exercise
 // erase ()
-static const TestCase void_test_cases [] = {
+static const StringTestCase
+void_test_cases [] = {
 
 #undef TEST
 #define TEST(str, res) {                                                \
@@ -82,7 +80,8 @@
 
 // used to exercise
 // erase (size_type)
-static const TestCase size_test_cases [] = {
+static const StringTestCase
+size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, res, bthrow) {                                    \
@@ -144,7 +143,8 @@
 // used to exercise
 // erase (size_type, size_type)
 // erase (iterator, iterator)
-static const TestCase size_size_test_cases [] = {
+static const StringTestCase
+size_size_test_cases [] = {
 
 // size_size_test_cases serves a double duty
 #define iter_iter_test_cases size_size_test_cases
@@ -229,7 +229,8 @@
 
 // used to exercise
 // erase (iterator)
-static const TestCase iter_test_cases [] = {
+static const StringTestCase
+iter_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, res) {                                      \
@@ -278,14 +279,16 @@
 
 template <class charT, class Traits, class Allocator>
 void test_erase (charT, Traits*, Allocator*,
-                 const Function &func,
-                 const TestCase &tcase)
+                 const StringFunc     &func,
+                 const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename String::iterator                    StringIter;
     typedef typename String::const_iterator              ConstStringIter;
 
-    const bool use_iters = Erase (iter) <= func.which_;
+    const bool use_iters =
+        StringIds::arg_iter == StringIds::arg_type (func.which_, 1);
+
     if (use_iters && tcase.bthrow)
         return;
 
@@ -308,7 +311,7 @@
 
     // construct the string object to be modified
     // and the (possibly unused) argument string
-    /* const */ String  s_str (wstr, str_len);
+    String str (wstr, str_len);
 
     if (wstr != wstr_buf)
         delete[] wstr;
@@ -318,10 +321,9 @@
     // save the state of the string object before the call
     // to detect wxception safety violations (changes to
     // the state of the object after an exception)
-    const StringState str_state (rw_get_string_state (s_str));
+    const StringState str_state (rw_get_string_state (str));
 
-    std::size_t res_off = 0;
-    StringIter res_iter = s_str.begin ();
+    StringIter res_iter = str.begin ();
 
     // compute the offset and the extent (the number of elements)
     // of the first range into the string object being modified
@@ -333,7 +335,7 @@
 
     // create a pair of iterators into the string object being
     // modified (used only by the iterator overloads)
-    const StringIter it_first (s_str.begin () + off1);
+    const StringIter it_first (str.begin () + off1);
     const StringIter it_last  (it_first + ext1);
 
 #ifndef _RWSTD_NO_EXCEPTIONS
@@ -356,51 +358,43 @@
 
 #endif   // _RWSTD_NO_EXCEPTIONS
 
+    // pointer to the returned reference
+    const String* ret_ptr = 0;
+
     try {
         switch (func.which_) {
-        case Erase (void): {
-            const String& s_res = s_str.erase ();
-            res_off = &s_res - &s_str;
+
+        case Erase (void):
+            ret_ptr = &str.erase ();
             break;
-        }
-        case Erase (size): {
-            const String& s_res = s_str.erase (tcase.off);
-            res_off = &s_res - &s_str;
+
+        case Erase (size):
+            ret_ptr = &str.erase (tcase.off);
             break;
-        }
 
-        case Erase (size_size): {
-            const String& s_res = s_str.erase (tcase.off, tcase.size);
-            res_off = &s_res - &s_str;
+        case Erase (size_size):
+            ret_ptr = &str.erase (tcase.off, tcase.size);
             break;
-        }
 
-        case Erase (iter): {
-            res_iter = s_str.erase (it_first);
+        case Erase (iter):
+            res_iter = str.erase (it_first);
             break;
-        }
 
-           case Erase (iter_iter): {
-            res_iter = s_str.erase (it_first, it_last);
+        case Erase (iter_iter):
+            res_iter = str.erase (it_first, it_last);
             break;
-        }
 
         default:
-            RW_ASSERT ("test logic error: unknown erase overload");
+            RW_ASSERT (!"test logic error: unknown erase overload");
             return;
         }
 
         // verify the returned value
-        if (!use_iters) {
-            rw_assert (0 == res_off, 0, tcase.line,
-                       "line %d. %{$FUNCALL} returned invalid reference, "
-                       "offset is %zu", __LINE__, res_off);
-        }
-        else {
-            const ConstStringIter begin = s_str.begin ();
-            const ConstStringIter end   = s_str.end ();
+        if (use_iters) {
+            const ConstStringIter begin = str.begin ();
+            const ConstStringIter end   = str.end ();
 
-            bool success = begin <= res_iter && res_iter <= end;
+            const bool success = begin <= res_iter && res_iter <= end;
             rw_assert (success, 0, tcase.line,
                        "line %d. %{$FUNCALL} returned invalid iterator, "
                        "difference with begin is %td",
@@ -413,33 +407,45 @@
             else {
                 const std::size_t match =
                     rw_match (nres + tcase.off, &(*res_iter), 1);
+
                 rw_assert (1 == match, 0, tcase.line,
-                    "line %d. %{$FUNCALL} == %{#c}, got %{#c}",
+                           "line %d. %{$FUNCALL} == %{#c}, got %{#c}",
                            __LINE__, nres[tcase.off], *res_iter);
             }
         }
+        else {
+            // verify that the reference returned from the function
+            // refers to the modified string object (i.e., *this
+            // within the function)
+            const std::ptrdiff_t ret_off = ret_ptr - &str;
+
+            // verify the returned value
+            rw_assert (0 == ret_off, 0, tcase.line,
+                       "line %d. %{$FUNCALL} returned invalid reference, "
+                       "offset is %td", __LINE__, ret_off);
+        }
 
         // verfiy that strings length are equal
-        rw_assert (res_len == s_str.size (), 0, tcase.line,
+        rw_assert (res_len == str.size (), 0, tcase.line,
                    "line %d. %{$FUNCALL} expected %{#*s} with length "
                    "%zu, got %{/*.*Gs} with length %zu",
                    __LINE__, int (tcase.nres), tcase.res,
                    res_len, int (sizeof (charT)),
-                   int (s_str.size ()), s_str.c_str (), s_str.size ());
+                   int (str.size ()), str.c_str (), str.size ());
 
-        if (res_len == s_str.size ()) {
+        if (res_len == str.size ()) {
             // if the result length matches the expected length
             // (and only then), also verify that the modified
             // string matches the expected result
             const std::size_t match =
-                rw_match (tcase.res, s_str.c_str(), tcase.nres);
+                rw_match (tcase.res, str.c_str(), tcase.nres);
 
             rw_assert (match == res_len, 0, tcase.line,
                        "line %d. %{$FUNCALL} expected %{#*s}, "
                        "got %{/*.*Gs}, difference at offset %zu",
                        __LINE__, int (tcase.nres), tcase.res,
-                       int (sizeof (charT)), int (s_str.size ()),
-                       s_str.c_str (), match);
+                       int (sizeof (charT)), int (str.size ()),
+                       str.c_str (), match);
         }
     }
 
@@ -472,7 +478,7 @@
     if (caught) {
         // verify that an exception thrown during allocation
         // didn't cause a change in the state of the object
-        str_state.assert_equal (rw_get_string_state (s_str),
+        str_state.assert_equal (rw_get_string_state (str),
                                 __LINE__, tcase.line, caught);
     }
 
@@ -489,13 +495,13 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::erase_ ## tag, tag ## _test_cases,       \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        Erase (sig), sig ## _test_cases,                        \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
         TEST (void),
@@ -507,7 +513,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.erase",
-                                    test_erase, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.erase",
+                               test_erase, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.find.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.find.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.cpp Wed May 24 18:31:01 2006
@@ -37,11 +37,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define Find(which)               StringMembers::find_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define Find(sig)                 StringIds::find_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -52,8 +48,8 @@
 
 // exercises:
 // find (const value_type*)
-static const TestCase
-ptr_test_cases [] = {
+static const StringTestCase
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res) {                   \
@@ -132,8 +128,8 @@
 
 // exercises:
 // find (const basic_string&)
-static const TestCase
-str_test_cases [] = {
+static const StringTestCase
+cstr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res) {                   \
@@ -217,8 +213,8 @@
 
 // exercises:
 // find (const value_type*, size_type)
-static const TestCase
-ptr_size_test_cases [] = {
+static const StringTestCase
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res) {              \
@@ -317,8 +313,8 @@
 
 // exercises:
 // find (const value_type*, size_type, size_type)
-static const TestCase
-ptr_size_size_test_cases [] = {
+static const StringTestCase
+cptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res) {        \
@@ -445,8 +441,8 @@
 
 // exercises:
 // find (const basic_string&, size_type)
-static const TestCase
-str_size_test_cases [] = {
+static const StringTestCase
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res) {              \
@@ -542,7 +538,7 @@
 
 // exercises:
 // find (value_type)
-static const TestCase
+static const StringTestCase
 val_test_cases [] = {
 
 #undef TEST
@@ -584,7 +580,7 @@
 
 // exercises:
 // find (value_type, size_type)
-static const TestCase
+static const StringTestCase
 val_size_test_cases [] = {
 
 #undef TEST
@@ -639,8 +635,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_find (charT, Traits*, Allocator*,
-                const Function &func,
-                const TestCase &tcase)
+                const StringFunc     &func,
+                const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -673,9 +669,6 @@
     // the state of the object after an exception)
     const StringState str_state (rw_get_string_state (s_str));
 
-    std::size_t res = 0;
-    std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos;
-
     // string function argument
     const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
     const String&      arg_str = tcase.arg ? s_arg : s_str;
@@ -697,47 +690,46 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     try {
+        std::size_t res = 0;
+
         switch (func.which_) {
-        case Find (ptr): {
+
+        case Find (cptr):
             res = s_str.find (arg_ptr);
             break;
-        }
 
-        case Find (str): {
+        case Find (cstr):
             res = s_str.find (arg_str);
             break;
-        }
 
-        case Find (ptr_size): {
+        case Find (cptr_size):
             res = s_str.find (arg_ptr, tcase.off);
             break;
-        }
 
-        case Find (ptr_size_size): {
+        case Find (cptr_size_size):
             res = s_str.find (arg_ptr, tcase.off, size);
             break;
-        }
 
-        case Find (str_size): {
+        case Find (cstr_size):
             res = s_str.find (arg_str, tcase.off);
             break;
-        }
 
-        case Find (val): {
+        case Find (val):
             res = s_str.find (arg_val);
             break;
-        }
 
-        case Find (val_size): {
+        case Find (val_size):
             res = s_str.find (arg_val, tcase.off);
             break;
-        }
 
         default:
             RW_ASSERT (!"logic error: unknown find overload");
             return;
         }
 
+        const std::size_t exp_res =
+            NPOS != tcase.nres ? tcase.nres : String::npos;
+
         // verify the returned value
         rw_assert (exp_res == res, 0, tcase.line,
                    "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, "
@@ -785,28 +777,27 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::find_ ## tag,                            \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        Find (sig), sig ## _test_cases,                         \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (ptr_size_size),
-        TEST (str_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cptr_size_size),
+        TEST (cstr_size),
         TEST (val),
         TEST (val_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.find",
-                                    test_find, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.find",
+                               test_find, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.first.not.of.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.find.first.not.of.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.find.first.not.of.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.first.not.of.cpp Wed May 24 18:31:01 2006
@@ -38,11 +38,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define FindFirstNotOf(which)     StringMembers::find_first_not_of_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define FindFirstNotOf(sig)       StringIds::find_first_not_of_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -53,8 +49,8 @@
 
 // used to exercise 
 // find_first_not_of (const value_type*)
-static const TestCase 
-ptr_test_cases [] = {
+static const StringTestCase 
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                 \
@@ -124,8 +120,8 @@
 
 // used to exercise 
 // find_first_not_of (const basic_string&)
-static const TestCase 
-str_test_cases [] = {
+static const StringTestCase 
+cstr_test_cases [] = {
 
 #undef TEST     
 #define TEST(str, arg, res)                 \
@@ -198,8 +194,8 @@
 
 // used to exercise 
 // find_first_not_of (const value_type*, size_type)
-static const TestCase 
-ptr_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -289,8 +285,8 @@
 
 // used to exercise 
 // find_first_not_of (const value_type*, size_type, size_type)
-static const TestCase 
-ptr_size_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res, bthrow)      \
@@ -417,8 +413,8 @@
 
 // used to exercise 
 // find_first_not_of (const basic_string&, size_type)
-static const TestCase 
-str_size_test_cases [] = {
+static const StringTestCase 
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -511,7 +507,7 @@
 
 // used to exercise 
 // find_first_not_of (value_type)
-static const TestCase 
+static const StringTestCase 
 val_test_cases [] = {
 
 #undef TEST
@@ -554,7 +550,7 @@
 
 // used to exercise 
 // find_first_not_of (value_type, size_type)
-static const TestCase 
+static const StringTestCase 
 val_size_test_cases [] = {
 
 #undef TEST
@@ -608,8 +604,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_find_first_not_of (charT, Traits*, Allocator*,  
-                             const Function &func,
-                             const TestCase &tcase)
+                             const StringFunc     &func,
+                             const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -642,9 +638,6 @@
     // the state of the object after an exception)
     const StringState str_state (rw_get_string_state (s_str));
 
-    std::size_t res = 0;
-    std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos;
-
     const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
     const String&      arg_str = tcase.arg ? s_arg : s_str;
     const charT        arg_val = make_char (char (tcase.val), (charT*)0);
@@ -668,47 +661,46 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     try {
-    switch (func.which_) {
-        case FindFirstNotOf (ptr): {
+
+        std::size_t res = 0;
+
+        switch (func.which_) {
+        case FindFirstNotOf (cptr):
             res = s_str.find_first_not_of (arg_ptr);
             break;
-        }
 
-        case FindFirstNotOf (str): {
+        case FindFirstNotOf (cstr):
             res = s_str.find_first_not_of (arg_str);
             break;
-        }
 
-        case FindFirstNotOf (ptr_size): {
+        case FindFirstNotOf (cptr_size):
             res = s_str.find_first_not_of (arg_ptr, tcase.off);
             break;
-        }
 
-        case FindFirstNotOf (ptr_size_size): {
+        case FindFirstNotOf (cptr_size_size):
             res = s_str.find_first_not_of (arg_ptr, tcase.off, size);
             break;
-        }
 
-        case FindFirstNotOf (str_size): {
+        case FindFirstNotOf (cstr_size):
             res = s_str.find_first_not_of (arg_str, tcase.off);
             break;
-        }
 
-        case FindFirstNotOf (val): {
+        case FindFirstNotOf (val):
             res = s_str.find_first_not_of (arg_val);
             break;
-        }
 
-        case FindFirstNotOf (val_size): {
+        case FindFirstNotOf (val_size):
             res = s_str.find_first_not_of (arg_val, tcase.off);
             break;
-        }
 
         default:
             RW_ASSERT ("test logic error: unknown find_first_not_of overload");
             return;
         }
 
+        const std::size_t exp_res =
+            NPOS != tcase.nres ? tcase.nres : String::npos;
+
         // verify the returned value
         rw_assert (exp_res == res, 0, tcase.line,
                    "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, "
@@ -763,28 +755,27 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::find_first_not_of_ ## tag,               \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        FindFirstNotOf (sig), sig ## _test_cases,               \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (ptr_size_size),
-        TEST (str_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cptr_size_size),
+        TEST (cstr_size),
         TEST (val),
         TEST (val_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.find.first.not.of",
-                                    test_find_first_not_of, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.find.first.not.of",
+                               test_find_first_not_of, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.first.of.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.find.first.of.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.find.first.of.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.first.of.cpp Wed May 24 18:31:01 2006
@@ -38,11 +38,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define FindFirstOf(which)        StringMembers::find_first_of_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define FindFirstOf(sig)          StringIds::find_first_of_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -53,8 +49,8 @@
 
 // used to exercise 
 // find_first_of (const value_type*)
-static const TestCase 
-ptr_test_cases [] = {
+static const StringTestCase 
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                 \
@@ -129,8 +125,8 @@
 
 // used to exercise 
 // find_first_of (const basic_string&)
-static const TestCase 
-str_test_cases [] = {
+static const StringTestCase 
+cstr_test_cases [] = {
 
 #undef TEST     
 #define TEST(str, arg, res)                 \
@@ -208,8 +204,8 @@
 
 // used to exercise 
 // find_first_of (const value_type*, size_type)
-static const TestCase 
-ptr_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -303,8 +299,8 @@
 
 // used to exercise 
 // find_first_of (const value_type*, size_type, size_type)
-static const TestCase 
-ptr_size_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res, bthrow)      \
@@ -420,8 +416,8 @@
 
 // used to exercise 
 // find_first_of (const basic_string&, size_type)
-static const TestCase 
-str_size_test_cases [] = {
+static const StringTestCase 
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -518,7 +514,7 @@
 
 // used to exercise 
 // find_first_of (value_type)
-static const TestCase 
+static const StringTestCase 
 val_test_cases [] = {
 
 #undef TEST
@@ -562,7 +558,7 @@
 
 // used to exercise 
 // find_first_of (value_type, size_type)
-static const TestCase 
+static const StringTestCase 
 val_size_test_cases [] = {
 
 #undef TEST
@@ -618,8 +614,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_find_first_of (charT, Traits*, Allocator*,  
-                         const Function &func,
-                         const TestCase &tcase)
+                         const StringFunc    &func,
+                         const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -652,9 +648,6 @@
     // the state of the object after an exception)
     const StringState str_state (rw_get_string_state (s_str));
 
-    std::size_t res = 0;
-    std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos;
-
     const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
     const String&      arg_str = tcase.arg ? s_arg : s_str;
     const charT        arg_val = make_char (char (tcase.val), (charT*)0);
@@ -678,47 +671,46 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     try {
+        std::size_t res = 0;
+
         switch (func.which_) {
-        case FindFirstOf (ptr): {
+
+        case FindFirstOf (cptr):
             res = s_str.find_first_of (arg_ptr);
             break;
-        }
 
-        case FindFirstOf (str): {
+        case FindFirstOf (cstr):
             res = s_str.find_first_of (arg_str);
             break;
-        }
 
-        case FindFirstOf (ptr_size): {
+        case FindFirstOf (cptr_size):
             res = s_str.find_first_of (arg_ptr, tcase.off);
             break;
-        }
 
-        case FindFirstOf (ptr_size_size): {
+        case FindFirstOf (cptr_size_size):
             res = s_str.find_first_of (arg_ptr, tcase.off, size);
             break;
-        }
 
-        case FindFirstOf (str_size): {
+        case FindFirstOf (cstr_size):
             res = s_str.find_first_of (arg_str, tcase.off);
             break;
-        }
 
-        case FindFirstOf (val): {
+        case FindFirstOf (val):
             res = s_str.find_first_of (arg_val);
             break;
-        }
 
-        case FindFirstOf (val_size): {
+        case FindFirstOf (val_size):
             res = s_str.find_first_of (arg_val, tcase.off);
             break;
-        }
 
         default:
             RW_ASSERT ("test logic error: unknown find_first_of overload");
             return;
         }
 
+        const std::size_t exp_res =
+            NPOS != tcase.nres ? tcase.nres : String::npos;
+
         // verify the returned value
         rw_assert (exp_res == res, 0, tcase.line,
                    "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, "
@@ -773,28 +765,27 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::find_first_of_ ## tag,                   \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        FindFirstOf (sig), sig ## _test_cases,                  \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (ptr_size_size),
-        TEST (str_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cptr_size_size),
+        TEST (cstr_size),
         TEST (val),
         TEST (val_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.find.first.of",
-                                    test_find_first_of, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.find.first.of",
+                               test_find_first_of, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.last.not.of.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.find.last.not.of.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.find.last.not.of.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.last.not.of.cpp Wed May 24 18:31:01 2006
@@ -38,11 +38,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define FindLastNotOf(which)      StringMembers::find_last_not_of_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define FindLastNotOf(sig)        StringIds::find_last_not_of_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -53,8 +49,8 @@
 
 // used to exercise 
 // find_last_not_of (const value_type*)
-static const TestCase 
-ptr_test_cases [] = {
+static const StringTestCase 
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                 \
@@ -125,8 +121,8 @@
 
 // used to exercise 
 // find_last_not_of (const basic_string&)
-static const TestCase 
-str_test_cases [] = {
+static const StringTestCase 
+cstr_test_cases [] = {
 
 #undef TEST     
 #define TEST(str, arg, res)                 \
@@ -199,8 +195,8 @@
 
 // used to exercise 
 // find_last_not_of (const value_type*, size_type)
-static const TestCase 
-ptr_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -297,8 +293,8 @@
 
 // used to exercise 
 // find_last_not_of (const value_type*, size_type, size_type)
-static const TestCase 
-ptr_size_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res, bthrow)      \
@@ -420,8 +416,8 @@
 
 // used to exercise 
 // find_last_not_of (const basic_string&, size_type)
-static const TestCase 
-str_size_test_cases [] = {
+static const StringTestCase 
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -520,7 +516,7 @@
 
 // used to exercise 
 // find_last_not_of (value_type)
-static const TestCase 
+static const StringTestCase 
 val_test_cases [] = {
 
 #undef TEST
@@ -566,7 +562,7 @@
 
 // used to exercise 
 // find_last_not_of (value_type, size_type)
-static const TestCase 
+static const StringTestCase 
 val_size_test_cases [] = {
 
 #undef TEST
@@ -620,8 +616,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_find_last_not_of (charT, Traits*, Allocator*,
-                            const Function &func,
-                            const TestCase &tcase)
+                            const StringFunc     &func,
+                            const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -654,9 +650,6 @@
     // the state of the object after an exception)
     const StringState str_state (rw_get_string_state (s_str));
 
-    std::size_t res = 0;
-    std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos;
-
     const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
     const String&      arg_str = tcase.arg ? s_arg : s_str;
     const charT        arg_val = make_char (char (tcase.val), (charT*)0);
@@ -680,47 +673,46 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     try {
-    switch (func.which_) {
-        case FindLastNotOf (ptr): {
+        std::size_t res = 0;
+
+        switch (func.which_) {
+
+        case FindLastNotOf (cptr):
             res = s_str.find_last_not_of (arg_ptr);
             break;
-        }
 
-        case FindLastNotOf (str): {
+        case FindLastNotOf (cstr):
             res = s_str.find_last_not_of (arg_str);
             break;
-        }
 
-        case FindLastNotOf (ptr_size): {
+        case FindLastNotOf (cptr_size):
             res = s_str.find_last_not_of (arg_ptr, tcase.off);
             break;
-        }
 
-        case FindLastNotOf (ptr_size_size): {
+        case FindLastNotOf (cptr_size_size):
             res = s_str.find_last_not_of (arg_ptr, tcase.off, size);
             break;
-        }
 
-        case FindLastNotOf (str_size): {
+        case FindLastNotOf (cstr_size):
             res = s_str.find_last_not_of (arg_str, tcase.off);
             break;
-        }
 
-        case FindLastNotOf (val): {
+        case FindLastNotOf (val):
             res = s_str.find_last_not_of (arg_val);
             break;
-        }
 
-        case FindLastNotOf (val_size): {
+        case FindLastNotOf (val_size):
             res = s_str.find_last_not_of (arg_val, tcase.off);
             break;
-        }
 
         default:
             RW_ASSERT ("test logic error: unknown find_last_not_of overload");
             return;
         }
 
+        const std::size_t exp_res =
+            NPOS != tcase.nres ? tcase.nres : String::npos;
+
         // verify the returned value
         rw_assert (exp_res == res, 0, tcase.line,
                    "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, "
@@ -775,29 +767,27 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::find_last_not_of_ ## tag,                \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        FindLastNotOf (sig), sig ## _test_cases,                \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (ptr_size_size),
-        TEST (str_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cptr_size_size),
+        TEST (cstr_size),
         TEST (val),
         TEST (val_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.find.last.not.of",
-                                    test_find_last_not_of, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.find.last.not.of",
+                               test_find_last_not_of, tests, test_count);
 }
-

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.last.of.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.find.last.of.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.find.last.of.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.last.of.cpp Wed May 24 18:31:01 2006
@@ -26,10 +26,10 @@
  **************************************************************************/
 
 #include <string>           // for string
-#include <cstdlib>          // for free(), size_t
+#include <cstddef>          // for size_t
 #include <stdexcept>        // for length_error
 
-#include <21.strings.h>     // for StringMembers
+#include <21.strings.h>     // for StringIds
 #include <driver.h>         // for rw_test()
 #include <rw_allocator.h>   // for UserAlloc
 #include <rw_char.h>        // for rw_expand()
@@ -37,11 +37,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define NPOS                      _RWSTD_SIZE_MAX
-#define FindLastOf(which)         StringMembers::find_last_of_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define FindLastOf(sig)   StringIds::find_last_of_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -52,8 +48,8 @@
 
 // used to exercise 
 // find_last_of (const value_type*)
-static const TestCase 
-ptr_test_cases [] = {
+static const StringTestCase 
+cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                 \
@@ -129,8 +125,8 @@
 
 // used to exercise 
 // find_last_of (const basic_string&)
-static const TestCase 
-str_test_cases [] = {
+static const StringTestCase 
+cstr_test_cases [] = {
 
 #undef TEST     
 #define TEST(str, arg, res)                 \
@@ -207,8 +203,8 @@
 
 // used to exercise 
 // find_last_of (const value_type*, size_type)
-static const TestCase 
-ptr_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -309,8 +305,8 @@
 
 // used to exercise 
 // find_last_of (const value_type*, size_type, size_type)
-static const TestCase 
-ptr_size_size_test_cases [] = {
+static const StringTestCase 
+cptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res, bthrow)      \
@@ -430,8 +426,8 @@
 
 // used to exercise 
 // find_last_of (const basic_string&, size_type)
-static const TestCase 
-str_size_test_cases [] = {
+static const StringTestCase 
+cstr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)            \
@@ -532,7 +528,7 @@
 
 // used to exercise 
 // find_last_of (value_type)
-static const TestCase 
+static const StringTestCase 
 val_test_cases [] = {
 
 #undef TEST
@@ -576,7 +572,7 @@
 
 // used to exercise 
 // find_last_of (value_type, size_type)
-static const TestCase 
+static const StringTestCase 
 val_size_test_cases [] = {
 
 #undef TEST
@@ -633,8 +629,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_find_last_of (charT, Traits*, Allocator*,  
-                        const Function &func,
-                        const TestCase &tcase)
+                        const StringFunc     &func,
+                        const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
 
@@ -650,8 +646,8 @@
     charT* warg = rw_expand (warg_buf, tcase.arg, tcase.arg_len, &arg_len);
 
     // construct the string object and the argument string
-    const String  s_str (wstr, str_len);
-    const String  s_arg (warg, arg_len);
+    const String s_str (wstr, str_len);
+    const String s_arg (warg, arg_len);
 
     if (wstr != wstr_buf)
         delete[] wstr;
@@ -667,9 +663,6 @@
     // the state of the object after an exception)
     const StringState str_state (rw_get_string_state (s_str));
 
-    std::size_t res = 0;
-    std::size_t exp_res = NPOS != tcase.nres ? tcase.nres : String::npos;
-
     const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
     const String&      arg_str = tcase.arg ? s_arg : s_str;
     const charT        arg_val = make_char (char (tcase.val), (charT*)0);
@@ -693,28 +686,31 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     try {
-    switch (func.which_) {
-        case FindLastOf (ptr): {
+
+        std::size_t res = 0;
+
+        switch (func.which_) {
+
+        case FindLastOf (cptr):
             res = s_str.find_last_of (arg_ptr);
             break;
-        }
 
-        case FindLastOf (str): {
+        case FindLastOf (cstr): {
             res = s_str.find_last_of (arg_str);
             break;
         }
 
-        case FindLastOf (ptr_size): {
+        case FindLastOf (cptr_size): {
             res = s_str.find_last_of (arg_ptr, tcase.off);
             break;
         }
 
-        case FindLastOf (ptr_size_size): {
+        case FindLastOf (cptr_size_size): {
             res = s_str.find_last_of (arg_ptr, tcase.off, size);
             break;
         }
 
-        case FindLastOf (str_size): {
+        case FindLastOf (cstr_size): {
             res = s_str.find_last_of (arg_str, tcase.off);
             break;
         }
@@ -734,6 +730,9 @@
             return;
         }
 
+        std::size_t exp_res =
+            NPOS != tcase.nres ? tcase.nres : String::npos;
+
         // verify the returned value
         rw_assert (exp_res == res, 0, tcase.line,
                    "line %d. %{$FUNCALL} == %{?}%zu%{;}%{?}npos%{;}, "
@@ -788,28 +787,27 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::find_last_of_ ## tag,                    \
-        tag ## _test_cases,                                     \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        FindLastOf (sig), sig ## _test_cases,                   \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (ptr),
-        TEST (str),
-        TEST (ptr_size),
-        TEST (ptr_size_size),
-        TEST (str_size),
+        TEST (cptr),
+        TEST (cstr),
+        TEST (cptr_size),
+        TEST (cptr_size_size),
+        TEST (cstr_size),
         TEST (val),
         TEST (val_size)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.find.last.of",
-                                    test_find_last_of, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.find.last.of",
+                               test_find_last_of, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp?rev=409280&r1=409279&r2=409280&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp Wed May 24 18:31:01 2006
@@ -29,7 +29,7 @@
 #include <stdexcept>      // for out_of_range, length_error
 #include <cstddef>        // for size_t
 
-#include <21.strings.h>   // for StringMembers
+#include <21.strings.h>   // for StringIds
 #include <alg_test.h>     // for InputIter
 #include <driver.h>       // for rw_test()
 #include <rw_allocator.h> // for UserAlloc
@@ -39,10 +39,7 @@
 /**************************************************************************/
 
 // for convenience and brevity
-#define Insert(which)             StringMembers::insert_ ## which
-
-typedef StringMembers::TestCase   TestCase;
-typedef StringMembers::Function   Function;
+#define Insert(sig)   StringIds::insert_ ## sig
 
 static const char* const exceptions[] = {
     "unknown exception", "out_of_range", "length_error",
@@ -53,8 +50,8 @@
 
 // used to exercise
 // insert (size_type, const value_type*)
-static const TestCase
-size_ptr_test_cases [] = {
+static const StringTestCase
+size_cptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, arg, res, bthrow) {                      \
@@ -125,8 +122,8 @@
 
 // used to exercise
 // insert (size_type, const basic_string&)
-static const TestCase
-size_str_test_cases [] = {
+static const StringTestCase
+size_cstr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, arg, res, bthrow) {                      \
@@ -197,11 +194,11 @@
 // exrcises
 // insert (size_type, basic_string&, size_type, size_type)
 // insert (iterator, InputIterator, InputIterator)
-static const TestCase
-range_test_cases [] = {
+static const StringTestCase
+iter_range_test_cases [] = {
 
 // range_test_cases serves a double duty
-#define size_str_size_size_test_cases range_test_cases
+#define size_cstr_size_size_test_cases iter_range_test_cases
 
 #undef TEST
 #define TEST(str, off, arg, off2, size2, res, bthrow) {                 \
@@ -291,8 +288,8 @@
 
 // used to exercise
 // insert (size_type, const value_type*, size_type)
-static const TestCase
-size_ptr_size_test_cases [] = {
+static const StringTestCase
+size_cptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, arg, size2, res, bthrow) {               \
@@ -370,11 +367,11 @@
 // exrecises
 // insert (size_type, size_type, value_type)
 // insert (iterator, size_type, value_type)
-static const TestCase
-size_val_test_cases [] = {
+static const StringTestCase
+iter_size_val_test_cases [] = {
 
 // size_val_test_cases serves a double duty
-#define size_size_val_test_cases size_val_test_cases
+#define size_size_val_test_cases iter_size_val_test_cases
 
 #undef TEST
 #define TEST(str, off, size2, val, res, bthrow) {               \
@@ -444,8 +441,8 @@
 
 // used to exercise
 // insert (iterator, value_type)
-static const TestCase
-val_test_cases [] = {
+static const StringTestCase
+iter_val_test_cases [] = {
 
 #undef TEST
 #define TEST(str, off, val, res, bthrow)                                \
@@ -503,7 +500,7 @@
                         Traits*,
                         Allocator*, 
                         const Iterator &it,
-                        const TestCase &tcase)
+                        const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename String::iterator                    StringIter;
@@ -518,7 +515,7 @@
     const std::size_t size2 = tcase.arg ? warg_len : size1;
 
     // construct the string object to be modified
-    String s_str (wstr, size1);
+    String str (wstr, size1);
 
     // compute the offset and the extent (the number of elements)
     // of the first range into the string object being modified
@@ -533,7 +530,7 @@
         off2 + tcase.size2 < size2 ? std::size_t (tcase.size2) : size2 - off2;
 
     // create an iterator into the string object being modified
-    StringIter iter (s_str.begin () + off1);
+    StringIter iter (str.begin () + off1);
 
     if (tcase.arg) {
         const charT* const beg = warg + off2;
@@ -542,25 +539,25 @@
         const Iterator first (beg, beg, end);
         const Iterator last  (end, beg, end);
 
-        s_str.insert (iter, first, last);
+        str.insert (iter, first, last);
     }
     else {
         // self-referential modification (inserting a range
         // of elements with a subrange of its own elements)
-        const StringIter first (s_str.begin () + off2);
+        const StringIter first (str.begin () + off2);
         const StringIter last (first + ext2);
 
-        s_str.insert (iter, first, last);
+        str.insert (iter, first, last);
     }
 
     // detrmine whether the produced sequence matches the exepceted result
-    const std::size_t match = rw_match (tcase.res, s_str.data (), tcase.nres);
+    const std::size_t match = rw_match (tcase.res, str.data (), tcase.nres);
 
     rw_assert (match == res_len, 0, tcase.line,
                "line %d. %{$FUNCALL} expected %{#*s}, got %{/*.*Gs}, "
                "difference at pos %zu for %s",
                __LINE__, int (tcase.nres), tcase.res,
-               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (),
+               int (sizeof (charT)), int (str.size ()), str.c_str (),
                match, itname);
 }
 
@@ -574,7 +571,7 @@
                         std::size_t     res_len,
                         Traits*,
                         Allocator*,
-                        const TestCase &tcase)
+                        const StringTestCase &tcase)
 {
     if (tcase.bthrow)  // this method doesn't throw
         return;
@@ -602,8 +599,8 @@
 
 template <class charT, class Traits, class Allocator>
 void test_insert (charT, Traits*, Allocator*,
-                  const Function &func,
-                  const TestCase &tcase)
+                  const StringFunc     &func,
+                  const StringTestCase &tcase)
 {
     typedef std::basic_string <charT, Traits, Allocator> String;
     typedef typename String::iterator                    StringIter;
@@ -625,7 +622,7 @@
     charT* wres = rw_expand (wres_buf, tcase.res, tcase.nres, &res_len);
 
     // special processing for insert_range to exercise all iterators
-    if (Insert (range) == func.which_) {
+    if (Insert (iter_range) == func.which_) {
         test_insert_range (wstr, str_len, warg, arg_len, 
                            res_len, (Traits*)0, (Allocator*)0, tcase);
         if (wstr != wstr_buf)
@@ -640,8 +637,8 @@
         return;
     }
 
-    /* const */ String s_str (wstr, str_len);
-    const       String s_arg (warg, arg_len);
+    /* const */ String str (wstr, str_len);
+    const       String arg (warg, arg_len);
 
     if (wstr != wstr_buf)
         delete[] wstr;
@@ -655,10 +652,9 @@
     // save the state of the string object before the call
     // to detect wxception safety violations (changes to
     // the state of the object after an exception)
-    const StringState str_state (rw_get_string_state (s_str));
+    const StringState str_state (rw_get_string_state (str));
 
-    std::size_t res_off = 0;
-    std::size_t exp_off = Insert (val) == func.which_ ? tcase.off : 0;
+    std::ptrdiff_t exp_off = Insert (iter_val) == func.which_ ? tcase.off : 0;
 
     // compute the offset and the extent (the number of elements)
     // of the first range into the string object being modified
@@ -666,8 +662,8 @@
     const std::size_t off1 =
         std::size_t (tcase.off) < size1 ? std::size_t (tcase.off) : size1;
 
-    const charT* const arg_ptr = tcase.arg ? s_arg.c_str () : s_str.c_str ();
-    const String&      arg_str = tcase.arg ? s_arg : s_str;
+    const charT* const arg_ptr = tcase.arg ? arg.c_str () : str.c_str ();
+    const String&      arg_str = tcase.arg ? arg : str;
     const charT        arg_val = make_char (char (tcase.val), (charT*)0);
 
     std::size_t total_length_calls = 0;
@@ -691,12 +687,13 @@
 
 #ifndef _RWSTD_NO_EXCEPTIONS
 
-        const bool use_iters = (Insert (val) <= func.which_);
+        const bool use_iters =
+            StringIds::arg_iter == StringIds::arg_type (func.which_, 1);
 
         if (1 == tcase.bthrow && !use_iters)
             expected = exceptions [1];      // out_of_range
         else if (   2 == tcase.bthrow
-                 && Insert (size_str_size_size) == func.which_)
+                 && Insert (size_cstr_size_size) == func.which_)
             expected = exceptions [1];      // out_of_range
         else if (3 == tcase.bthrow && !use_iters)
             expected = exceptions [2];      // length_error
@@ -707,62 +704,55 @@
 
 #else   // if defined (_RWSTD_NO_EXCEPTIONS)
 
-    if (tcase.bthrow) {
-        if (wres != wres_buf)
-            delete[] wres;
+        if (tcase.bthrow) {
+            if (wres != wres_buf)
+                delete[] wres;
 
-        return;
-    }
+            return;
+        }
 
 #endif   // _RWSTD_NO_EXCEPTIONS
 
+        // pointer to the returned reference
+        const String* ret_ptr = 0;
+
         try {
             switch (func.which_) {
-            case Insert (size_ptr): {
-                const String& s_res = s_str.insert (tcase.off, arg_ptr);
-                res_off = &s_res - &s_str;
+
+            case Insert (size_cptr):
+                ret_ptr = &str.insert (tcase.off, arg_ptr);
                 if (rg_calls)
                     n_length_calls = rg_calls [UTMemFun::length];
                 break;
-            }
 
-            case Insert (size_str): {
-                const String& s_res = s_str.insert (tcase.off, arg_str);
-                res_off = &s_res - &s_str;
+            case Insert (size_cstr):
+                ret_ptr = &str.insert (tcase.off, arg_str);
                 break;
-            }
 
-            case Insert (size_ptr_size): {
-                const String& s_res = 
-                    s_str.insert (tcase.off, arg_ptr, tcase.size2);
-                res_off = &s_res - &s_str;
+            case Insert (size_cptr_size):
+                ret_ptr = &str.insert (tcase.off, arg_ptr, tcase.size2);
                 break;
-            }
 
-            case Insert (size_str_size_size): {
-                const String& s_res = 
-                    s_str.insert (tcase.off, arg_str, tcase.off2, tcase.size2);
-                res_off = &s_res - &s_str;
+            case Insert (size_cstr_size_size):
+                ret_ptr =
+                    &str.insert (tcase.off, arg_str, tcase.off2, tcase.size2);
                 break;
-            }
 
-            case Insert (size_size_val): {
-                const String& s_res = 
-                    s_str.insert (tcase.off, tcase.size2, arg_val);
-                res_off = &s_res - &s_str;
+            case Insert (size_size_val):
+                ret_ptr = &str.insert (tcase.off, tcase.size2, arg_val);
                 break;
-            }
 
-            case Insert (size_val): {
-                StringIter it (s_str.begin () + off1);
-                s_str.insert (it, tcase.size2, arg_val);
+            case Insert (iter_size_val): {
+                const StringIter it (str.begin () + off1);
+                str.insert (it, tcase.size2, arg_val);
+                ret_ptr = &str;   // function returns void
                 break;
             }
 
-            case Insert (val): {
-                StringIter it (s_str.begin () + off1);
-                StringIter res_it = s_str.insert (it, arg_val);
-                res_off = res_it - s_str.begin ();
+            case Insert (iter_val): {
+                StringIter it (str.begin () + off1);
+                it = str.insert (it, arg_val);
+                ret_ptr = &str + (it - str.begin ());
                 break;
             }
 
@@ -771,38 +761,44 @@
                 return;
             }
 
+            // verify that the reference returned from the function
+            // refers to the modified string object (i.e., *this
+            // within the function)
+            const std::ptrdiff_t ret_off = ret_ptr - &str;
+
             // verify the returned value
-            rw_assert (exp_off == res_off, 0, tcase.line,
-                       "line %d. %{$FUNCALL} %{?}== %zu, got %zu%{;}"
-                       "%{?}returned invalid reference, offset is %zu%{;}",
-                       __LINE__, Insert (val) == func.which_, exp_off, res_off,
-                       Insert (val) != func.which_, res_off);
+            rw_assert (exp_off == ret_off, 0, tcase.line,
+                       "line %d. %{$FUNCALL} %{?}== begin() + %td, got %td%{;}"
+                       "%{?}returned invalid reference, offset is %td%{;}",
+                       __LINE__, Insert (iter_val) == func.which_,
+                       exp_off, ret_off,
+                       Insert (iter_val) != func.which_, ret_off);
 
             // verfiy that strings length are equal
-            rw_assert (res_len == s_str.size (), 0, tcase.line,
+            rw_assert (res_len == str.size (), 0, tcase.line,
                        "line %d. %{$FUNCALL} expected %{#*s} with length "
                        "%zu, got %{/*.*Gs} with length %zu", __LINE__, 
                        int (tcase.nres), tcase.res, res_len, 
-                       int (sizeof (charT)), int (s_str.size ()), 
-                       s_str.c_str (), s_str.size ());
+                       int (sizeof (charT)), int (str.size ()), 
+                       str.c_str (), str.size ());
 
-            if (res_len == s_str.size ()) {
+            if (res_len == str.size ()) {
                 // if the result length matches the expected length
                 // (and only then), also verify that the modified
                 // string matches the expected result
                 const std::size_t match =
-                    rw_match (tcase.res, s_str.c_str(), tcase.nres);
+                    rw_match (tcase.res, str.c_str(), tcase.nres);
 
                 rw_assert (match == res_len, 0, tcase.line,
                            "line %d. %{$FUNCALL} expected %{#*s}, "
                            "got %{/*.*Gs}, difference at offset %zu",
                            __LINE__, int (tcase.nres), tcase.res,
-                           int (sizeof (charT)), int (s_str.size ()),
-                           s_str.c_str (), match);
+                           int (sizeof (charT)), int (str.size ()),
+                           str.c_str (), match);
             }
 
             // verify that Traits::length was used
-            if (Insert (size_ptr) == func.which_ && rg_calls) {
+            if (Insert (size_cptr) == func.which_ && rg_calls) {
                 rw_assert (n_length_calls - total_length_calls > 0, 
                            0, tcase.line, "line %d. %{$FUNCALL} doesn't "
                            "use traits::length()", __LINE__);
@@ -852,7 +848,7 @@
         if (caught) {
             // verify that an exception thrown during allocation
             // didn't cause a change in the state of the object
-            str_state.assert_equal (rw_get_string_state (s_str),
+            str_state.assert_equal (rw_get_string_state (str),
                                     __LINE__, tcase.line, caught);
 
             if (-1 == tcase.bthrow) {
@@ -896,28 +892,28 @@
 
 int main (int argc, char** argv)
 {
-    static const StringMembers::Test
+    static const StringTest
     tests [] = {
 
 #undef TEST
-#define TEST(tag) {                                             \
-        StringMembers::insert_ ## tag, tag ## _test_cases,      \
-        sizeof tag ## _test_cases / sizeof *tag ## _test_cases  \
+#define TEST(sig) {                                             \
+        Insert (sig), sig ## _test_cases,                       \
+        sizeof sig ## _test_cases / sizeof *sig ## _test_cases  \
     }
 
-        TEST (size_ptr),
-        TEST (size_str),
-        TEST (size_ptr_size),
-        TEST (size_str_size_size),
+        TEST (size_cptr),
+        TEST (size_cstr),
+        TEST (size_cptr_size),
+        TEST (size_cstr_size_size),
         TEST (size_size_val),
-        TEST (val),
-        TEST (size_val),
-        TEST (range)
+        TEST (iter_val),
+        TEST (iter_size_val),
+        TEST (iter_range)
     };
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    return StringMembers::run_test (argc, argv, __FILE__,
-                                    "lib.string.insert",
-                                    test_insert, tests, test_count);
+    return rw_run_string_test (argc, argv, __FILE__,
+                               "lib.string.insert",
+                               test_insert, tests, test_count);
 }