stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ant...@apache.org
Subject svn commit: r394064 - /incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp
Date Fri, 14 Apr 2006 11:29:17 GMT
Author: antonp
Date: Fri Apr 14 04:29:14 2006
New Revision: 394064

URL: http://svn.apache.org/viewcvs?rev=394064&view=rev
Log:
2006-04-14  Anton Pevtsov  <antonp@moscow.vdiweb.com>

	STDCXX-4
	* 21.string.assign.cpp: New test exercising lib.string.assign.

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

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=394064&r1=394063&r2=394064&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp Fri Apr 14 04:29:14 2006
@@ -2,275 +2,1120 @@
  *
  * 21.string.assign.cpp - test exercising [lib.string.assign]
  *
- * $Id: //stdlib/dev/tests/stdlib/string/assign.cpp#1 $
+ * $Id$
  *
  ***************************************************************************
  *
- * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License");  you may  not use this file except  in compliance with the
- * License.    You    may   obtain   a   copy   of    the   License    at
- * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
- * applicable law  or agreed to  in writing,  software  distributed under
- * the License is distributed on an "AS IS" BASIS,  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.
+ * Copyright 2006 The Apache Software Foundation or its licensors,
+ * as applicable.
  *
+ * Copyright 2006 Rogue Wave Software.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 <stdexcept>   // for out_of_range
-#include <string>
-
-#include <cmdopt.h>
-#include <driver.h>
-#include <valcmp.h>
+#include <memory>       // for placement operator new()
+#include <string>       // for string
+#include <cstdlib>      // for free(), size_t
+#include <stdexcept>    // for out_of_range, length_error
+
+#include <cmdopt.h>     // for rw_enabled()
+#include <driver.h>     // for rw_test()
+
+#include <rw_printf.h>  // for rw_asnprintf()
+#include <rw_char.h>    // for rw_widen()
+#include <alg_test.h>   // for InputIter<>
+
+#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
 
 /**************************************************************************/
 
