stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r395450 - in /incubator/stdcxx/trunk/tests/strings: 21.string.append.cpp 21.string.assign.cpp
Date Thu, 20 Apr 2006 00:22:30 GMT
Author: sebor
Date: Wed Apr 19 17:22:29 2006
New Revision: 395450

URL: http://svn.apache.org/viewcvs?rev=395450&view=rev
Log:
2006-04-19  Martin Sebor  <sebor@roguewave.com>

	* 21.strings.assign.cpp (<21.strings.h>, StringMembers): Included
	header and used class to simplify.
	(AssignOverload, TestCase, FunctionTag, rw_opt_no_assign): Removed,
	replaced with StringMembers equivalents.
	(*_test_cases): Renamed from assign_*_test_cases for simplicity,
	reverting a previous rename in the opposite direction.
	* 21.strings.append.cpp: Same.

Modified:
    incubator/stdcxx/trunk/tests/strings/21.string.append.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp

Modified: incubator/stdcxx/trunk/tests/strings/21.string.append.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.append.cpp?rev=395450&r1=395449&r2=395450&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.append.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.append.cpp Wed Apr 19 17:22:29 2006
@@ -22,7 +22,7 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
+ *
  **************************************************************************/
 
 #include <memory>       // for placement operator new()
@@ -37,22 +37,32 @@
 #include <rw_char.h>    // for rw_widen()
 #include <alg_test.h>   // for InputIter<>
 
+#include <21.strings.h>
+
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
    // disabled for compilers such as IBM VAC++ or MSVC
    // that can't reliably replace the operators
 #  include <rw_new.h>
 #endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