-template <class charT>
-struct Lit
-{
-    static const charT null[];
-    static const charT space[];
-    static const charT a[];
-    static const charT n[];
-    static const charT s[];
-    static const charT x[];
-    static const charT st[];
-    static const charT abc[];
-    static const charT tes[];
-    static const charT xxx[];
-    static const charT string[];
-    static const charT firstString[];
-    static const charT firstSecondString[];
-    static const charT firstStringSecond[];
-    static const charT firFirstString[];
-    static const charT firstFirstStString[];
-    static const charT firstStndring[];
-    static const charT firstnString[];
-    static const charT firstStrings[];
-    static const charT sFirstString[];
-    static const charT secondFirstString[];
-    static const charT second[];
-    static const charT coFirstString[];
-    static const charT testString[];
-    static const charT longTest[];
+struct MemFun
+{
+    enum charT  { Char, WChar, UChar };
+    enum Traits { DefaultTraits, UserTraits };
+
+    MemFun (charT cid, const char *cname,
+          Traits tid, const char *tname)
+        : cid_ (cid), tid_ (tid), 
+          cname_ (cname), tname_ (tname), aname_ ("allocator"),
+          fname_ ("assign") { /* empty */ }
+
+    charT       cid_;     // character type id (char or wchar_t)
+    Traits      tid_;     // traits type id (default or user-defined)
+    const char *cname_;   // character type name
+    const char *tname_;   // traits name
+    const char *aname_;   // allocator name
+    const char *fname_;   // function name
 };
 
-#define LIT(member) \
-    template <class charT> const charT Lit<charT>::member[]
+/**************************************************************************/
 
+// for convenience and brevity
+#define LSTR      long_string
+#define LLEN      long_string_len
+
+static const std::size_t long_string_len = 4096;
+static char long_string [long_string_len];
+
+static const char* const exp_exceptions[] = 
+    { "unknown exception", "out_of_range", "length_error" };
+
+/**************************************************************************/
+
+typedef enum AssignTags {
+
+    // assign (const charT* s)
+    assign_ptr          =  1,   
+    // assign (const basic_string& str)
+    assign_str          =  2,
+    // assign (const charT* s, size_type n)
+    assign_ptr_size     =  3,
+    // assign (const basic_string& str, size_type pos, size_type n)
+    assign_str_off_size =  4,
+    // assign (size_type n, charT c)
+    assign_size_val     =  5,
+    // assign (InputIterator first, InputIterator last)
+    assign_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;
 
-LIT (null) = { 0 };
-LIT (space) = { ' ', 0 };
-LIT (a) = { 'a', 0 };
-LIT (n) = { 'n', 0 };
-LIT (s) = { 's', 0 };
-LIT (x) = { 'x', 0 };
-LIT (st) = { 's', 't', 0 };
-LIT (abc) = { 'a', 'b', 'c', 0 };
-LIT (tes) = { 't', 'e', 's', 0 };
-LIT (xxx) = { 'x','x','x', 0 };
-LIT (string) = { 's', 't', 'r', 'i', 'n', 'g', 0 };
-LIT (firstString) = {
-    'F', 'i', 'r', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 0
-};
-LIT (firstSecondString) = {
-    'F', 'i', 'r', 's', 't', 'S', 'e', 'c', 'o', 'n', 'd', ' ',
-    's', 't', 'r', 'i', 'n', 'g', 0
-};
-LIT (firstStringSecond) = {
-    'F', 'i', 'r', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g',
-    'S', 'e', 'c', 'o', 'n', 'd', 0
-};
-LIT (firFirstString) = {
-    'F', 'i', 'r', 'F', 'i', 'r', 's', 't', ' ',
-    's', 't', 'r', 'i', 'n', 'g', 0
-};
-LIT (firstFirstStString) = {
-    'F', 'i', 'r', 's', 't', 'F', 'i', 'r', 's', 't', ' ', 's', 't', ' ',
-    's', 't', 'r', 'i', 'n', 'g', 0
-};
-LIT (firstStndring) = {
-    'F', 'i', 'r', 's', 't', ' ', 's', 't', 'n', 'd', 'r', 'i', 'n', 'g', 0
-};
-LIT (firstnString) = {
-    'F', 'i', 'r', 's', 't', 'n', ' ', 's', 't', 'r', 'i', 'n', 'g', 0
 };
-LIT (firstStrings) = {
-    'F', 'i', 'r', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 's',  0
+
+/**************************************************************************/
+
+static int rw_opt_no_char_traits;              // for --no-char_traits
+static int rw_opt_no_user_traits;              // for --no-user_traits
+
+static int rw_opt_no_user_chars;               // for --no-user_chars
+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_assign_ptr;               // for --no-assign-ptr
+static int rw_opt_no_assign_str;               // for --no-assign-str
+static int rw_opt_no_assign_ptr_size;          // for --no-assign-ptr-size
+static int rw_opt_no_assign_str_off_size;      // for --no-assign-str-off-size
+static int rw_opt_no_assign_size_val;          // for --no-assign-size_val
+static int rw_opt_no_assign_range;             // for --no-assign-range
+
+/**************************************************************************/
+
+// used to exercise 
+// assign (const charT* s)
+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 }
+
+    //    +----------------------------------------- controlled sequence
+    //    |             +--------------------------- sequence to be assigned
+    //    |             |             +------------- expected result sequence
+    //    |             |             |        +---- exception info 
+    //    |             |             |        |         0 - no exception        
+    //    |             |             |        |         1 - out_of_range        
+    //    |             |             |        |         2 - length_error  
+    //    |             |             |        |        -1 - exc. safety
+    //    |             |             |        |                       
+    //    |             |             |        +-------+             
+    //    V             V             V                V
+    TEST ("ab",         "c",          "c",             0),
+
+    TEST ("",           "",           "",              0),
+    TEST ("",           "\0",         "",              0),
+    TEST ("",           "abc",        "abc",           0),
+    TEST ("abc",        "",           "",              0),
+
+    TEST ("\0",         "",           "",              0),
+    TEST ("\0",         "a",          "a",             0),
+    TEST ("\0",         "\0\0",       "",              0),
+
+    TEST ("\0\0ab",     "cdefghij",   "cdefghij",      0),
+    TEST ("a\0\0b",     "cdefghij",   "cdefghij",      0),
+    TEST ("ab\0\0",     "cdefghij",   "cdefghij",      0),
+    TEST ("a\0b\0\0c",  "e\0",        "e",             0),
+    TEST ("\0ab\0\0c",  "e\0",        "e",             0),
+
+    TEST ("",           LSTR,         LSTR,            0),
+    TEST (LSTR,         "",           "",              0),
+
+    TEST ("",           0,            "",              0),
+    TEST ("abc",        0,            "abc",           0),
+    TEST ("a\0\0bc",    0,            "a",             0),
+    TEST ("\0\0abc",    0,            "",              0),
+    TEST ("abc\0\0",    0,            "abc",           0),
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    TEST ("",           LSTR,         LSTR,           -1),
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    TEST ("last",       "test",       "test",          0)
 };
-LIT (sFirstString) = {
-    's', 'F', 'i', 'r', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 0
+
+/**************************************************************************/
+
+// used to exercise 
+// assign (const basic_string& str)
+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 }
+
+    //    +----------------------------------------- controlled sequence
+    //    |             +------------------------- sequence to be assigned
+    //    |             |             +------------- expected result sequence
+    //    |             |             |        +---- exception info 
+    //    |             |             |        |         0 - no exception        
+    //    |             |             |        |         1 - out_of_range        
+    //    |             |             |        |         2 - length_error  
+    //    |             |             |        |        -1 - exc. safety
+    //    |             |             |        |                       
+    //    |             |             |        +-----+             
+    //    V             V             V              V
+    TEST ("ab",         "c",          "c",           0),
+
+    TEST ("",           "",           "",            0),
+    TEST ("",           "\0",         "\0",          0),
+    TEST ("",           "abc",        "abc",         0),
+    TEST ("abc",        "",           "",            0),
+
+    TEST ("\0",         "",           "",            0),
+    TEST ("\0",         "a",          "a",           0),
+    TEST ("\0",         "\0\0",       "\0\0",        0),
+
+    TEST ("ab",         "c\0e",       "c\0e",        0),
+
+    TEST ("\0\0ab",     "cdefghij",   "cdefghij",    0),
+    TEST ("a\0\0b",     "cdefghij",   "cdefghij",    0),
+    TEST ("ab\0\0",     "cdefghij",   "cdefghij",    0),
+    TEST ("a\0b\0\0c",  "e\0",        "e\0",         0),
+    TEST ("\0ab\0\0c",  "e\0",        "e\0",         0),
+    TEST ("ab\0\0c\0",  "\0e",        "\0e",         0),
+
+    TEST ("e\0",        "a\0b\0\0c",  "a\0b\0\0c",   0),
+    TEST ("e\0\0",      "\0ab\0\0c",  "\0ab\0\0c",   0),
+    TEST ("\0e",        "ab\0\0c\0",  "ab\0\0c\0",   0),
+
+    TEST ("",           LSTR,         LSTR,          0),
+    TEST (LSTR,         "",           "",            0),
+
+    TEST ("",           0,            "",            0),
+    TEST ("abc",        0,            "abc",         0),
+    TEST ("a\0\0bc",    0,            "a\0\0bc",     0),
+    TEST ("\0\0abc",    0,            "\0\0abc",     0),
+    TEST ("abc\0\0",    0,            "abc\0\0",     0),
+
+    TEST ("last",       "test",       "test",        0)
 };
-LIT (secondFirstString) = {
-    'S', 'e', 'c', 'o', 'n', 'd', 'F', 'i', 'r', 's', 't', ' ',
-    's', 't', 'r', 'i', 'n', 'g', 0
+
+/**************************************************************************/
+
+// used to exercise 
+// assign (const charT* s, size_type n)
+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 }
+
+    //    +----------------------------------------- controlled sequence
+    //    |            +------------------------- sequence to be assigned
+    //    |            |            +------------ assign() 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, "c",           0),
+
+    TEST ("",          "",          0,  "",           0),
+    TEST ("",          "abc",       1,  "a",          0),
+    TEST ("",          "\0",        1,  "\0",         0),
+
+    TEST ("\0",        "",          0,  "",           0),
+    TEST ("\0",        "a",         0,  "",           0),
+    TEST ("\0",        "a",         1,  "a",          0),
+    TEST ("\0",        "\0\0",      1,  "\0",         0),
+    TEST ("\0",        "\0\0",      2,  "\0\0",       0),
+
+    TEST ("cde",       "ab",        2,  "ab",         0),
+    TEST ("cde",       "ab",        1,  "a",          0),
+
+    TEST ("\0e\0",     "a\0b\0\0c", 0,  "",           0),
+    TEST ("\0e\0",     "\0ab\0\0c", 3,  "\0ab",       0),
+    TEST ("\0e\0",     "a\0b\0\0c", 6,  "a\0b\0\0c",  0),
+
+    TEST ("a\0b\0\0c", "\0e\0",     3,  "\0e\0",      0),
+    TEST ("a\0b\0\0c", "\0\0e\0",   2,  "\0\0",       0),
+    TEST ("\0ab\0\0c", "\0e\0",     1,  "\0",         0),
+    TEST ("a\0bc\0\0", "\0e",       2,  "\0e",        0),
+
+    TEST ("",          0,           0,  "",           0),
+    TEST ("abc",       0,           0,  "",           0),
+    TEST ("abc",       0,           1,  "a",          0),
+    TEST ("abc",       0,           2,  "ab",         0),
+    TEST ("a\0bc",     0,           2,  "a\0",        0),
+    TEST ("\0abc\0\0", 0,           1,  "\0",         0),
+    TEST ("a\0bc\0\0", 0,           3,  "a\0b",       0),
+    TEST ("a\0bc\0\0", 0,           6,  "a\0bc\0\0",  0),
+
+    TEST ("",          LSTR, LLEN - 1,  LSTR,         0),
+    TEST ("abcd",      LSTR,        0,  "",           0),
+    TEST (LSTR,        LSTR,        0,  "",           0),
+    TEST (LSTR,        LSTR,        1,  "x",          0),
+    TEST (LSTR,        "",          0,  "",           0),
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    TEST ("",          "",         -1,  "",           2),
+
+    TEST ("",          LSTR, LLEN - 1,  LSTR,        -1),
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    TEST ("last",      "test",      4, "test",        0)
 };