+
+#define AppendOverload   StringMembers::MemberFunction
+#define Append(which)   StringMembers::append_ ## which
+#define Disabled(which)  StringMembers::opt_memfun_disabled [which]
+
+typedef StringMembers::TestCase TestCase;
+typedef StringMembers::Test     Test;
+
 /**************************************************************************/
 
 struct MemFun
 {
-    enum charT  { Char, WChar, UChar };
-    enum Traits { DefaultTraits, UserTraits };
+    typedef StringMembers::charT  charT;
+    typedef StringMembers::Traits Traits;
 
     MemFun (charT cid, const char *cname,
           Traits tid, const char *tname)
-        : cid_ (cid), tid_ (tid), 
+        : cid_ (cid), tid_ (tid),
           cname_ (cname), tname_ (tname), aname_ ("allocator"),
           fname_ ("append") { /* empty */ }
 
@@ -73,53 +83,11 @@
 static const std::size_t long_string_len = 4096;
 static char long_string [long_string_len];
 
-static const char* const exp_exceptions[] = 
+static const char* const exp_exceptions[] =
     { "unknown exception", "out_of_range", "length_error" };
 
 /**************************************************************************/
 
-typedef enum AppendTags {
-
-    // append (const charT* s)
-    append_ptr          =  1,   
-    // append (const basic_string& str)
-    append_str          =  2,
-    // append (const charT* s, size_type n)
-    append_ptr_size     =  3,
-    // append (const basic_string& str, size_type pos, size_type n)
-    append_str_off_size =  4,
-    // append (size_type n, charT c)
-    append_size_val     =  5,
-    // append (InputIterator first, InputIterator last)
-    append_range        =  6
-
-} ATags;
-
-/**************************************************************************/
-
-struct TestCase
-{
-    int  line;
-
-    int  pos;
-    int  count;
-    int  ch;
-
-    const char* str;
-    std::size_t str_len;
-
-    const char* src;
-    std::size_t src_len;
-
-    const char* res;
-    std::size_t res_len;
-
-    int bthrow;
-
-};
-
-/**************************************************************************/
-
 static int rw_opt_no_char_traits;              // for --no-char_traits
 static int rw_opt_no_user_traits;              // for --no-user_traits
 
@@ -127,34 +95,28 @@
 static int rw_opt_no_exceptions;               // for --no-exceptions
 static int rw_opt_no_exception_safety;         // for --no-exception-safety
 
-static int rw_opt_no_append_ptr;               // for --no-append-ptr
-static int rw_opt_no_append_str;               // for --no-append-str
-static int rw_opt_no_append_ptr_size;          // for --no-append-ptr-size
-static int rw_opt_no_append_str_off_size;      // for --no-append-str-off-size
-static int rw_opt_no_append_size_val;          // for --no-append-size-val
-static int rw_opt_no_append_range;             // for --no-append-range
-
 /**************************************************************************/
 
-// used to exercise 
+// used to exercise
 // append (const charT* s)
-static const TestCase ptr_test_cases [] = {
+static const TestCase
+ptr_test_cases [] = {
 
 #undef TEST
-#define TEST(str, src, res, bthrow)                            \
-    { __LINE__, -1, -1, -1, str, sizeof str - 1, src,          \
-      sizeof src - 1, res, sizeof res - 1, bthrow }
+#define TEST(str, arg, res, bthrow)                            \
+    { __LINE__, -1, -1, -1, str, sizeof str - 1, 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  
+    //    |             |             |        +---- exception info
+    //    |             |             |        |         0 - no exception
+    //    |             |             |        |         1 - out_of_range
+    //    |             |             |        |         2 - length_error
     //    |             |             |        |        -1 - exc. safety
-    //    |             |             |        |                       
-    //    |             |             |        +--------------+             
+    //    |             |             |        |
+    //    |             |             |        +--------------+
     //    V             V             V                       V
     TEST ("ab",         "c",          "abc",                  0),
 
@@ -199,25 +161,26 @@
 
 /**************************************************************************/
 
-// used to exercise 
+// used to exercise
 // append (const basic_string& str)
-static const TestCase str_test_cases [] = {
+static const TestCase
+str_test_cases [] = {
 
 #undef TEST
-#define TEST(str, src, res, bthrow)                            \
-    { __LINE__, -1, -1, -1, str, sizeof str - 1, src,          \
-      sizeof src - 1, res, sizeof res - 1, bthrow }
+#define TEST(str, arg, res, bthrow)                            \
+    { __LINE__, -1, -1, -1, str, sizeof str - 1, 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  
+    //    |             |             |        +---- exception info
+    //    |             |             |        |         0 - no exception
+    //    |             |             |        |         1 - out_of_range
+    //    |             |             |        |         2 - length_error
     //    |             |             |        |        -1 - exc. safety
-    //    |             |             |        |                       
-    //    |             |             |        +--------------+             
+    //    |             |             |        |
+    //    |             |             |        +--------------+
     //    V             V             V                       V
     TEST ("ab",         "c",          "abc",                  0),
 
@@ -263,27 +226,28 @@
 
 /**************************************************************************/
 
-// used to exercise 
+// used to exercise
 // append (const charT* s, size_type n)
-static const TestCase ptr_size_test_cases [] = {
+static const TestCase
+ptr_size_test_cases [] = {
 
 #undef TEST
-#define TEST(str, src, count, res, bthrow)                            \
-    { __LINE__, -1, count, -1, str, sizeof str - 1, src,              \
-      sizeof src - 1, res, sizeof res - 1, bthrow }
+#define TEST(str, arg, size, res, bthrow)                            \
+    { __LINE__, -1, size, -1, str, sizeof str - 1, 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             
+    //    |            |            +------------ 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),
@@ -329,29 +293,33 @@
 
 /**************************************************************************/
 
-// used to exercise 
-// append (const basic_string& str, size_type pos, size_type n)
+// used to exercise
+// append (const basic_string& str, size_type off, size_type n)
 // append (InputIterator first, InputIterator last)
-static const TestCase range_test_cases [] = {
+static const TestCase
+range_test_cases [] = {
+
+// range_test_cases serves a double duty
+#define str_off_size_test_cases range_test_cases
 
 #undef TEST
-#define TEST(str, src, pos, count, res, bthrow)                            \
-    { __LINE__, pos, count, -1, str, sizeof str - 1, src,                  \
-      sizeof src - 1, res, sizeof res - 1, bthrow }
+#define TEST(str, arg, off, size, res, bthrow)                            \
+    { __LINE__, off, size, -1, str, sizeof str - 1, arg,                  \
+      sizeof arg - 1, res, sizeof res - 1, bthrow }
 
     //    +-------------------------------------- controlled sequence
     //    |            +------------------------- sequence to be appended
     //    |            |            +------------ append() pos argument
-    //    |            |            |  +--------- append() n 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             
+    //    |            |            |  |  |  +--- 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),
@@ -409,27 +377,28 @@
 
 /**************************************************************************/
 
-// used to exercise 
+// used to exercise
 // append (charT c, size_type n)
-static const TestCase size_val_test_cases [] = {
+static const TestCase
+size_val_test_cases [] = {
 
 #undef TEST
-#define TEST(str, count, ch, res, bthrow)                            \
-    { __LINE__, -1, count, ch, str, sizeof str - 1, 0, 0,            \
+#define TEST(str, size, val, res, bthrow)                            \
+    { __LINE__, -1, size, val, str, sizeof str - 1, 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  
+    //    |            |   |   +----------------- expected result sequence
+    //    |            |   |   |       +--------- exception info
+    //    |            |   |   |       |             0 - no exception
+    //    |            |   |   |       |             1 - out_of_range
+    //    |            |   |   |       |             2 - length_error
     //    |            |   |   |       |            -1 - exc. safety
-    //    |            |   |   |       |                         
-    //    |            |   |   |       +-----------+             
-    //    V            V   V   V                   V                
+    //    |            |   |   |       |
+    //    |            |   |   |       +-----------+
+    //    V            V   V   V                   V
     TEST ("ab",        1, 'c', "abc",              0),
 
     TEST ("",          0, ' ',  "",                0),
@@ -471,49 +440,33 @@
 
 /**************************************************************************/
 
-static const struct FunctionTag
-{
-    ATags           a_tag;
-    const int      *p_opt;
-    const TestCase *t_cases;
-    std::size_t     n_cases;
-    const char     *str_hdr;
-
-} function_tags [] = {
+static const StringMembers::Test
+tests [] = {
 
 #undef TEST
-#define TEST(tag, opt, cases, hdr)                              \
-    { tag, &opt, cases, sizeof cases / sizeof *cases, hdr }     
-
-    TEST (append_ptr, rw_opt_no_append_ptr, ptr_test_cases,                  
-          "append (const charT* s)"),
-
-    TEST (append_str, rw_opt_no_append_str, str_test_cases,            
-          "append (const basic_string& str)"),
-
-    TEST (append_ptr_size, rw_opt_no_append_ptr_size, ptr_size_test_cases, 
-          "append (const charT* s, size_type n)"),
-
-    TEST (append_str_off_size, rw_opt_no_append_str_off_size, 
-          range_test_cases, "append (const basic_string& str,"
-          " size_type pos, size_type n)"),
-
-    TEST (append_size_val, rw_opt_no_append_size_val, 
-          size_val_test_cases, "append (size_type n, charT c)"),
+#define TEST(tag, sig) {                                        \
+        Append (tag), tag ## _test_cases,                       \
+        sizeof tag ## _test_cases / sizeof *tag ## _test_cases, \
+        "append " sig                                           \
+    }
 
-    TEST (append_range, rw_opt_no_append_range, range_test_cases, 
-          "append (InputIterator first, InputIterator last)")
+    TEST (ptr,          "(const value_type*)"),
+    TEST (str,          "(const basic_string&)"),
+    TEST (ptr_size,     "(const value_type*, size_type)"),
+    TEST (str_off_size, "(const basic_string&, size_type, size_type)"),
+    TEST (size_val,     "(size_type, value_type)"),
+    TEST (range,        "(InputIterator, InputIterator)")
 };
 
 /**************************************************************************/
 
 template <class charT, class Traits>
-void test_append_exceptions (charT, Traits*,  
-                             const ATags     which,
-                             const TestCase &cs,
-                             const char     *append_fmt)
+void test_append_exceptions (charT, Traits*,
+                             const AppendOverload  which,
+                             const TestCase       &cs,
+                             const char           *funcall)
 {
-    typedef std::basic_string <charT, Traits, 
+    typedef std::basic_string <charT, Traits,
                                std::allocator<charT> > TestString;
     typedef typename TestString::iterator StringIter;
     typedef typename TestString::const_iterator ConstStringIter;
@@ -522,10 +475,10 @@
     static charT wsrc [LLEN];
 
     rw_widen (wstr, cs.str, cs.str_len);
-    rw_widen (wsrc, cs.src, cs.src_len);
+    rw_widen (wsrc, cs.arg, cs.arg_len);
 
     TestString s_str (wstr, cs.str_len);
-    TestString s_src (wsrc, cs.src_len);
+    TestString s_arg (wsrc, cs.arg_len);
 
     std::size_t throw_after = 0;
 
@@ -553,23 +506,23 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
         _TRY {
-            if (append_ptr == which) 
-                s_str.append (cs.src ? wsrc : s_str.c_str ());
+            if (Append (ptr) == which)
+                s_str.append (cs.arg ? wsrc : s_str.c_str ());
 
-            else if (append_str == which)
-                s_str.append (cs.src ? s_src : s_str);
+            else if (Append (str) == which)
+                s_str.append (cs.arg ? s_arg : s_str);
 
-            else if (append_ptr_size == which)
-                s_str.append (cs.src ? wsrc : s_str.c_str (), cs.count);
+            else if (Append (ptr_size) == which)
+                s_str.append (cs.arg ? wsrc : s_str.c_str (), cs.size);
 
-            else if (append_str_off_size == which) 
-                s_str.append (cs.src ? s_src : s_str, cs.pos, cs.count);
+            else if (Append (str_off_size) == which)
+                s_str.append (cs.arg ? s_arg : s_str, cs.off, cs.size);
 
-            else if (append_size_val == which)
-                s_str.append (cs.count, make_char ((char) cs.ch, (charT*)0));
+            else if (Append (size_val) == which)
+                s_str.append (cs.size, make_char (char (cs.val), (charT*)0));
 
-            else if (append_range == which)
-                s_str.append (s_src.begin (), s_src.end ());
+            else if (Append (range) == which)
+                s_str.append (s_arg.begin (), s_arg.end ());
 
             break;
         }
@@ -583,18 +536,18 @@
             rw_assert (s_str.size () == size, 0, cs.line,
                        "line %d: %s: size unexpectedly changed "
                        "from %zu to %zu after an exception",
-                       __LINE__, append_fmt, size, s_str.size ());
+                       __LINE__, funcall, size, s_str.size ());
 
             rw_assert (s_str.capacity () == capacity, 0, cs.line,
                        "line %d: %s: capacity unexpectedly "
                        "changed from %zu to %zu after an exception",
-                       __LINE__, append_fmt, capacity, s_str.capacity ());
+                       __LINE__, funcall, capacity, s_str.capacity ());
+
 
-            
             rw_assert (s_str.begin () == begin, 0, cs.line,
                        "line %d: %s: begin() unexpectedly "
                        "changed from after an exception by %d",
-                       __LINE__, append_fmt, s_str.begin () - begin);
+                       __LINE__, funcall, s_str.begin () - begin);
 
 
             // increment to allow this call to operator new to succeed
@@ -612,10 +565,10 @@
     // verify that if exceptions are enabled and when capacity changes
     // at least one exception is thrown
     rw_assert (   *pst->throw_at_calls_ [0] == std::size_t (-1)
-               || throw_after, 
+               || throw_after,
                0, cs.line,
                "line %d: %s: failed to throw an expected exception",
-               __LINE__, append_fmt);
+               __LINE__, funcall);
 
 #  endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
 #else   // if defined (_RWSTD_NO_EXCEPTIONS)
@@ -637,38 +590,38 @@
 
 template <class charT, class Traits, class Iterator>
 void test_append_range (charT* wstr,
-                        charT* wsrc, 
+                        charT* wsrc,
                         Traits*,
                         const Iterator &it,
                         const TestCase &cs,
-                        const char     *append_fmt)
+                        const char     *funcall)
 {
-    typedef std::basic_string <charT, Traits, 
+    typedef std::basic_string <charT, Traits,
                                std::allocator<charT> > String;
     typedef typename String::iterator StringIter;
 
-    const char* const itname = 
-        cs.src ? type_name (it, (charT*)0) : "basic_string::iterator";
+    const char* const itname =
+        cs.arg ? type_name (it, (charT*)0) : "basic_string::iterator";
 
     String s_str (wstr, cs.str_len);
-    String s_src (wsrc, cs.src_len);
+    String s_arg (wsrc, cs.arg_len);
 
-    std::size_t off_last = cs.pos + cs.count;
+    std::size_t off_last = cs.off + cs.size;
 
-    if (cs.src) {
-        off_last = off_last > s_src.size () ? s_src.size () : off_last;
+    if (cs.arg) {
+        off_last = off_last > s_arg.size () ? s_arg.size () : off_last;
 
-        const Iterator first = make_iter (wsrc + cs.pos, 
-            wsrc + cs.pos, wsrc + off_last, Iterator (0, 0, 0));
-        const Iterator last  = make_iter (wsrc + off_last, 
-            wsrc + cs.pos, wsrc + off_last, Iterator (0, 0, 0));
+        const Iterator first = make_iter (wsrc + cs.off,
+            wsrc + cs.off, wsrc + off_last, Iterator (0, 0, 0));
+        const Iterator last  = make_iter (wsrc + off_last,
+            wsrc + cs.off, wsrc + off_last, Iterator (0, 0, 0));
 
         s_str.append (first, last);
     }
     else {
-        StringIter first (s_str.begin () + cs.pos);
-        StringIter last  (off_last > s_str.size () ? 
-            s_str.end () 
+        StringIter first (s_str.begin () + cs.off);
+        StringIter last  (off_last > s_str.size () ?
+            s_str.end ()
           : s_str.begin () + off_last);
 
         s_str.append (first, last);
@@ -678,51 +631,51 @@
 
     rw_assert (match == cs.res_len, 0, cs.line,
                "line %d. %s expected %{#*s}, got %{/*.*Gs}, "
-               "difference at pos %zu for %s", 
-               __LINE__, append_fmt, int (cs.res_len), cs.res, 
-               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (), 
+               "difference at off %zu for %s",
+               __LINE__, funcall, int (cs.res_len), cs.res,
+               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (),
                match, itname);
 }
 
 /**************************************************************************/
 
 template <class charT, class Traits>
-void test_append_range (charT* wstr, 
-                        charT* wsrc, 
+void test_append_range (charT* wstr,
+                        charT* wsrc,
                         Traits*,
                         const TestCase &cs,
-                        const char     *append_fmt)
+                        const char     *funcall)
 {
     if (cs.bthrow)  // this method doesn't throw
         return;
 
-    test_append_range (wstr, wsrc, (Traits*)0, 
-                       InputIter<charT>(0, 0, 0), cs, append_fmt);
+    test_append_range (wstr, wsrc, (Traits*)0,
+                       InputIter<charT>(0, 0, 0), cs, funcall);
 
-    // there is no need to call test_append_range 
+    // there is no need to call test_append_range
     // for other iterators in this case
-    if (0 == cs.src)
+    if (0 == cs.arg)
         return;
 
-    test_append_range (wstr, wsrc, (Traits*)0, 
-                       ConstFwdIter<charT>(0, 0, 0), cs, append_fmt);
+    test_append_range (wstr, wsrc, (Traits*)0,
+                       ConstFwdIter<charT>(0, 0, 0), cs, funcall);
 
-    test_append_range (wstr, wsrc, (Traits*)0, 
-                       ConstBidirIter<charT>(0, 0, 0), cs, append_fmt);
+    test_append_range (wstr, wsrc, (Traits*)0,
+                       ConstBidirIter<charT>(0, 0, 0), cs, funcall);
 
-    test_append_range (wstr, wsrc, (Traits*)0, 
-                       ConstRandomAccessIter<charT>(0, 0, 0), cs, append_fmt);
+    test_append_range (wstr, wsrc, (Traits*)0,
+                       ConstRandomAccessIter<charT>(0, 0, 0), cs, funcall);
 }
 
 /**************************************************************************/
 
 template <class charT, class Traits>
-void test_append (charT, Traits*,  
-                  const ATags     which,
+void test_append (charT, Traits*,
+                  const AppendOverload     which,
                   const TestCase &cs,
-                  const char     *append_fmt)
+                  const char     *funcall)
 {
-    typedef std::basic_string <charT, Traits, 
+    typedef std::basic_string <charT, Traits,
                                std::allocator<charT> > TestString;
     typedef typename TestString::iterator StringIter;
 
@@ -730,16 +683,16 @@
     static charT wsrc [LLEN];
 
     rw_widen (wstr, cs.str, cs.str_len);
-    rw_widen (wsrc, cs.src, cs.src_len);
+    rw_widen (wsrc, cs.arg, cs.arg_len);
 
     // special processing for append_range to exercise all iterators
-    if (append_range == which) {
-        test_append_range (wstr, wsrc, (Traits*)0, cs, append_fmt);
+    if (Append (range) == which) {
+        test_append_range (wstr, wsrc, (Traits*)0, cs, funcall);
         return;
     }
 
     TestString s_str (wstr, cs.str_len);
-    TestString s_src (wsrc, cs.src_len);
+    TestString s_arg (wsrc, cs.arg_len);
 
     std::size_t res_off = 0;
 
@@ -747,7 +700,7 @@
 
     // is some exception expected ?
     const char* expected = 0;
-    if (1 == cs.bthrow && append_str_off_size == which)
+    if (1 == cs.bthrow && Append (str_off_size) == which)
         expected = exp_exceptions [1];
     if (2 == cs.bthrow)
         expected = exp_exceptions [2];
@@ -760,53 +713,52 @@
 
     switch (which)
     {
-    case append_ptr: {
-        TestString& s_res = s_str.append (cs.src ? wsrc : s_str.c_str ());
+    case Append (ptr): {
+        TestString& s_res = s_str.append (cs.arg ? wsrc : s_str.c_str ());
         res_off = &s_res - &s_str;
         break;
     }
 
-    case append_str: {
-        TestString& s_res = s_str.append (cs.src ? s_src : s_str);
+    case Append (str): {
+        TestString& s_res = s_str.append (cs.arg ? s_arg : s_str);
         res_off = &s_res - &s_str;
         break;
     }
 
-    case append_ptr_size: {
-        TestString& s_res = 
-            s_str.append (cs.src ? wsrc : s_str.c_str (), cs.count);
+    case Append (ptr_size): {
+        TestString& s_res =
+            s_str.append (cs.arg ? wsrc : s_str.c_str (), cs.size);
         res_off = &s_res - &s_str;
         break;
     }
 
-    case append_str_off_size: {
-        TestString& s_res = 
-            s_str.append (cs.src ? s_src : s_str, cs.pos, cs.count);
+    case Append (str_off_size): {
+        TestString& s_res =
+            s_str.append (cs.arg ? s_arg : s_str, cs.off, cs.size);
         res_off = &s_res - &s_str;
         break;
     }
 
-    case append_size_val: {
-        TestString& s_res = 
-            s_str.append (cs.count, make_char ((char) cs.ch, (charT*)0));
+    case Append (size_val): {
+        TestString& s_res =
+            s_str.append (cs.size, make_char (char (cs.val), (charT*)0));
         res_off = &s_res - &s_str;
         break;
     }
 
     default:
-        RW_ASSERT ("test logic error: unknown append overload");
-        return;
+        RW_ASSERT (!"test logic error: unknown append overload");
     }
 
     // verify the returned value
     rw_assert (0 == res_off, 0, cs.line,
-               "line %d. %s returned invalid reference, offset is %zu", 
-               __LINE__, append_fmt, res_off);
+               "line %d. %s returned invalid reference, offset is %zu",
+               __LINE__, funcall, res_off);
 
     // verfiy that strings length are equal
     rw_assert (cs.res_len == s_str.size (), 0, cs.line,
                "line %d. %s expected %{#*s} with length %zu, got %{/*.*Gs} "
-               "with length %zu", __LINE__, append_fmt, int (cs.res_len), 
+               "with length %zu", __LINE__, funcall, int (cs.res_len),
                cs.res, cs.res_len, int (sizeof (charT)), int (s_str.size ()),
                s_str.c_str (), s_str.size ());
 
@@ -815,9 +767,9 @@
 
     rw_assert (match == cs.res_len, 0, cs.line,
                "line %d. %s expected %{#*s}, got %{/*.*Gs}, "
-               "difference at pos %zu", 
-               __LINE__, append_fmt, int (cs.res_len), cs.res, 
-               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (), 
+               "difference at off %zu",
+               __LINE__, funcall, int (cs.res_len), cs.res,
+               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (),
                match);
 
 #ifndef _RWSTD_NO_EXCEPTIONS
@@ -840,90 +792,39 @@
     rw_assert (caught == expected, 0, cs.line,
                "line %d. %s %{?}expected %s, caught %s"
                "%{:}unexpectedly caught %s%{;}",
-               __LINE__, append_fmt, 0 != expected, expected, caught, caught);
+               __LINE__, funcall, 0 != expected, expected, caught, caught);
 }
 
 /**************************************************************************/
 
-void get_append_format (char** pbuf, std::size_t* pbufsize, 
-                        const MemFun *pfid, 
-                        const ATags which, 
-                        const TestCase& cs)
-{
-    if (   MemFun::DefaultTraits == pfid->tid_
-        && (MemFun::Char == pfid->cid_ || MemFun::WChar == pfid->cid_))
-        rw_asnprintf (pbuf, pbufsize,
-                      "std::%{?}w%{;}string (%{#*s}).append",
-                      MemFun::WChar == pfid->cid_,
-                      int (cs.str_len), cs.str);
-    else
-        rw_asnprintf (pbuf, pbufsize,
-                      "std::basic_string<%s, %s<%1$s>, %s<%1$s>>(%{#*s})"
-                      ".append", pfid->cname_, pfid->tname_, pfid->aname_, 
-                      int (cs.str_len), cs.str);
-
-    const bool self = 0 == cs.src;
-
-    switch (which)
-    {
-    case append_ptr:
-        rw_asnprintf (pbuf, pbufsize, 
-                      "%{+} (%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
-                      !self, int (cs.src_len), cs.src, self);
-        break;
-
-    case append_str:
-        rw_asnprintf (pbuf, pbufsize, 
-                      "%{+} (%{?}string (%{#*s})%{;}%{?}*this%{;})",
-                      !self, int (cs.src_len), cs.src, self);
-        break;
-
-    case append_ptr_size:
-        rw_asnprintf (pbuf, pbufsize, "%{+} ("
-                      "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
-                      !self, int (cs.src_len), cs.src, self, cs.count);
-        break;
-
-    case append_str_off_size:
-        rw_asnprintf (pbuf, pbufsize, "%{+} ("
-                      "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
-                      !self, int (cs.src_len), cs.src, 
-                      self, cs.pos, cs.count);
-        break;
-
-    case append_size_val:
-        rw_asnprintf (pbuf, pbufsize, 
-                      "%{+} (%zu, %#c)", cs.count, cs.ch);
-        break;
-
-    case append_range:
-        rw_asnprintf (pbuf, pbufsize, "%{+} ("
-                      "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
-                      "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)", 
-                      !self, int (cs.src_len), cs.src,
-                      self, cs.pos, !self, int (cs.src_len), cs.src, 
-                      self, cs.pos + cs.count);
-        break;
-    }
+static char*
+get_append_format (const MemFun         *pfid,
+                   const AppendOverload  which,
+                   const TestCase       &cs)
+{
+    return StringMembers::format (pfid->cid_, pfid->tid_,
+                                  StringMembers::DefaultAllocator,
+                                  which, cs);
 }
 
 /**************************************************************************/
 
-void test_append (const MemFun *pfid, const ATags which, 
-                  const TestCase& cs, bool exc_safety_test)
+static void
+test_append (const MemFun *pfid, const AppendOverload which,
+             const TestCase& cs, bool exc_safety_test)
 {
-    char* buf = 0;
-    std::size_t buf_sz = 0;
-    get_append_format (&buf, &buf_sz, pfid, which, cs); 
+    // format the description of the function call including
+    // the values of arguments for use in diagnostics
+    char* const funcall = get_append_format (pfid, which, cs);
 
 #undef TEST
-#define TEST(charT, Traits)	                                           \
-    !exc_safety_test ?                                                 \
-        test_append (charT(), (Traits*)0, which, cs, buf)              \
-      : test_append_exceptions (charT(), (Traits*)0, which, cs, buf)
+#define TEST(charT, Traits)	                                          \
+    exc_safety_test ?                                                     \
+        test_append_exceptions (charT (), (Traits*)0, which, cs, funcall) \
+      : test_append (charT (), (Traits*)0, which, cs, funcall)
 
-    if (MemFun:: DefaultTraits == pfid->tid_) {
-        if (MemFun::Char == pfid->cid_)
+    if (StringMembers::DefaultTraits == pfid->tid_) {
+        if (StringMembers::Char == pfid->cid_)
             TEST (char, std::char_traits<char>);
 
 #ifndef _RWSTD_NO_WCHAR_T
@@ -933,11 +834,11 @@
 
     }
     else {
-       if (MemFun::Char == pfid->cid_)
+       if (StringMembers::Char == pfid->cid_)
            TEST (char, UserTraits<char>);
 
 #ifndef _RWSTD_NO_WCHAR_T
-       else if (MemFun::WChar == pfid->cid_)
+       else if (StringMembers::WChar == pfid->cid_)
            TEST (wchar_t, UserTraits<wchar_t>);
 #endif   // _RWSTD_NO_WCHAR_T
 
@@ -945,50 +846,50 @@
            TEST (UserChar, UserTraits<UserChar>);
     }
 
-    free (buf);
+    std::free (funcall);
 }
 
 /**************************************************************************/
 
 static void
-test_append (const MemFun *pfid, const FunctionTag& ftag)
+test_append (const MemFun *pfid, const Test& test)
 {
     rw_info (0, 0, 0, "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::%s",
-             pfid->cname_, pfid->tname_, pfid->aname_, ftag.str_hdr);
+             pfid->cname_, pfid->tname_, pfid->aname_, test.funsig);
 
     if (rw_opt_no_exception_safety)
         rw_note (0, 0, 0,
                  "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::"
-                 "%s exception safety test disabled", 
-                 pfid->cname_, pfid->tname_, pfid->aname_, ftag.str_hdr);
+                 "%s exception safety test disabled",
+                 pfid->cname_, pfid->tname_, pfid->aname_, test.funsig);
 
 #ifdef _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
     else
         rw_warn (0, 0, __LINE__,
                  "%s exception safety test: no replacable new and delete",
-                 ftag.str_hdr);
+                 test.funsig);
 
 #endif  //_RWSTD_NO_REPLACEABLE_NEW_DELETE
 
-    for (std::size_t i = 0; i != ftag.n_cases; ++i) {
+    for (std::size_t i = 0; i != test.case_count; ++i) {
 
-        if (!rw_enabled (ftag.t_cases[i].line)) {
-            rw_note (0, 0, __LINE__, 
-                     "test on line %d disabled", ftag.t_cases[i].line);
+        if (!rw_enabled (test.cases[i].line)) {
+            rw_note (0, 0, __LINE__,
+                     "test on line %d disabled", test.cases[i].line);
             continue;
         }
 
         // do not exercise exceptions if they were disabled
-        if (0 != rw_opt_no_exceptions && 0 != ftag.t_cases[i].bthrow)
+        if (0 != rw_opt_no_exceptions && 0 != test.cases[i].bthrow)
             continue;
 
         // do not exercise exception safety if they were disabled
-        if (0 != rw_opt_no_exception_safety && -1 == ftag.t_cases[i].bthrow)
+        if (0 != rw_opt_no_exception_safety && -1 == test.cases[i].bthrow)
             continue;
 
-        test_append (pfid, ftag.a_tag, ftag.t_cases[i], 
-                     -1 == ftag.t_cases[i].bthrow);
+        test_append (pfid, test.which, test.cases[i],
+                     -1 == test.cases [i].bthrow);
     }
 }
 
@@ -998,11 +899,12 @@
 static void
 run_test (const MemFun *pfid)
 {
-    if (MemFun::UserTraits == pfid->tid_ && rw_opt_no_user_traits) {
+    if (StringMembers::UserTraits == pfid->tid_ && rw_opt_no_user_traits) {
         rw_note (1 < rw_opt_no_user_traits++, 0, 0,
                  "user defined traits test disabled");
     }
-    else if (MemFun::DefaultTraits == pfid->tid_  && rw_opt_no_char_traits) {
+    else if (   StringMembers::DefaultTraits == pfid->tid_
+             && rw_opt_no_char_traits) {
         rw_note (1 < rw_opt_no_char_traits++, 0, 0,
                  "char_traits test disabled");
     }
@@ -1010,20 +912,19 @@
 
         if (rw_opt_no_exceptions)
             rw_note (1 < rw_opt_no_exceptions++, 0, 0,
-                     "string::append exceptions tests disabled"); 
+                     "string::append exceptions tests disabled");
 
-        static const std::size_t ftags = 
-            sizeof function_tags / sizeof *function_tags;
+        static const std::size_t ntests = sizeof tests / sizeof *tests;
 
-        for (std::size_t i = 0; i < ftags; i++) {
+        for (std::size_t i = 0; i < ntests; i++) {
 
-            if (*function_tags[i].p_opt) 
-                rw_note (0, 0, 0, 
+            if (Disabled (tests [i].which))
+                rw_note (0, 0, 0,
                          "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::"
-                         "%s test disabled", pfid->cname_, pfid->tname_, 
-                         pfid->aname_, function_tags[i].str_hdr);
+                         "%s test disabled", pfid->cname_, pfid->tname_,
+                         pfid->aname_, tests [i].funsig);
             else
-                test_append (pfid, function_tags[i]);
+                test_append (pfid, tests [i]);
         }
     }
 }
@@ -1040,13 +941,14 @@
 
     if (rw_enabled ("char")) {
 
-        MemFun fid (MemFun::Char, "char", MemFun::DefaultTraits, 0);
+        MemFun fid (StringMembers::Char, "char",
+                    StringMembers::DefaultTraits, 0);
 
         fid.tname_ = "char_traits";
 
         run_test (&fid);
 
-        fid.tid_   = MemFun::UserTraits;
+        fid.tid_   = StringMembers::UserTraits;
         fid.tname_ = "UserTraits";
 
         run_test (&fid);
@@ -1056,13 +958,14 @@
 
     if (rw_enabled ("wchar_t")) {
 
-        MemFun fid (MemFun::WChar, "wchar_t", MemFun::DefaultTraits, 0);
+        MemFun fid (StringMembers::WChar, "wchar_t",
+                    StringMembers::DefaultTraits, 0);
 
         fid.tname_ = "char_traits";
 
         run_test (&fid);
 
-        fid.tid_   = MemFun::UserTraits;
+        fid.tid_   = StringMembers::UserTraits;
         fid.tname_ = "UserTraits";
 
         run_test (&fid);
@@ -1074,7 +977,8 @@
         rw_note (0, 0, 0, "user defined chars test disabled");
     }
     else {
-        MemFun fid (MemFun::UChar, "UserChar", MemFun::UserTraits, 0);
+        MemFun fid (StringMembers::UChar, "UserChar",
+                    StringMembers::UserTraits, 0);
         fid.tname_ = "UserTraits";
         run_test (&fid);
     }
@@ -1092,7 +996,8 @@
 {
     return rw_test (argc, argv, __FILE__,
                     "lib.string.append",
-                    0 /* no comment */, run_test,
+                    0 /* no comment */,
+                    run_test,
                     "|-no-char_traits# "
                     "|-no-user_traits# "
                     "|-no-user_chars# "
@@ -1112,11 +1017,12 @@
                     &rw_opt_no_exceptions,
                     &rw_opt_no_exception_safety,
 
-                    &rw_opt_no_append_ptr,
-                    &rw_opt_no_append_str,
-                    &rw_opt_no_append_ptr_size,
-                    &rw_opt_no_append_str_off_size,
-                    &rw_opt_no_append_size_val,
-                    &rw_opt_no_append_range);
+                    &Disabled (Append (ptr)),
+                    &Disabled (Append (str)),
+                    &Disabled (Append (ptr_size)),
+                    &Disabled (Append (str_off_size)),
+                    &Disabled (Append (size_val)),
+                    &Disabled (Append (range)),
+                    // sentinel
+                    (void*)0);
 }
-

Modified: incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp?rev=395450&r1=395449&r2=395450&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp Wed Apr 19 17:22:29 2006
@@ -37,18 +37,28 @@
 #include <rw_char.h>    // for rw_widen()
 #include <alg_test.h>   // for InputIter<>
 
+#include <21.strings.h>
+
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
    // disabled for compilers such as IBM VAC++ or MSVC
    // that can't reliably replace the operators
 #  include <rw_new.h>
 #endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
+
+#define AssignOverload   StringMembers::MemberFunction
+#define Assign(which)    StringMembers::assign_ ## which
+#define Disabled(which)  StringMembers::opt_memfun_disabled [which]
+
+typedef StringMembers::TestCase TestCase;
+typedef StringMembers::Test     Test;
+
 /**************************************************************************/
 
 struct MemFun
 {
-    enum charT  { Char, WChar, UChar };
-    enum Traits { DefaultTraits, UserTraits };
+    typedef StringMembers::charT  charT;
+    typedef StringMembers::Traits Traits;
 
     MemFun (charT cid, const char *cname,
           Traits tid, const char *tname)
@@ -78,48 +88,6 @@
 
 /**************************************************************************/
 
-enum AssignOverload {
-    // assign (const value_type*)
-    assign_ptr,
-    // assign (const basic_string&)
-    assign_str,
-    // assign (const value_type*, size_type)
-    assign_ptr_size,
-    // assign (const basic_string&, size_type, size_type)
-    assign_str_off_size,
-    // assign (size_type, value_type)
-    assign_size_val,
-    // assign (InputIterator, InputIterator)
-    assign_range,
-
-    // must be last: number of exercised overloads
-    n_assign_overloads
-};
-
-/**************************************************************************/
-
-struct TestCase
-{
-    int         line;      // test case line number
-
-    int         off;       // offset (position argument)
-    int         size;      // size (count argument)
-    int         val;       // value (single character to insert)
-
-    const char* str;       // controlled sequence
-    std::size_t str_len;   // length of sequence
-
-    const char* arg;       // sequence to insert
-    std::size_t arg_len;   // length of sequence
-
-    const char* res;       // resulting sequence
-    std::size_t res_len;   // length of sequence
-
-    int         bthrow;    // exception expected
-};
-
-/**************************************************************************/
-
 static int rw_opt_no_char_traits;              // for --no-char_traits
 static int rw_opt_no_user_traits;              // for --no-user_traits
 
@@ -127,15 +95,12 @@
 static int rw_opt_no_exceptions;               // for --no-exceptions
 static int rw_opt_no_exception_safety;         // for --no-exception-safety
 
-// array of options to disable each overload of assign
-static int rw_opt_no_assign [n_assign_overloads];
-
 /**************************************************************************/
 
 // used to exercise:
 // assign (const value_type*)
 static const TestCase
-assign_ptr_test_cases [] = {
+ptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow)                            \
@@ -189,7 +154,7 @@
 // used to exercise:
 // assign (const basic_string&)
 static const TestCase
-assign_str_test_cases [] = {
+str_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res, bthrow)                            \
@@ -249,7 +214,7 @@
 // used to exercise:
 // assign (const value_type*, size_type)
 static const TestCase
-assign_ptr_size_test_cases [] = {
+ptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, size, res, bthrow)                            \
@@ -319,10 +284,10 @@
 // assign (const basic_string&, size_type, size_type)
 // assign (InputIterator, InputIterator)
 static const TestCase
-assign_range_test_cases [] = {
+range_test_cases [] = {
 
-// assign_range_test_cases serve a double duty
-#define assign_str_off_size_test_cases assign_range_test_cases
+// range_test_cases serves a double duty
+#define str_off_size_test_cases range_test_cases
 
 #undef TEST
 #define TEST(str, arg, off, size, res, bthrow)                            \
@@ -402,7 +367,7 @@
 // used to exercise:
 // assign (size_type, value_type)
 static const TestCase
-assign_size_val_test_cases [] = {
+size_val_test_cases [] = {
 
 #undef TEST
 #define TEST(str, size, val, res, bthrow)                            \
@@ -455,27 +420,22 @@
 
 /**************************************************************************/
 
-static const struct FunctionTag
-{
-    AssignOverload  which;     // which overload of insert()
-    const TestCase *t_cases;   // test cases to exercise
-    std::size_t     n_cases;   // number of test cases
-    const char     *funsig;    // function signature
-} function_tags [] = {
+static const StringMembers::Test
+tests [] = {
 
 #undef TEST
 #define TEST(tag, sig) {                                        \
-        tag, tag ## _test_cases,                                \
+        Assign (tag), tag ## _test_cases,                       \
         sizeof tag ## _test_cases / sizeof *tag ## _test_cases, \
         "assign " sig                                           \
     }
 
-    TEST (assign_ptr,          "(const value_type*)"),
-    TEST (assign_str,          "(const basic_string&)"),
-    TEST (assign_ptr_size,     "(const value_type*, size_type)"),
-    TEST (assign_str_off_size, "(const basic_string&, size_type, size_type)"),
-    TEST (assign_size_val,     "(size_type, value_type)"),
-    TEST (assign_range,        "(InputIterator, InputIterator)")
+    TEST (ptr,          "(const value_type*)"),
+    TEST (str,          "(const basic_string&)"),
+    TEST (ptr_size,     "(const value_type*, size_type)"),
+    TEST (str_off_size, "(const basic_string&, size_type, size_type)"),
+    TEST (size_val,     "(size_type, value_type)"),
+    TEST (range,        "(InputIterator, InputIterator)")
 };
 
 /**************************************************************************/
@@ -531,27 +491,27 @@
 
         _TRY {
             switch (which) {
-            case assign_ptr:
+            case Assign (ptr):
                 s_str.assign (arg_ptr);
                 break;
 
-            case assign_str:
+            case Assign (str):
                 s_str.assign (arg_str);
                 break;
 
-            case assign_ptr_size:
+            case Assign (ptr_size):
                 s_str.assign (arg_ptr, cs.size);
                 break;
 
-            case assign_str_off_size:
+            case Assign (str_off_size):
                 s_str.assign (arg_str, cs.off, cs.size);
                 break;
 
-            case assign_size_val:
+            case Assign (size_val):
                 s_str.assign (cs.size, arg_val);
                 break;
 
-            case assign_range: {
+            case Assign (range): {
                 const ConstStringIter first = s_arg.begin ();
                 const ConstStringIter last  = s_arg.end ();
                 s_str.assign (first, last);
@@ -724,7 +684,7 @@
     rw_widen (wsrc, cs.arg, cs.arg_len);
 
     // special processing for assign_range to exercise all iterators
-    if (assign_range == which) {
+    if (Assign (range) == which) {
         test_assign_range (wstr, wsrc, (Traits*)0, cs, funcall);
         return;
     }
@@ -746,7 +706,7 @@
 
     // is some exception expected ?
     const char* expected = 0;
-    if (1 == cs.bthrow && assign_str_off_size == which)
+    if (1 == cs.bthrow && Assign (str_off_size) == which)
         expected = exp_exceptions [1];
     if (2 == cs.bthrow)
         expected = exp_exceptions [2];
@@ -763,23 +723,23 @@
 #endif   // _RWSTD_NO_EXCEPTIONS
 
     switch (which) {
-    case assign_ptr:
+    case Assign (ptr):
         res_ptr = &s_str.assign (arg_ptr);
         break;
 
-    case assign_str:
+    case Assign (str):
         res_ptr = &s_str.assign (arg_str);
         break;
 
-    case assign_ptr_size:
+    case Assign (ptr_size):
         res_ptr = &s_str.assign (arg_ptr, size);
         break;
 
-    case assign_str_off_size:
+    case Assign (str_off_size):
         res_ptr = &s_str.assign (arg_str, cs.off, size);
         break;
 
-    case assign_size_val: {
+    case Assign (size_val): {
         const charT val = make_char (char (cs.val), (charT*)0);
         res_ptr = &s_str.assign (size, val);
         break;
@@ -846,11 +806,12 @@
     char*       buf     = 0;
     std::size_t bufsize = 0;
 
-    if (   MemFun::DefaultTraits == pfid->tid_
-        && (MemFun::Char == pfid->cid_ || MemFun::WChar == pfid->cid_))
+    if (   StringMembers::DefaultTraits == pfid->tid_
+        && (   StringMembers::Char == pfid->cid_
+            || StringMembers::WChar == pfid->cid_))
         rw_asnprintf (&buf, &bufsize,
                       "std::%{?}w%{;}string (%{#*s}).assign",
-                      MemFun::WChar == pfid->cid_,
+                      StringMembers::WChar == pfid->cid_,
                       int (cs.str_len), cs.str);
     else
         rw_asnprintf (&buf, &bufsize,
@@ -862,37 +823,37 @@
     const bool self = 0 == cs.arg;
 
     switch (which) {
-    case assign_ptr:
+    case Assign (ptr):
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
                       !self, int (cs.arg_len), cs.arg, self);
         break;
 
-    case assign_str:
+    case Assign (str):
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%{?}string (%{#*s})%{;}%{?}*this%{;})",
                       !self, int (cs.arg_len), cs.arg, self);
         break;
 
-    case assign_ptr_size:
+    case Assign (ptr_size):
         rw_asnprintf (&buf, &bufsize, "%{+} ("
                       "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
                       !self, int (cs.arg_len), cs.arg, self, cs.size);
         break;
 
-    case assign_str_off_size:
+    case Assign (str_off_size):
         rw_asnprintf (&buf, &bufsize, "%{+} ("
                       "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
                       !self, int (cs.arg_len), cs.arg,
                       self, cs.off, cs.size);
         break;
 
-    case assign_size_val:
+    case Assign (size_val):
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%zu, %#c)", cs.size, cs.val);
         break;
 
-    case assign_range:
+    case Assign (range):
         rw_asnprintf (&buf, &bufsize, "%{+} ("
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)",
@@ -924,8 +885,8 @@
         test_assign_exceptions (charT (), (Traits*)0, which, cs, funcall)   \
       : test_assign (charT(), (Traits*)0, which, cs, funcall)
 
-    if (MemFun::DefaultTraits == pfid->tid_) {
-        if (MemFun::Char == pfid->cid_)
+    if (StringMembers::DefaultTraits == pfid->tid_) {
+        if (StringMembers::Char == pfid->cid_)
             TEST (char, std::char_traits<char>);
 
 #ifndef _RWSTD_NO_WCHAR_T
@@ -935,11 +896,11 @@
 
     }
     else {
-       if (MemFun::Char == pfid->cid_)
+       if (StringMembers::Char == pfid->cid_)
            TEST (char, UserTraits<char>);
 
 #ifndef _RWSTD_NO_WCHAR_T
-       else if (MemFun::WChar == pfid->cid_)
+       else if (StringMembers::WChar == pfid->cid_)
            TEST (wchar_t, UserTraits<wchar_t>);
 #endif   // _RWSTD_NO_WCHAR_T
 
@@ -953,44 +914,44 @@
 /**************************************************************************/
 
 static void
-test_assign (const MemFun *pfid, const FunctionTag& ftag)
+test_assign (const MemFun *pfid, const Test& test)
 {
     rw_info (0, 0, 0, "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::%s",
-             pfid->cname_, pfid->tname_, pfid->aname_, ftag.funsig);
+             pfid->cname_, pfid->tname_, pfid->aname_, test.funsig);
 
     if (rw_opt_no_exception_safety)
         rw_note (0, 0, 0,
                  "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::"
                  "%s exception safety test disabled",
-                 pfid->cname_, pfid->tname_, pfid->aname_, ftag.funsig);
+                 pfid->cname_, pfid->tname_, pfid->aname_, test.funsig);
 
 #ifdef _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
     else
         rw_warn (0, 0, __LINE__,
                  "%s exception safety test: no replacable new and delete",
-                 ftag.funsig);
+                 test.funsig);
 
 #endif  //_RWSTD_NO_REPLACEABLE_NEW_DELETE
 
-    for (std::size_t i = 0; i != ftag.n_cases; ++i) {
+    for (std::size_t i = 0; i != test.case_count; ++i) {
 
-        if (!rw_enabled (ftag.t_cases [i].line)) {
+        if (!rw_enabled (test.cases [i].line)) {
             rw_note (0, 0, __LINE__,
-                     "test on line %d disabled", ftag.t_cases [i].line);
+                     "test on line %d disabled", test.cases [i].line);
             continue;
         }
 
         // do not exercise exceptions if they were disabled
-        if (0 != rw_opt_no_exceptions && 0 != ftag.t_cases [i].bthrow)
+        if (0 != rw_opt_no_exceptions && 0 != test.cases [i].bthrow)
             continue;
 
         // do not exercise exception safety if they were disabled
-        if (0 != rw_opt_no_exception_safety && -1 == ftag.t_cases [i].bthrow)
+        if (0 != rw_opt_no_exception_safety && -1 == test.cases [i].bthrow)
             continue;
 
-        test_assign (pfid, ftag.which, ftag.t_cases [i],
-                     -1 == ftag.t_cases [i].bthrow);
+        test_assign (pfid, test.which, test.cases [i],
+                     -1 == test.cases [i].bthrow);
     }
 }
 
@@ -1000,11 +961,12 @@
 static void
 run_test (const MemFun *pfid)
 {
-    if (MemFun::UserTraits == pfid->tid_ && rw_opt_no_user_traits) {
+    if (StringMembers::UserTraits == pfid->tid_ && rw_opt_no_user_traits) {
         rw_note (1 < rw_opt_no_user_traits++, 0, 0,
                  "user defined traits test disabled");
     }
-    else if (MemFun::DefaultTraits == pfid->tid_  && rw_opt_no_char_traits) {
+    else if (   StringMembers::DefaultTraits == pfid->tid_
+             && rw_opt_no_char_traits) {
         rw_note (1 < rw_opt_no_char_traits++, 0, 0,
                  "char_traits test disabled");
     }
@@ -1014,18 +976,17 @@
             rw_note (1 < rw_opt_no_exceptions++, 0, 0,
                      "string::assign exceptions tests disabled");
 
-        static const std::size_t ftags =
-            sizeof function_tags / sizeof *function_tags;
+        static const std::size_t ntests = sizeof tests / sizeof *tests;
 
-        for (std::size_t i = 0; i < ftags; i++) {
+        for (std::size_t i = 0; i < ntests; i++) {
 
-            if (rw_opt_no_assign [function_tags [i].which])
+            if (Disabled (tests [i].which))
                 rw_note (0, 0, 0,
                          "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::"
                          "%s test disabled", pfid->cname_, pfid->tname_,
-                         pfid->aname_, function_tags [i].funsig);
+                         pfid->aname_, tests [i].funsig);
             else
-                test_assign (pfid, function_tags [i]);
+                test_assign (pfid, tests [i]);
         }
     }
 }
@@ -1043,13 +1004,14 @@
 
     if (rw_enabled ("char")) {
 
-        MemFun fid (MemFun::Char, "char", MemFun::DefaultTraits, 0);
+        MemFun fid (StringMembers::Char, "char",
+                    StringMembers::DefaultTraits, 0);
 
         fid.tname_ = "char_traits";
 
         run_test (&fid);
 
-        fid.tid_   = MemFun::UserTraits;
+        fid.tid_   = StringMembers::UserTraits;
         fid.tname_ = "UserTraits";
 
         run_test (&fid);
@@ -1059,13 +1021,14 @@
 
     if (rw_enabled ("wchar_t")) {
 
-        MemFun fid (MemFun::WChar, "wchar_t", MemFun::DefaultTraits, 0);
+        MemFun fid (StringMembers::WChar, "wchar_t",
+                    StringMembers::DefaultTraits, 0);
 
         fid.tname_ = "char_traits";
 
         run_test (&fid);
 
-        fid.tid_   = MemFun::UserTraits;
+        fid.tid_   = StringMembers::UserTraits;
         fid.tname_ = "UserTraits";
 
         run_test (&fid);
@@ -1077,7 +1040,8 @@
         rw_note (0, 0, 0, "user defined chars test disabled");
     }
     else {
-        MemFun fid (MemFun::UChar, "UserChar", MemFun::UserTraits, 0);
+        MemFun fid (StringMembers::UChar, "UserChar",
+                    StringMembers::UserTraits, 0);
         fid.tname_ = "UserTraits";
         run_test (&fid);
     }
@@ -1116,10 +1080,12 @@
                     &rw_opt_no_exceptions,
                     &rw_opt_no_exception_safety,
 
-                    rw_opt_no_assign + assign_ptr,
-                    rw_opt_no_assign + assign_str,
-                    rw_opt_no_assign + assign_ptr_size,
-                    rw_opt_no_assign + assign_str_off_size,
-                    rw_opt_no_assign + assign_size_val,
-                    rw_opt_no_assign + assign_range);
+                    &Disabled (Assign (ptr)),
+                    &Disabled (Assign (str)),
+                    &Disabled (Assign (ptr_size)),
+                    &Disabled (Assign (str_off_size)),
+                    &Disabled (Assign (size_val)),
+                    &Disabled (Assign (range)),
+                    // sentinel
+                    (void*)0);
 }



Mime
View raw message