-LIT (second) = { 'S', 'e', 'c', 'o', 'n', 'd', 0 };
-LIT (coFirstString) = {
-    'c', 'o', 'F', 'i', 'r', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 0
+
+/**************************************************************************/
+
+// used to exercise 
+// assign (const basic_string& str, size_type pos, size_type n)
+// assign (InputIterator first, InputIterator last)
+static const TestCase 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 }
+
+    //    +----------------------------------------- controlled sequence
+    //    |            +------------------------- sequence to be inserted
+    //    |            |            +------------ assign() pos argument
+    //    |            |            |  +--------- assign() n argument 
+    //    |            |            |  |  +------ expected result sequence
+    //    |            |            |  |  |  +--- exception info  
+    //    |            |            |  |  |  |       0 - no exception        
+    //    |            |            |  |  |  |       1 - out_of_range        
+    //    |            |            |  |  |  |       2 - length_error   
+    //    |            |            |  |  |  |      -1 - exc. safety 
+    //    |            |            |  |  |  |                         
+    //    |            |            |  |  |  +-----------+             
+    //    V            V            V  V  V              V             
+    TEST ("ab",        "c",         0, 1, "c",           0),
+
+    TEST ("",          "",          0, 0,  "",           0),
+    TEST ("",          "abc",       1, 1,  "b",          0),
+    TEST ("",          "\0",        0, 1,  "\0",         0),
+
+    TEST ("\0",        "",          0, 0,  "",           0),
+
+    TEST ("abc",       "",          0, 0,  "",           0),
+
+    TEST ("\0",        "a",         0, 1,  "a",          0),
+    TEST ("\0",        "\0\0",      1, 1,  "\0",         0),
+    TEST ("\0",        "\0\0",      0, 2,  "\0\0",       0),
+    TEST ("\0",        "\0\0",      1, 5,  "\0",         0),
+
+    TEST ("cde",       "ab",        0, 2,  "ab",         0),
+    TEST ("cde",       "ab",        0, 1,  "a",          0),
+    TEST ("cde",       "ab",        1, 5,  "b",          0),
+
+    TEST ("ab",        "c\0e",      0, 3,  "c\0e",       0),
+    TEST ("ab",        "c\0e",      1, 2,  "\0e",        0),
+    TEST ("ab",        "c\0e",      0, 2,  "c\0",        0),
+
+    TEST ("\0e\0",     "\0ab\0\0c", 0, 9,  "\0ab\0\0c",  0),
+    TEST ("\0e\0",     "\0ab\0\0c", 0, 3,  "\0ab",       0),
+    TEST ("a\0b\0\0c", "\0e\0",     0, 3,  "\0e\0",      0),
+    TEST ("a\0b\0\0c", "\0\0e\0",   0, 2,  "\0\0",       0),
+    TEST ("\0ab\0\0c", "\0e\0",     2, 1,  "\0",         0),
+    TEST ("\0ab\0\0c", "\0e\0",     2, 9,  "\0",         0),
+    TEST ("a\0bc\0\0", "\0e",       0, 2,  "\0e",        0),
+
+    TEST ("",          0,           0, 0,  "",           0),
+    TEST ("abc",       0,           1, 0,  "",           0),
+    TEST ("abc",       0,           1, 1,  "b",          0),
+    TEST ("abc",       0,           0, 2,  "ab",         0),
+    TEST ("a\0bc\0\0", 0,           4, 2,  "\0\0",       0),
+    TEST ("a\0bc\0\0", 0,           1, 3,  "\0bc",       0),
+    TEST ("a\0bc\0\0", 0,           0, 9,  "a\0bc\0\0",  0),
+    TEST ("abcdef",    0,           1, 2,  "bc",         0),
+
+    TEST (LSTR,        "",          0, 0,  "",           0),
+    TEST ("",          LSTR,        9, 2,  "xx",         0),
+    TEST ("",          LSTR,        9, 0,  "",           0),
+    TEST ("abc",       LSTR,        2, 1,  "x",          0),
+    TEST (LSTR,        LSTR,        2, 3,  "xxx",        0),
+    TEST ("",          LSTR,        0, LLEN, LSTR,       0),
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    TEST ("",          "\0",        2, 0,  "",           1),
+    TEST ("",          "a",         2, 0,  "",           1),
+    TEST ("",          LSTR,LLEN + 10, 0,  "",           1),
+
+    TEST ("",          LSTR,        0, LLEN - 1, LSTR,  -1),
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    TEST ("last",      "test",      0, 4, "test",        0)
 };
-LIT (testString) = {
-    't', 'e', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g', 0
+
+/**************************************************************************/
+
+// used to exercise 
+// assign (charT c, size_type n)
+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,            \
+      res, sizeof res - 1, bthrow }
+
+    //    +---------------------------------------controlled sequence
+    //    |            +------------------------- assign() count argument
+    //    |            |   +--------------------- character to be assigned
+    //    |            |   |   +----------------- expected result sequence 
+    //    |            |   |   |       +--------- exception info 
+    //    |            |   |   |       |             0 - no exception        
+    //    |            |   |   |       |             1 - out_of_range        
+    //    |            |   |   |       |             2 - length_error  
+    //    |            |   |   |       |            -1 - exc. safety
+    //    |            |   |   |       |                         
+    //    |            |   |   |       +--------+             
+    //    V            V   V   V                V                
+    TEST ("ab",        1, 'c', "c",             0),
+
+    TEST ("",          0, ' ',  "",             0),
+    TEST ("",          1, 'b',  "b",            0),
+    TEST ("",          3, 'b',  "bbb",          0),
+
+    TEST ("\0",        0, ' ',  "",             0),
+    TEST ("",          2, '\0', "\0\0",         0),
+
+    TEST ("\0",        1, 'a',  "a",            0),
+    TEST ("\0",        1, '\0', "\0",           0),
+    TEST ("\0",        2, '\0', "\0\0",         0),
+    TEST ("\0",        0, '\0', "",             0),
+
+    TEST ("cde",       3, 'a',  "aaa",          0),
+    TEST ("ab",        2, '\0', "\0\0",         0),
+    TEST ("ab",        1, '\0', "\0",           0),
+
+    TEST ("a\0b\0\0c", 2, '\0', "\0\0",         0),
+    TEST ("a\0b\0\0c", 1, '\0', "\0",           0),
+    TEST ("\0ab\0\0c", 3, '\0', "\0\0\0",       0),
+    TEST ("a\0bc\0\0", 2, 'a',  "aa",           0),
+
+    TEST ("",   LLEN - 1, 'x',  LSTR,           0),
+    TEST (LSTR,        0, 'x',  "",             0),
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    TEST ("",         -1, 'x',  "",             2),
+
+    TEST ("",   LLEN - 1, 'x',  LSTR,          -1),
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    TEST ("last",      4, 't',  "tttt",         0)
 };
-LIT (longTest) = {
-    'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ',
-    'v', 'e', 'r', 'y', ' ',  'l', 'o', 'n', 'g', ' ',
-    't', 'e', 's', 't', ' ',
-    's', 't', 'r', 'i', 'n', 'g', '.', 0
+
+/**************************************************************************/
+
+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 [] = {
+
+#undef TEST
+#define TEST(tag, opt, cases, hdr)                              \
+    { tag, &opt, cases, sizeof cases / sizeof *cases, hdr }     
+
+    TEST (assign_ptr, rw_opt_no_assign_ptr, ptr_test_cases,                  
+          "assign (const charT* s)"),
+
+    TEST (assign_str, rw_opt_no_assign_str, str_test_cases,            
+          "assign (const basic_string& str)"),
+
+    TEST (assign_ptr_size, rw_opt_no_assign_ptr_size, ptr_size_test_cases, 
+          "assign (const charT* s, size_type n)"),
+
+    TEST (assign_str_off_size, rw_opt_no_assign_str_off_size, 
+          range_test_cases, "assign (const basic_string& str,"
+          " size_type pos, size_type n)"),
+
+    TEST (assign_size_val, rw_opt_no_assign_size_val, 
+          size_val_test_cases, "assign (size_type n, charT c)"),
+
+    TEST (assign_range, rw_opt_no_assign_range, range_test_cases, 
+          "assign (InputIterator first, InputIterator last)")
 };
 
 /**************************************************************************/
 
-template <class charT>
-void test_assign (charT, const char *cname)
+template <class charT, class Traits>
+void test_assign_exceptions (charT, Traits*,  
+                             const ATags     which,
+                             const TestCase &cs,
+                             const char     *assign_fmt)
 {
-    _RWSTD_UNUSED (cname);
+    typedef std::basic_string <charT, Traits, 
+                               std::allocator<charT> > TestString;
+    typedef typename TestString::iterator StringIter;
+    typedef typename TestString::const_iterator ConstStringIter;
+
+    static charT wstr [LLEN];
+    static charT wsrc [LLEN];
+
+    rw_widen (wstr, cs.str, cs.str_len);
+    rw_widen (wsrc, cs.src, cs.src_len);
+
+    TestString s_str (wstr, cs.str_len);
+    TestString s_src (wsrc, cs.src_len);
+
+    std::size_t throw_after = 0;
 
-    rw_info (0, 0, 0, "Assign member with string parameter");
+    const std::size_t     size     = s_str.size ();
+    const std::size_t     capacity = s_str.capacity ();
+    const ConstStringIter begin    = s_str.begin ();
 
-    typedef std::char_traits<charT>                     Traits;
-    typedef std::allocator<charT>                       Allocator;
-    typedef std::basic_string<charT, Traits, Allocator> String;
+#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
-    typedef typename String::size_type size_type;
+    rwt_free_store* const pst = rwt_get_free_store (0);
+
+#endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+    // iterate for`n=throw_after' starting at the next call to operator
+    // new, forcing each call to throw an exception, until the assignion
+    // finally succeeds (i.e, no exception is thrown)
+    for ( ; ; ) {
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+#  ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+        *pst->throw_at_calls_ [0] = pst->new_calls_ [0] + throw_after + 1;
+
+#  endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+        _TRY {
+            if (assign_ptr == which) 
+                s_str.assign (cs.src ? wsrc : s_str.c_str ());
+
+            else if (assign_str == which)
+                s_str.assign (cs.src ? s_src : s_str);
+
+            else if (assign_ptr_size == which)
+                s_str.assign (cs.src ? wsrc : s_str.c_str (), cs.count);
+
+            else if (assign_str_off_size == which) 
+                s_str.assign (cs.src ? s_src : s_str, cs.pos, cs.count);
+
+            else if (assign_size_val == which)
+                s_str.assign (cs.count, make_char ((char) cs.ch, (charT*)0));
+
+            else if (assign_range == which)
+                s_str.assign (s_src.begin (), s_src.end ());
+
+            break;
+        }
+        _CATCH (...) {
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+            // verify that an exception thrown during allocation
+            // doesn't cause a change in the state of the vector
+
+            rw_assert (s_str.size () == size, 0, cs.line,
+                       "line %d: %s: size unexpectedly changed "
+                       "from %zu to %zu after an exception",
+                       __LINE__, assign_fmt, 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__, assign_fmt, 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__, assign_fmt, s_str.begin () - begin);
+
+
+            // increment to allow this call to operator new to succeed
+            // and force the next one to fail, and try to assign again
+            ++throw_after;
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+        }   // catch
+    }   // for
 
 #ifndef _RWSTD_NO_EXCEPTIONS
+#  ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+    // 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, 
+               0, cs.line,
+               "line %d: %s: failed to throw an expected exception",
+               __LINE__, assign_fmt);
+
+#  endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
+#else   // if defined (_RWSTD_NO_EXCEPTIONS)
+
+    _RWSTD_UNUSED (size);
+    _RWSTD_UNUSED (capacity);
+    _RWSTD_UNUSED (throw_after);
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+    *pst->throw_at_calls_ [0] = std::size_t (-1);
+
+#endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
+}
+
+/**************************************************************************/
 
+template <class charT, class Traits, class Iterator>
+void test_assign_range (charT* wstr,
+                        charT* wsrc, 
+                        Traits*,
+                        const Iterator &it,
+                        const TestCase &cs,
+                        const char     *assign_fmt)
+{
+    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";
+
+    String s_str (wstr, cs.str_len);
+    String s_src (wsrc, cs.src_len);
+
+    std::size_t off_last = cs.pos + cs.count;
+
+    if (cs.src) {
+        off_last = off_last > s_src.size () ? s_src.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));
+
+        s_str.assign (first, last);
+    }
+    else {
+        StringIter first (s_str.begin () + cs.pos);
+        StringIter last  (off_last > s_str.size () ? 
+            s_str.end () 
+          : s_str.begin () + off_last);
+
+        s_str.assign (first, last);
+    }
+
+    const std::size_t match = rw_match (cs.res, s_str.c_str(), cs.res_len);
+
+    rw_assert (match == cs.res_len, 0, cs.line,
+               "line %d. %s expected %{#*s}, got %{/*.*Gs}, "
+               "difference at pos %zu for %s", 
+               __LINE__, assign_fmt, 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_assign_range (charT* wstr, 
+                        charT* wsrc, 
+                        Traits*,
+                        const TestCase &cs,
+                        const char     *assign_fmt)
+{
+    if (cs.bthrow)  // this method doesn't throw
+        return;
+
+    test_assign_range (wstr, wsrc, (Traits*)0, 
+                       InputIter<charT>(0, 0, 0), cs, assign_fmt);
+
+    // there is no need to call test_assign_range 
+    // for other iterators in this case
+    if (0 == cs.src)
+        return;
+
+    test_assign_range (wstr, wsrc, (Traits*)0, 
+                       ConstFwdIter<charT>(0, 0, 0), cs, assign_fmt);
+
+    test_assign_range (wstr, wsrc, (Traits*)0, 
+                       ConstBidirIter<charT>(0, 0, 0), cs, assign_fmt);
+
+    test_assign_range (wstr, wsrc, (Traits*)0, 
+                       ConstRandomAccessIter<charT>(0, 0, 0), cs, assign_fmt);
+}
+
+/**************************************************************************/
+
+template <class charT, class Traits>
+void test_assign (charT, Traits*,  
+                  const ATags     which,
+                  const TestCase &cs,
+                  const char     *assign_fmt)
+{
+    typedef std::basic_string <charT, Traits, 
+                               std::allocator<charT> > TestString;
+    typedef typename TestString::iterator StringIter;
+
+    static charT wstr [LLEN];
+    static charT wsrc [LLEN];
+
+    rw_widen (wstr, cs.str, cs.str_len);
+    rw_widen (wsrc, cs.src, cs.src_len);
+
+    // special processing for assign_range to exercise all iterators
+    if (assign_range == which) {
+        test_assign_range (wstr, wsrc, (Traits*)0, cs, assign_fmt);
+        return;
+    }
+
+    TestString s_str (wstr, cs.str_len);
+    TestString s_src (wsrc, cs.src_len);
+
+    std::size_t res_off = 0;
+    std::size_t count = cs.count >= 0 ? cs.count : s_str.max_size () + 1;
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    // is some exception expected ?
+    const char* expected = 0;
+    if (1 == cs.bthrow && assign_str_off_size == which)
+        expected = exp_exceptions [1];
+    if (2 == cs.bthrow)
+        expected = exp_exceptions [2];
+
+    const char* caught = 0;
+
+    try {
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    switch (which)
     {
-        bool threw_error = false;
-        String ts(Lit<charT>::testString), nl(Lit<charT>::abc);
-        try { ts.assign(nl, nl.length() + 1, String::npos); }
-        catch (std::out_of_range) { threw_error = true; }
+    case assign_ptr: {
+        TestString& s_res = s_str.assign (cs.src ? wsrc : s_str.c_str ());
+        res_off = &s_res - &s_str;
+        break;
+    }
+
+    case assign_str: {
+        TestString& s_res = s_str.assign (cs.src ? s_src : s_str);
+        res_off = &s_res - &s_str;
+        break;
+    }
+
+    case assign_ptr_size: {
+        TestString& s_res = 
+            s_str.assign (cs.src ? wsrc : s_str.c_str (), count);
+        res_off = &s_res - &s_str;
+        break;
+    }
+
+    case assign_str_off_size: {
+        TestString& s_res = 
+            s_str.assign (cs.src ? s_src : s_str, cs.pos, count);
+        res_off = &s_res - &s_str;
+        break;
+    }
+
+    case assign_size_val: {
+        TestString& s_res = 
+            s_str.assign (count, make_char ((char) cs.ch, (charT*)0));
+        res_off = &s_res - &s_str;
+        break;
+    }
 
-        // Threw exception when pos too large
-        rw_assert ((threw_error==true), 0, __LINE__, "A1");
+    default:
+        RW_ASSERT ("test logic error: unknown assign overload");
+        return;
     }
 
+    // verify the returned value
+    rw_assert (0 == res_off, 0, cs.line,
+               "line %d. %s returned invalid reference, offset is %zu", 
+               __LINE__, assign_fmt, 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__, assign_fmt, int (cs.res_len), 
+               cs.res, cs.res_len, int (sizeof (charT)), int (s_str.size ()),
+               s_str.c_str (), s_str.size ());
+
+    // verfiy that assign results match expected result
+    const std::size_t match = rw_match (cs.res, s_str.c_str(), cs.res_len);
+
+    rw_assert (match == cs.res_len, 0, cs.line,
+               "line %d. %s expected %{#*s}, got %{/*.*Gs}, "
+               "difference at pos %zu", 
+               __LINE__, assign_fmt, int (cs.res_len), cs.res, 
+               int (sizeof (charT)), int (s_str.size ()), s_str.c_str (), 
+               match);
+
+#ifndef _RWSTD_NO_EXCEPTIONS
+
+    }
+    catch (std::out_of_range) {
+        caught = exp_exceptions[1];
+    }
+    catch (std::length_error) {
+        caught = exp_exceptions[2];
+    }
+    catch (...) {
+        caught = exp_exceptions[0];
+    }
+
+#else   // if defined (_RWSTD_NO_EXCEPTIONS)
+    _RWSTD_UNUSED (should_throw);
 #endif   // _RWSTD_NO_EXCEPTIONS
 
-  {
-    String s1, s2, s3, nl;
+    rw_assert (caught == expected, 0, cs.line,
+               "line %d. %s %{?}expected %s, caught %s"
+               "%{:}unexpectedly caught %s%{;}",
+               __LINE__, assign_fmt, 0 != expected, expected, caught, caught);
+}
+
+/**************************************************************************/
+
+void get_assign_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}).assign",
+                      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})"
+                      ".assign", pfid->cname_, pfid->tname_, pfid->aname_, 
+                      int (cs.str_len), cs.str);
+
+    const bool self = 0 == cs.src;
 
-    s1.assign(nl);
-    s2.assign(nl, 0, 5);
-    s3.assign(nl, 0, 0);
-
-    // Assigned nullString to nullString
-    rw_assert ((s1==nl) && (s2==nl) && (s3==nl), 0, __LINE__, "A2");
-
-    // Correctly references nullString
-    rw_assert (   String ().data () == s1.data ()
-               && String ().data () == s2.data ()
-               && String ().data () == s3.data (),
-                  0, __LINE__, "A3");
-  }
-  {
-    String s1, s2, s3, s4, s5, ts(Lit<charT>::testString);
-
-    s1.assign (ts);              // Whole string
-    s2.assign (ts, 0, 0);        // None of the string
-    s3.assign (ts, 0, 3);        // First three letters
-    s4.assign (ts, 5, 6);        // Second word
-    s5.assign (ts, 2, 2);        // Middle
-
-    // General Assignments
-    
-    rw_assert (s1 == ts, 0, __LINE__, "A4.1");
-    rw_assert (s2 == Lit<charT>::null, 0, __LINE__, "A4.2");
-    rw_assert (s3 == Lit<charT>::tes, 0, __LINE__, "A4.3");
-    rw_assert (s4 == Lit<charT>::string, 0, __LINE__, "A4.4");
-    rw_assert (s5 == Lit<charT>::st, 0, __LINE__, "A4.5");
-  }
-
-  rw_info (0, 0, 0, "Assign member with char pointer and maybe count");
-
-  {
-    String s1, s2, s3;
-    s1.assign (Lit<charT>::null);
-    s2.assign (Lit<charT>::null, 0, 5);
-    s3.assign (Lit<charT>::null, 0, 0);
-
-    // Assigned nullString to nullString
-    rw_assert (   (s1==Lit<charT>::null)
-               && (s2==Lit<charT>::null)
-               && (s3==Lit<charT>::null),
-               0, __LINE__, "A5");
-
-    // Correctly references nullString
-    rw_assert (   String ().data () == s1.data ()
-               && String ().data () == s2.data ()
-               && String ().data () == s3.data (),
-               0, __LINE__, "A6");
-  }
-  {
-    const charT * ts = Lit<charT>::testString;
-    String s1, s2, s3;
-    s1.assign(ts);            // Whole string
-    s2.assign(ts, 0, 0);         // None of the string
-    s3.assign(ts, 0, 3);         // First three letters
-
-    // General Assignments
-    rw_assert (s1 == ts && s2 == Lit<charT>::null && s3 == Lit<charT>::tes,
-               0, __LINE__, "A7");
-  }
-
-  rw_info (0, 0, 0, "Assign member with char and repetition count");
-
-  {
-    String s1;
-    s1.assign(0, Lit<charT>::space[0]);
-
-    // Assigned nullString to nullString
-    rw_assert ((s1==Lit<charT>::null), 0, __LINE__, "A8");
-
-    // Correctly references nullString
-    rw_assert (String ().data () == s1.data (), 0, __LINE__, "A9");
-  }
-  {
-    String s1, s2, s3;
-    s1.assign(1, Lit<charT>::x[0]);
-    s2.assign(0, Lit<charT>::x[0]);
-    s3.assign(3, Lit<charT>::x[0]);
-
-    // General Assignments
-    rw_assert (   (s1 == Lit<charT>::x)
-               && (s2 == Lit<charT>::null)
-               && (s3 == Lit<charT>::xxx),
-               0, __LINE__, "A10");
-  }
+    switch (which)
+    {
+    case assign_ptr:
+        rw_asnprintf (pbuf, pbufsize, 
+                      "%{+} (%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
+                      !self, int (cs.src_len), cs.src, self);
+        break;
+
+    case assign_str:
+        rw_asnprintf (pbuf, pbufsize, 
+                      "%{+} (%{?}string (%{#*s})%{;}%{?}*this%{;})",
+                      !self, int (cs.src_len), cs.src, self);
+        break;
+
+    case assign_ptr_size:
+        rw_asnprintf (pbuf, pbufsize, "%{+} ("
+                      "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
+                      !self, int (cs.src_len), cs.src, self, cs.count);
+        break;
+
+    case assign_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 assign_size_val:
+        rw_asnprintf (pbuf, pbufsize, 
+                      "%{+} (%zu, %#c)", cs.count, cs.ch);
+        break;
+
+    case assign_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;
+    }
 }
 
 /**************************************************************************/
 
-int run_test (int, char*[])
+void test_assign (const MemFun *pfid, const ATags which, 
+                  const TestCase& cs, bool exc_safety_test)
 {
-    if (rw_enabled ("char"))
-        test_assign (char (), "char");
+    char* buf = 0;
+    std::size_t buf_sz = 0;
+    get_assign_format (&buf, &buf_sz, pfid, which, cs); 
+
+#undef TEST
+#define TEST(charT, Traits)	                                           \
+    !exc_safety_test ?                                                 \
+        test_assign (charT(), (Traits*)0, which, cs, buf)              \
+      : test_assign_exceptions (charT(), (Traits*)0, which, cs, buf)
+
+    if (MemFun:: DefaultTraits == pfid->tid_) {
+        if (MemFun::Char == pfid->cid_)
+            TEST (char, std::char_traits<char>);
+
+#ifndef _RWSTD_NO_WCHAR_T
     else
-        rw_note (0, __FILE__, __LINE__, "char test disabled");
+        TEST (wchar_t, std::char_traits<wchar_t>);
+#endif   // _RWSTD_NO_WCHAR_T
+
+    }
+    else {
+       if (MemFun::Char == pfid->cid_)
+           TEST (char, UserTraits<char>);
 
 #ifndef _RWSTD_NO_WCHAR_T
+       else if (MemFun::WChar == pfid->cid_)
+           TEST (wchar_t, UserTraits<wchar_t>);
+#endif   // _RWSTD_NO_WCHAR_T
+
+       else
+           TEST (UserChar, UserTraits<UserChar>);
+    }
+
+    free (buf);
+}
+
+/**************************************************************************/
+
+static void
+test_assign (const MemFun *pfid, const FunctionTag& ftag)
+{
+    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);
+
+    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);
+
+#ifdef _RWSTD_NO_REPLACEABLE_NEW_DELETE
 
-    if (rw_enabled ("wchar_t"))
-        test_assign (wchar_t (), "wchar_t");
     else
-        rw_note (0, __FILE__, __LINE__, "wchar_t test disabled");
+        rw_warn (0, 0, __LINE__,
+                 "%s exception safety test: no replacable new and delete",
+                 ftag.str_hdr);
+
+#endif  //_RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+    for (std::size_t i = 0; i != ftag.n_cases; ++i) {
+
+        if (!rw_enabled (ftag.t_cases[i].line)) {
+            rw_note (0, 0, __LINE__, 
+                     "test on line %d disabled", ftag.t_cases[i].line);
+            continue;
+        }
+
+        // do not exercise exceptions if they were disabled
+        if (0 != rw_opt_no_exceptions && 0 != ftag.t_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)
+            continue;
 
-#endif   // _RWSTD_NO_WCHAR_T
+        test_assign (pfid, ftag.a_tag, ftag.t_cases[i], 
+                     -1 == ftag.t_cases[i].bthrow);
+    }
+}
 
-    return 0;
 
+/**************************************************************************/
+
+static void
+run_test (const MemFun *pfid)
+{
+    if (MemFun::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) {
+        rw_note (1 < rw_opt_no_char_traits++, 0, 0,
+                 "char_traits test disabled");
+    }
+    else {
+
+        if (rw_opt_no_exceptions)
+            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;
+
+        for (std::size_t i = 0; i < ftags; i++) {
+
+            if (*function_tags[i].p_opt) 
+                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);
+            else
+                test_assign (pfid, function_tags[i]);
+        }
+    }
 }
 
 /**************************************************************************/
 
-int main (int argc, char *argv[])
+int run_test (int, char*[])
+{
+    if ('\0' == LSTR [0]) {
+        // initialize LSTR
+        for (std::size_t i = 0; i != sizeof LSTR - 1; ++i)
+            LSTR [i] = 'x';
+    }
+
+    if (rw_enabled ("char")) {
+
+        MemFun fid (MemFun::Char, "char", MemFun::DefaultTraits, 0);
+
+        fid.tname_ = "char_traits";
+
+        run_test (&fid);
+
+        fid.tid_   = MemFun::UserTraits;
+        fid.tname_ = "UserTraits";
+
+        run_test (&fid);
+    }
+    else
+        rw_note (0, 0, 0, "string::assign char tests disabled");
+
+    if (rw_enabled ("wchar_t")) {
+
+        MemFun fid (MemFun::WChar, "wchar_t", MemFun::DefaultTraits, 0);
+
+        fid.tname_ = "char_traits";
+
+        run_test (&fid);
+
+        fid.tid_   = MemFun::UserTraits;
+        fid.tname_ = "UserTraits";
+
+        run_test (&fid);
+    }
+    else
+        rw_note (0, 0, 0, "string::assign wchar tests disabled");
+
+    if (rw_opt_no_user_chars) {
+        rw_note (0, 0, 0, "user defined chars test disabled");
+    }
+    else {
+        MemFun fid (MemFun::UChar, "UserChar", MemFun::UserTraits, 0);
+        fid.tname_ = "UserTraits";
+        run_test (&fid);
+    }
+
+    // silence a bogus EDG eccp remark #550-D:
+    // variable "exp_exceptions" was set but never used
+    _RWSTD_UNUSED (exp_exceptions);
+
+    return 0;
+}
+
+/**************************************************************************/
+
+int main (int argc, char** argv)
 {
     return rw_test (argc, argv, __FILE__,
                     "lib.string.assign",
                     0 /* no comment */, run_test,
-                    0 /* co command line options */);
+                    "|-no-char_traits# "
+                    "|-no-user_traits# "
+                    "|-no-user_chars# "
+                    "|-no-exceptions# "
+                    "|-no-exception-safety# "
+
+                    "|-no-assign-ptr# "
+                    "|-no-assign-str# "
+                    "|-no-assign-ptr-size# "
+                    "|-no-assign-str-off-size# "
+                    "|-no-assign-size-val# "
+                    "|-no-assign-range#",
+
+                    &rw_opt_no_char_traits,
+                    &rw_opt_no_user_traits,
+                    &rw_opt_no_user_chars,
+                    &rw_opt_no_exceptions,
+                    &rw_opt_no_exception_safety,
+
+                    &rw_opt_no_assign_ptr,
+                    &rw_opt_no_assign_str,
+                    &rw_opt_no_assign_ptr_size,
+                    &rw_opt_no_assign_str_off_size,
+                    &rw_opt_no_assign_size_val,
+                    &rw_opt_no_assign_range);
 }
+



Mime
View raw message