stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r397022 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp strings/21.string.append.cpp strings/21.string.assign.cpp strings/21.string.insert.cpp strings/21.string.op.plus.equal.cpp strings/21.string.replace.cpp
Date Tue, 25 Apr 2006 23:45:02 GMT
Author: sebor
Date: Tue Apr 25 16:44:57 2006
New Revision: 397022

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

	* 21.strings.h (run_test): Added function arguments.
	(opt_memfun_disabled, opt_no_user_char, opt_no_char_traits,
	opt_no_user_traits, opt_no_exceptions, opt_no_exception_safety,
	setvars): Removed.
	* 21.strings.cpp (_rw_char_names, _rw_traits_names, _rw_alloc_names,
	_rw_memfun_names): Moved from run_test to file scope to make them
	accessible from other functions.
	(_rw_ilog2): New helper to compute an integral base-2 logarithm.
	(_rw_setvars): Renamed from setvars and gave it internal linkage.
	(_rw_run_test): New helper. Handled command line options common
	to all tests.
	(run_test): Invoked _rw_run_test via a call to rw_test after
	setting and processing command line options common to all tests.
	* 21.string.append.cpp (run_test): Moved body into main and removed.
	(main): Called StringMembers::run_test.
	* 21.string.assign.cpp: Same.
	* 21.string.op.plus.equal.cpp: Same.
	* 21.string.replace.cpp: Same.
	* 21.string.insert.cpp: Same.

Modified:
    incubator/stdcxx/trunk/tests/include/21.strings.h
    incubator/stdcxx/trunk/tests/src/21.strings.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.append.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp
    incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp

Modified: incubator/stdcxx/trunk/tests/include/21.strings.h
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/include/21.strings.h?rev=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/21.strings.h (original)
+++ incubator/stdcxx/trunk/tests/include/21.strings.h Tue Apr 25 16:44:57 2006
@@ -247,41 +247,14 @@
 
     typedef void TestFun (const Function&, const TestCase&);
 
-    static void
-    run_test (TestFun*, const Test*, _RWSTD_SIZE_T);
+    static int
+    run_test (int, char**, const char*, const char*,
+              TestFun*, const Test*, _RWSTD_SIZE_T);
 
     enum { long_string_len = 4096 };
 
     static char
     long_string [long_string_len];
-
-    // array of integers to use for command line option
-    // processing (to disable individual overloads of all
-    // member functions)
-    static int
-    opt_memfun_disabled [sig_last];
-
-    static int opt_no_user_char;          // for --no-user_char
-    static int opt_no_char_traits;        // for --no-char_traits
-    static int opt_no_user_traits;        // for --no-user_traits
-
-    static int opt_no_exceptions;         // for --no-exceptions
-    static int opt_no_exception_safety;   // for --no-exception-safety
-
-private:
-
-    // sets the {CLASS}, {FUNC}, {FUNCSIG}, and optionally {FUNCALL}
-    // environment variables as follows:
-    // CLASS:   the name of basic_string specialization
-    // FUNC:    the name of the basic_string member function
-    // FUNCSIG: the name and signature of a specific overload
-    //          of the basic_string member function
-    // FUNCALL: a string describing the call to the basic_string member
-    //          function with function with function arguments expanded
-    //          (as specified by the TestCase argument)
-    static void
-    setvars (const Function &fun, const TestCase* = 0);
-
 };
 
 #define Disabled(which)   \

Modified: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Tue Apr 25 16:44:57 2006
@@ -41,45 +41,81 @@
 
 /**************************************************************************/
 
+static const char* const
+_rw_char_names[] = {
+    "char", "wchar_t", "UserChar"
+};
+
+
+static const char* const
+_rw_traits_names[] = {
+    "char_traits", "UserTraits"
+};
+
+
+static const char* const
+_rw_alloc_names[] = {
+    "allocator", "UserAllocator"
+};
+
+
+static const char* const
+_rw_memfun_names[] = {
+    "append", "assign", "erase", "insert", "replace", "operator+="
+};
+
+/**************************************************************************/
+
 char StringMembers::
 long_string [StringMembers::long_string_len];
 
-int StringMembers::
-opt_memfun_disabled [StringMembers::sig_last];
+static int
+_rw_opt_memfun_disabled [StringMembers::sig_last];
 
-int StringMembers::
-opt_no_user_char;
+static int
+_rw_opt_no_char_types [3];
 
-int StringMembers::
-opt_no_char_traits;
+static int
+_rw_opt_no_traits_types [2];
 
-int StringMembers::
-opt_no_user_traits;
+static int
+_rw_opt_no_alloc_types [2];
 
-int StringMembers::
-opt_no_exceptions;
+static int
+_rw_opt_no_exceptions;
 
-int StringMembers::
-opt_no_exception_safety;
+static int
+_rw_opt_no_exception_safety;
 
+/**************************************************************************/
 
-void StringMembers::
-setvars (const Function &fun, const TestCase *pcase /* = 0 */)
+// coputes integral base-2 logarithm of its argument
+static size_t
+_rw_ilog2 (size_t n)
 {
-    static const char* const char_names[] = {
-        "char", "wchar_t", "UserChar"
-    };
-
+    unsigned ilog2 = 0;
 
-    static const char* const traits_names[] = {
-        "char_traits", "UserTraits"
-    };
+    while (n >>= 1)
+        ++ilog2;
 
+    return ilog2;
+}
 
-    static const char* const allocator_names[] = {
-        "allocator", "UserAllocator"
-    };
+/**************************************************************************/
 
+// sets the {CLASS}, {FUNC}, {FUNCSIG}, and optionally {FUNCALL}
+// environment variables as follows:
+// CLASS:   the name of basic_string specialization
+// FUNC:    the name of the basic_string member function
+// FUNCSIG: the name and signature of a specific overload
+//          of the basic_string member function
+// FUNCALL: a string describing the call to the basic_string member
+//          function with function with function arguments expanded
+//          (as specified by the TestCase argument)
+void
+_rw_setvars (const StringMembers::Function &fun,
+             const StringMembers::TestCase *pcase = 0)
+{
     char*  buf     = 0;
     size_t bufsize = 0;
 
@@ -89,11 +125,12 @@
         // of the member function, and the name of the overload of the
         // member function, respectively, when no test case is given
 
-        if (   DefaultTraits == fun.traits_id_
-            && (Char == fun.char_id_ || WChar == fun.char_id_)) {
+        if (   StringMembers::DefaultTraits == fun.traits_id_
+            && (   StringMembers::Char == fun.char_id_
+                || StringMembers::WChar == fun.char_id_)) {
             // format std::string and std::wstring
-            rw_asnprintf (&buf, &bufsize,
-                          "std::%{?}w%{;}string", WChar == fun.char_id_);
+            rw_asnprintf (&buf, &bufsize, "std::%{?}w%{;}string",
+                          StringMembers::WChar == fun.char_id_);
         }
         else {
             // format std::basic_string specializations other than
@@ -101,10 +138,10 @@
             // of the default allocator for brevity
             rw_asnprintf (&buf, &bufsize,
                           "std::basic_string<%s, %s<%1$s>%{?}, %s<%1$s>%{;}>",
-                          char_names [fun.char_id_ - 1],
-                          traits_names [fun.traits_id_ - 1],
-                          DefaultAllocator != fun.alloc_id_,
-                          allocator_names [fun.alloc_id_ - 1]);
+                          _rw_char_names [fun.char_id_ - 1],
+                          _rw_traits_names [fun.traits_id_ - 1],
+                          StringMembers::DefaultAllocator != fun.alloc_id_,
+                          _rw_alloc_names [fun.alloc_id_ - 1]);
         }
 
         // set the {CLASS} variable to the name of the specialization
@@ -113,20 +150,13 @@
         rw_fprintf (0, "%{$CLASS:=*}", buf);
 
         // determine the member function name
-        const char* fname = 0;
+        const size_t funinx  = _rw_ilog2 (size_t (fun.which_) >> 5);
+        const size_t memfuns =
+            sizeof _rw_memfun_names / sizeof *_rw_memfun_names;
 
-        if (fun.which_ & mem_append)
-            fname = "append";
-        else if (fun.which_ & mem_assign)
-            fname = "assign";
-        else if (fun.which_ & mem_erase)
-            fname ="erase";
-        else if (fun.which_ & mem_insert)
-            fname ="insert";
-        else if (fun.which_ & mem_replace)
-            fname ="replace";
-        else if (fun.which_ & mem_op_plus_eq)
-            fname ="operator+=";
+        RW_ASSERT (funinx < memfuns);
+
+        const char* const fname = _rw_memfun_names [funinx];
 
         free (buf);
         buf     = 0;
@@ -169,7 +199,8 @@
             "iterator, iterator, InputIterator, InputIterator",
         };
 
-        const size_t siginx = size_t (fun.which_ & ~mem_mask) - 1U;
+        const size_t siginx =
+            size_t (fun.which_ & ~StringMembers::mem_mask) - 1U;
 
         RW_ASSERT (siginx < sizeof signatures / sizeof *signatures);
 
@@ -193,46 +224,46 @@
 
     // format and append member function arguments
     switch (fun.which_) {
-    case append_ptr:
-    case assign_ptr:
-    case op_plus_eq_ptr:
+    case StringMembers::append_ptr:
+    case StringMembers::assign_ptr:
+    case StringMembers::op_plus_eq_ptr:
         rw_asnprintf (&buf, &bufsize,
                       "%{+}(%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
                       !self, int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case append_str:
-    case assign_str:
-    case op_plus_eq_str:
+    case StringMembers::append_str:
+    case StringMembers::assign_str:
+    case StringMembers::op_plus_eq_str:
         rw_asnprintf (&buf, &bufsize,
                       "%{+}(%{?}string (%{#*s})%{;}%{?}*this%{;})",
                       !self, int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case append_ptr_size:
-    case assign_ptr_size:
+    case StringMembers::append_ptr_size:
+    case StringMembers::assign_ptr_size:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
                       !self, int (pcase->arg_len), pcase->arg,
                       self, pcase->size);
         break;
 
-    case append_str_size_size:
-    case assign_str_size_size:
+    case StringMembers::append_str_size_size:
+    case StringMembers::assign_str_size_size:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
                       !self, int (pcase->arg_len), pcase->arg, self,
                       pcase->off, pcase->size);
         break;
 
-    case append_size_val:
-    case assign_size_val:
+    case StringMembers::append_size_val:
+    case StringMembers::assign_size_val:
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%zu, %#c)", pcase->size, pcase->val);
         break;
 
-    case append_range:
-    case assign_range:
+    case StringMembers::append_range:
+    case StringMembers::assign_range:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%{?}%{#*s}%{;}%{?}this->%{;}.begin() + %zu, "
                       "%{?}%{#*s}%{;}%{?}this->%{;}.begin() + %zu)",
@@ -242,53 +273,53 @@
                       self, pcase->off + pcase->size);
         break;
 
-    case insert_size_ptr:
+    case StringMembers::insert_size_ptr:
         rw_asnprintf (&buf, &bufsize, 
                       "%{+} (%zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
                       pcase->off, !self, int (pcase->arg_len), 
                       pcase->arg, self);
         break;
 
-    case insert_size_str:
+    case StringMembers::insert_size_str:
         rw_asnprintf (&buf, &bufsize,  
                       "%{+} (%zu, %{?}string (%{#*s})%{;}%{?}*this%{;})",
                       pcase->off, !self, int (pcase->arg_len), 
                       pcase->arg, self);
         break;
 
-    case insert_size_ptr_size:
+    case StringMembers::insert_size_ptr_size:
         rw_asnprintf (&buf, &bufsize, "%{+} ("
                       "%zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
                       pcase->off, !self, int (pcase->arg_len),
                       pcase->arg, self, pcase->size2);
         break;
 
-    case insert_size_str_size_size:
+    case StringMembers::insert_size_str_size_size:
         rw_asnprintf (&buf, &bufsize, "%{+} ("
                       "%zu, %{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
                       pcase->off, !self, int (pcase->arg_len), pcase->arg,
                       self, pcase->off2, pcase->size2);
         break;
 
-    case insert_size_size_val:
+    case StringMembers::insert_size_size_val:
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%zu, %zu, %#c)",
                       pcase->off, pcase->size2, pcase->val);
         break;
 
-    case insert_size_val:
+    case StringMembers::insert_size_val:
         rw_asnprintf (&buf, &bufsize, 
                       "%{+} (begin + %zu, %zu, %#c)",
                       pcase->off, pcase->size2, pcase->val);
         break;
 
-    case insert_val:
+    case StringMembers::insert_val:
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (begin + %zu, %#c)",
                       pcase->off, pcase->val);
         break;
 
-    case insert_range:
+    case StringMembers::insert_range:
         rw_asnprintf (&buf, &bufsize, "%{+} (begin + %zu, "
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)", 
@@ -297,28 +328,28 @@
                       pcase->arg, self, pcase->off2 + pcase->size2);
         break;
 
-    case replace_size_size_ptr:
+    case StringMembers::replace_size_size_ptr:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%zu, %zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
                       pcase->off, pcase->size, !self, 
                       int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case replace_size_size_str:
+    case StringMembers::replace_size_size_str:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%zu, %zu, %{?}string (%{#*s})%{;}%{?}*this%{;})",
                       pcase->off, pcase->size, !self, 
                       int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case replace_size_size_ptr_size:
+    case StringMembers::replace_size_size_ptr_size:
         rw_asnprintf (&buf, &bufsize, "%{+}("
                       "%zu, %zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
                       pcase->off, pcase->size, !self, 
                       int (pcase->arg_len), pcase->arg, self, pcase->size2);
         break;
 
-    case replace_size_size_str_size_size:
+    case StringMembers::replace_size_size_str_size_size:
         rw_asnprintf (&buf, &bufsize, "%{+}(%zu, %zu, "
                       "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
                       pcase->off, pcase->size, !self, 
@@ -326,41 +357,41 @@
                       pcase->off2, pcase->size2);
         break;
 
-    case replace_size_size_size_val:
+    case StringMembers::replace_size_size_size_val:
         rw_asnprintf (&buf, &bufsize, 
                       "%{+}(%zu, %zu, %zu, %#c)",
                       pcase->off, pcase->size, pcase->size2, pcase->val);
         break;
 
-    case replace_iter_iter_ptr:
+    case StringMembers::replace_iter_iter_ptr:
         rw_asnprintf (&buf, &bufsize, "%{+}(begin() + %zu, begin() + %zu, "
                       "%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
                       pcase->off, pcase->off + pcase->size, 
                       !self, int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case replace_iter_iter_str:
+    case StringMembers::replace_iter_iter_str:
         rw_asnprintf (&buf, &bufsize, "%{+}(begin() + %zu, begin() + %zu, " 
                       "%{?}string (%{#*s})%{;}%{?}*this%{;})",
                       pcase->off, pcase->off + pcase->size, 
                       !self, int (pcase->arg_len), pcase->arg, self);
         break;
 
-    case replace_iter_iter_ptr_size:
+    case StringMembers::replace_iter_iter_ptr_size:
         rw_asnprintf (&buf, &bufsize, "%{+}(begin() + %zu, begin() + %zu, " 
                       "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
                       pcase->off, pcase->off + pcase->size, !self, 
                       int (pcase->arg_len), pcase->arg, self, pcase->size2);
         break;
 
-    case replace_iter_iter_size_val:
+    case StringMembers::replace_iter_iter_size_val:
         rw_asnprintf (&buf, &bufsize, 
                       "%{+}(begin() + %zu, begin() + %zu, %zu, %#c)",
                       pcase->off, pcase->off + pcase->size, 
                       pcase->size2, pcase->val);
         break;
 
-    case replace_iter_iter_range:
+    case StringMembers::replace_iter_iter_range:
         rw_asnprintf (&buf, &bufsize, "%{+}(begin() + %zu, begin() + %zu, "
                       "%{?}%{#*s}%{;}%{?}this->%{;}begin() + %zu, "
                       "%{?}%{#*s}%{;}%{?}this->%{;}begin() + %zu)", 
@@ -370,7 +401,7 @@
                       pcase->off2 + pcase->size2);
         break;
 
-    case op_plus_eq_val:
+    case StringMembers::op_plus_eq_val:
         rw_asnprintf (&buf, &bufsize,
                       "%{+} (%#c)", pcase->val);
         break;
@@ -386,66 +417,271 @@
 
 /**************************************************************************/
 
-void StringMembers::
-run_test (TestFun *test_callback, const Test *tests, size_t test_count)
+static StringMembers::TestFun*
+_rw_test_callback;
+
+static const StringMembers::Test*
+_rw_string_tests;
+
+static size_t
+_rw_string_test_count;
+
+
+static int
+_rw_run_test (int, char*[])
 {
-    if ('\0' == long_string [0]) {
+    if ('\0' == StringMembers::long_string [0]) {
         // initialize long_string
-        for (size_t i = 0; i != sizeof long_string - 1; ++i)
-            long_string [i] = 'x';
+        for (size_t i = 0; i != sizeof StringMembers::long_string - 1; ++i)
+            StringMembers::long_string [i] = 'x';
     }
 
-    static const charT char_types[] = {
-        Char, WChar, UChar,
-        UnknownChar
+    static const StringMembers::charT char_types[] = {
+        StringMembers::Char,
+        StringMembers::WChar,
+        StringMembers::UChar,
+        StringMembers::UnknownChar
     };
 
-    static const Traits traits_types[] = {
-        DefaultTraits, UserTraits,
-        UnknownTraits,
+    static const StringMembers::Traits traits_types[] = {
+        StringMembers::DefaultTraits,
+        StringMembers::UserTraits,
+        StringMembers::UnknownTraits,
     };
 
-    static const Allocator alloc_types[] = {
-        DefaultAllocator,
-        UnknownAllocator
+    static const StringMembers::Allocator alloc_types[] = {
+        StringMembers::DefaultAllocator,
+        // StringMembers::UserAllocator,   // not implemented yet
+        StringMembers::UnknownAllocator
     };
 
+    // exercise different charT specializations last
     for (size_t i = 0; char_types [i]; ++i) {
 
+        if (_rw_opt_no_char_types [i]) {
+            // issue only the first note
+            rw_note (1 < _rw_opt_no_char_types [i]++, 0, 0,
+                     "%s tests disabled", _rw_char_names [i]);
+            continue;
+        }
+
+        // exercise all specializations on Traits before those on charT
         for (size_t j = 0; traits_types [j]; ++j) {
 
+            if (_rw_opt_no_traits_types [i]) {
+                // issue only the first note
+                rw_note (1 < _rw_opt_no_traits_types [i]++, 0, 0,
+                         "%s tests disabled", _rw_traits_names [i]);
+                continue;
+            }
+
             for (size_t k = 0; alloc_types [k]; ++k) {
 
-                for (size_t m = 0; m != test_count; ++m) {
+                if (_rw_opt_no_alloc_types [i]) {
+                    // issue only the first note
+                    rw_note (1 < _rw_opt_no_alloc_types [i]++, 0, 0,
+                             "%s tests disabled",
+                             _rw_alloc_names [i]);
+                    continue;
+                }
+
+                for (size_t m = 0; m != _rw_string_test_count; ++m) {
+
+                    const StringMembers::Test& test = _rw_string_tests [m];
 
-                    const Function memfun = {
+                    // create an object uniquely identifying the overload
+                    // of the member function exercised by the set of test
+                    // cases defined to exercise it
+                    const StringMembers::Function memfun = {
                         char_types [i],
                         traits_types [j],
                         alloc_types [k],
-                        tests [m].which
+                        test.which
                     };
 
                     // set the {CLASS}, {FUNC}, and {FUNCSIG} environment
                     // variable to the name of the basic_string specializaton
                     // and its member function being exercised
-                    setvars (memfun);
+                    _rw_setvars (memfun);
 
                     rw_info (0, 0, 0, "%{$CLASS}::%{$FUNCSIG}");
 
-                    for (size_t n = 0; n != tests [m].case_count; ++n)
-                        if (rw_enabled (tests [m].cases [n].line)) {
+                    // compute the function overload's 0-based index
+                    const size_t siginx =
+                        size_t (test.which & ~StringMembers::mem_mask) - 1U;
+
+                    // check if tests of the function overload
+                    // have been disabled
+                    if (_rw_opt_memfun_disabled [siginx]) {
+                        rw_note (0, 0, 0,
+                                 "%{$CLASS}::%{$FUNCSIG} tests disabled");
+                        continue;
+                    }
+
+                    const size_t case_count = test.case_count;
+
+                    // iterate over all test cases for this function overload
+                    // invoking the test case handler for each in turn
+                    for (size_t n = 0; n != case_count; ++n) {
+
+                        const StringMembers::TestCase& tcase = test.cases [n];
+
+                        // check to see if this is an exception safety
+                        // test case and avoid running it when exception
+                        // safety has been disabled via a command line
+                        // option
+                        if (   -1 == tcase.bthrow
+                            && _rw_opt_no_exception_safety) {
+
+                            // issue only the first note
+                            rw_note (1 < _rw_opt_no_exception_safety++, 0, 0,
+                                     "exception safety tests disabled");
+                            continue;
+                        }
+
+                        // check to see if this is a test case that
+                        // involves the throwing of an exception and
+                        // avoid running it when exceptions have been
+                        // disabled
+                        if (tcase.bthrow && _rw_opt_no_exceptions) {
+
+                            // issue only the first note
+                            rw_note (1 < _rw_opt_no_exceptions++, 0, 0,
+                                     "exception tests disabled");
+                            continue;
+                        }
+
+                        // check to see if the test case is enabled
+                        if (rw_enabled (tcase.line)) {
 
                             // set the {FUNCALL} environment variable
-                            setvars (memfun, tests [m].cases + n);
+                            // to describe the function call specified
+                            // by this test case
+                            _rw_setvars (memfun, &tcase);
 
-                            test_callback (memfun, tests [m].cases [n]);
+                            // invoke the test function
+                            _rw_test_callback (memfun, tcase);
                         }
                         else
-                            rw_note (0, 0, 0,
-                                     "test on line %d disabled",
-                                     tests [m].cases [n].line);
+                            rw_note (0, 0, 0, "test on line %d disabled",
+                                     tcase.line);
+                    }
                 }
             }
         }
     }
+
+    return 0;
+}
+
+/**************************************************************************/
+
+int StringMembers::
+run_test (int         argc,
+          char       *argv [],
+          const char *file,
+          const char *clause,
+          TestFun    *test_callback,
+          const Test *tests,
+          size_t      test_count)
+{
+    // set the global variables accessed in _rw_run_test
+    _rw_test_callback     = test_callback;
+    _rw_string_tests      = tests;
+    _rw_string_test_count = test_count;
+
+#ifdef _RWSTD_NO_EXCEPTIONS
+
+    _rw_no_exceptions       = 1;
+    _rw_no_exception_safety = 1;
+
+#endif   // _RWSTD_NO_EXCEPTIONS
+
+    return rw_test (argc, argv, file, clause,
+                    0,   // comment
+                    _rw_run_test,
+                    "|-no-char# "
+                    "|-no-wchar_t# "
+                    "|-no-UserChar# "
+                    "|-no-char_traits# "
+                    "|-no-UserTraits# "
+                    "|-no-allocator# "
+                    "|-no-UserAllocator# "
+
+                    "|-no-exceptions# "
+                    "|-no-exception-safety# "
+
+                    "|-no-void# "
+                    "|-no-ptr# "
+                    "|-no-str# "
+                    "|-no-size# "
+                    "|-no-ptr_size# "
+                    "|-no-str_size_size# "
+                    "|-no-size_ptr_size# "
+                    "|-no-size_str_size_size# "
+                    "|-no-size_val# "
+                    "|-no-size_str# "
+                    "|-no-size_size# "
+                    "|-no-size_size_ptr# "
+                    "|-no-size_size_str# "
+                    "|-no-size_size_val# "
+                    "|-no-size_size_ptr_size# "
+                    "|-no-size_size_str_size_size# "
+                    "|-no-size_size_size_val# "
+                    "|-no-val# "
+                    "|-no-range# "
+                    "|-no-iter_val# "
+                    "|-no-iter_size_val# "
+                    "|-no-iter_range# "
+                    "|-no-iter_iter_ptr# "
+                    "|-no-iter_iter_str# "
+                    "|-no-iter_iter_ptr_size# "
+                    "|-no-iter_iter_size_val# "
+                    "|-no-iter_iter_range# ",
+
+                    // handlers controlling specializations of the template
+                    _rw_opt_no_char_types + 0,
+                    _rw_opt_no_char_types + 1,
+                    _rw_opt_no_char_types + 2,
+                    _rw_opt_no_traits_types + 0,
+                    _rw_opt_no_traits_types + 1,
+                    _rw_opt_no_alloc_types + 0,
+                    _rw_opt_no_alloc_types + 1,
+
+
+                    // handlers controlling exceptions
+                    &_rw_opt_no_exceptions,
+                    &_rw_opt_no_exception_safety,
+
+                    // handlers controlling specific overloads of a function
+                    _rw_opt_memfun_disabled + sig_void - 1,
+                    _rw_opt_memfun_disabled + sig_ptr - 1,
+                    _rw_opt_memfun_disabled + sig_str - 1,
+                    _rw_opt_memfun_disabled + sig_size - 1,
+                    _rw_opt_memfun_disabled + sig_ptr_size - 1,
+                    _rw_opt_memfun_disabled + sig_str_size_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_ptr_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_str_size_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_val - 1,
+                    _rw_opt_memfun_disabled + sig_size_str - 1,
+                    _rw_opt_memfun_disabled + sig_size_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_ptr - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_str - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_val - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_ptr_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_str_size_size - 1,
+                    _rw_opt_memfun_disabled + sig_size_size_size_val - 1,
+                    _rw_opt_memfun_disabled + sig_val - 1,
+                    _rw_opt_memfun_disabled + sig_range - 1,
+                    _rw_opt_memfun_disabled + sig_iter_val - 1,
+                    _rw_opt_memfun_disabled + sig_iter_size_val - 1,
+                    _rw_opt_memfun_disabled + sig_iter_range - 1,
+                    _rw_opt_memfun_disabled + sig_iter_iter_ptr - 1,
+                    _rw_opt_memfun_disabled + sig_iter_iter_str - 1,
+                    _rw_opt_memfun_disabled + sig_iter_iter_ptr_size - 1,
+                    _rw_opt_memfun_disabled + sig_iter_iter_size_val - 1,
+                    _rw_opt_memfun_disabled + sig_iter_iter_range - 1,
+
+                    // sentinel
+                    (void*)0);
 }

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=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.append.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.append.cpp Tue Apr 25 16:44:57 2006
@@ -25,18 +25,15 @@
  *
  **************************************************************************/
 
-#include <string>       // for string
-#include <stdexcept>    // for out_of_range, length_error
+#include <string>         // for string
+#include <stdexcept>      // for out_of_range, length_error
 
-#include <cstddef>      // for size_t
+#include <cstddef>        // for size_t
 
-#include <alg_test.h>   // for InputIter<>
-#include <cmdopt.h>     // for rw_enabled()
-#include <driver.h>     // for rw_test()
-#include <rw_char.h>    // for rw_widen()
-#include <rw_printf.h>  // for rw_asnprintf()
-
-#include <21.strings.h>
+#include <21.strings.h>   // for StringMembers
+#include <alg_test.h>     // for InputIter
+#include <driver.h>       // for rw_test()
+#include <rw_char.h>      // for rw_widen()
 
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
    // disabled for compilers such as IBM VAC++ or MSVC
@@ -734,7 +731,7 @@
 
 DEFINE_TEST_DISPATCH (test_append);
 
-int run_test (int, char*[])
+int main (int argc, char** argv)
 {
     static const StringMembers::Test
     tests [] = {
@@ -756,44 +753,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    StringMembers::run_test (test_append, tests, test_count);
-    
-    return 0;
-}
-
-/**************************************************************************/
-
-int main (int argc, char** argv)
-{
-    return rw_test (argc, argv, __FILE__,
-                    "lib.string.append",
-                    0 /* no comment */,
-                    run_test,
-                    "|-no-char_traits# "
-                    "|-no-user_traits# "
-                    "|-no-user_char# "
-                    "|-no-exceptions# "
-                    "|-no-exception-safety# "
-
-                    "|-no-append-ptr# "
-                    "|-no-append-str# "
-                    "|-no-append-ptr-size# "
-                    "|-no-append-str-size-size# "
-                    "|-no-append-size-val# "
-                    "|-no-append-range#",
-
-                    &StringMembers::opt_no_char_traits,
-                    &StringMembers::opt_no_user_traits,
-                    &StringMembers::opt_no_user_char,
-                    &StringMembers::opt_no_exceptions,
-                    &StringMembers::opt_no_exception_safety,
-
-                    &Disabled (Append (ptr)),
-                    &Disabled (Append (str)),
-                    &Disabled (Append (ptr_size)),
-                    &Disabled (Append (str_size_size)),
-                    &Disabled (Append (size_val)),
-                    &Disabled (Append (range)),
-                    // sentinel
-                    (void*)0);
+    return StringMembers::run_test (argc, argv, __FILE__,
+                                    "lib.string.append",
+                                    test_append, tests, test_count);
 }

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=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.assign.cpp Tue Apr 25 16:44:57 2006
@@ -25,19 +25,14 @@
  *
  **************************************************************************/
 
-#include <memory>       // for placement operator new()
-#include <string>       // for string
-#include <cstddef>      // for size_t
-#include <stdexcept>    // for out_of_range, length_error
-
-#include <alg_test.h>   // for InputIter<>
-#include <cmdopt.h>     // for rw_enabled()
-#include <driver.h>     // for rw_test()
-
-#include <rw_char.h>    // for rw_widen()
-#include <rw_printf.h>  // for rw_asnprintf()
-
-#include <21.strings.h>
+#include <string>         // for string
+#include <cstddef>        // for size_t
+#include <stdexcept>      // for out_of_range, length_error
+
+#include <21.strings.h>   // for StringMembers
+#include <alg_test.h>     // for InputIter
+#include <driver.h>       // for rw_test()
+#include <rw_char.h>      // for rw_widen()
 
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
    // disabled for compilers such as IBM VAC++ or MSVC
@@ -737,8 +732,7 @@
 
 DEFINE_TEST_DISPATCH (test_assign);
 
-static int
-run_test (int, char*[])
+int main (int argc, char** argv)
 {
     static const StringMembers::Test
     tests [] = {
@@ -760,44 +754,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    StringMembers::run_test (test_assign, tests, test_count);
-
-    return 0;
-}
-
-/**************************************************************************/
-
-int main (int argc, char** argv)
-{
-    return rw_test (argc, argv, __FILE__,
-                    "lib.string.assign",
-                    0 /* no comment */,
-                    run_test,
-                    "|-no-char_traits# "
-                    "|-no-user_traits# "
-                    "|-no-user_char# "
-                    "|-no-exceptions# "
-                    "|-no-exception-safety# "
-
-                    "|-no-assign-ptr# "
-                    "|-no-assign-str# "
-                    "|-no-assign-ptr-size# "
-                    "|-no-assign-str-size-size# "
-                    "|-no-assign-size-val# "
-                    "|-no-assign-range#",
-
-                    &StringMembers::opt_no_char_traits,
-                    &StringMembers::opt_no_user_traits,
-                    &StringMembers::opt_no_user_char,
-                    &StringMembers::opt_no_exceptions,
-                    &StringMembers::opt_no_exception_safety,
-
-                    &Disabled (Assign (ptr)),
-                    &Disabled (Assign (str)),
-                    &Disabled (Assign (ptr_size)),
-                    &Disabled (Assign (str_size_size)),
-                    &Disabled (Assign (size_val)),
-                    &Disabled (Assign (range)),
-                    // sentinel
-                    (void*)0);
+    return StringMembers::run_test (argc, argv, __FILE__,
+                                    "lib.string.assign",
+                                    test_assign, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp?rev=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.insert.cpp Tue Apr 25 16:44:57 2006
@@ -25,19 +25,15 @@
  *
  **************************************************************************/
 
-#include <string>       // for string
-#include <stdexcept>    // for out_of_range, length_error
+#include <string>         // for string
+#include <stdexcept>      // for out_of_range, length_error
 
-#include <cstddef>      // for size_t
+#include <cstddef>        // for size_t
 
-#include <cmdopt.h>     // for rw_enabled()
-#include <driver.h>     // for rw_test()
-
-#include <alg_test.h>   // for InputIter
-#include <rw_printf.h>  // for rw_asnprintf()
-#include <rw_char.h>    // for rw_widen()
-
-#include <21.strings.h>
+#include <21.strings.h>   // for StringMembers
+#include <alg_test.h>     // for InputIter
+#include <driver.h>       // for rw_test()
+#include <rw_char.h>      // for rw_widen()
 
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
    // disabled for compilers such as IBM VAC++ or MSVC
@@ -828,8 +824,7 @@
 
 DEFINE_TEST_DISPATCH (test_insert);
 
-static int
-run_test (int, char*[])
+int main (int argc, char** argv)
 {
     static const StringMembers::Test
     tests [] = {
@@ -852,48 +847,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    StringMembers::run_test (test_insert, tests, test_count);
-
-    return 0;
-}
-
-/**************************************************************************/
-
-int main (int argc, char** argv)
-{
-    return rw_test (argc, argv, __FILE__,
-                    "lib.string.insert",
-                    0 /* no comment */, run_test,
-                    "|-no-char_traits# "
-                    "|-no-user_traits# "
-                    "|-no-user_chars# "
-                    "|-no-exceptions# "
-                    "|-no-exception-safety# "
-
-                    "|-no-insert-off-ptr# "
-                    "|-no-insert-off-str# "
-                    "|-no-insert-off-ptr-size# "
-                    "|-no-insert-off-str-off-size# "
-                    "|-no-insert-off-size-val# "
-                    "|-no-insert-size-val# "
-                    "|-no-insert-val# "
-                    "|-no-insert-range#",
-
-                    &StringMembers::opt_no_char_traits,
-                    &StringMembers::opt_no_user_traits,
-                    &StringMembers::opt_no_user_char,
-                    &StringMembers::opt_no_exceptions,
-                    &StringMembers::opt_no_exception_safety,
-
-                    &Disabled (Insert (size_ptr)),
-                    &Disabled (Insert (size_str)),
-                    &Disabled (Insert (size_ptr_size)),
-                    &Disabled (Insert (size_str_size_size)),
-                    &Disabled (Insert (size_size_val)),
-                    &Disabled (Insert (val)),
-                    &Disabled (Insert (size_val)),
-                    &Disabled (Insert (range)),
-
-                    // sentinel
-                    (void*)0);
+    return StringMembers::run_test (argc, argv, __FILE__,
+                                    "lib.string.insert",
+                                    test_insert, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp?rev=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.op.plus.equal.cpp Tue Apr 25 16:44:57 2006
@@ -25,17 +25,16 @@
  *
  **************************************************************************/
 
-#include <string>       // for string
-#include <cstdlib>      // for free(), size_t
-#include <stdexcept>    // for out_of_range, length_error
-
-#include <alg_test.h>   // for InputIter
-#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 <string>        // for string
+#include <stdexcept>     // for out_of_range, length_error
+
+#include <cstddef>       // for size_t
+
+#include <21.strings.h>   // for StringMembers
+#include <alg_test.h>     // for InputIter
+#include <driver.h>       // for rw_test()
+#include <rw_char.h>      // for rw_widen()
 
-#include <21.strings.h>
 
 #ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
 #  include <rw_new.h>   // for bad_alloc, replacement operator new
@@ -444,8 +443,7 @@
 
 DEFINE_TEST_DISPATCH (test_op_plus_eq);
 
-static int
-run_test (int, char*[])
+int main (int argc, char** argv)
 {
     static const StringMembers::Test
     tests [] = {
@@ -463,39 +461,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    StringMembers::run_test (test_op_plus_eq, tests, test_count);
-
-    return 0;
-}
-
-/**************************************************************************/
-
-int main (int argc, char** argv)
-{
-    return rw_test (argc, argv, __FILE__,
-                    "lib.string.op+=",
-                    0 /* no comment */,
-                    run_test,
-                    "|-no-char_traits# "
-                    "|-no-user_traits# "
-                    "|-no-user_char# "
-                    "|-no-exceptions# "
-                    "|-no-exception-safety# "
-
-                    "|-no-op-append-ptr# "
-                    "|-no-op-append-str# "
-                    "|-no-op-append-val#",
-
-                    &StringMembers::opt_no_char_traits,
-                    &StringMembers::opt_no_user_traits,
-                    &StringMembers::opt_no_user_char,
-                    &StringMembers::opt_no_exceptions,
-                    &StringMembers::opt_no_exception_safety,
-
-                    &Disabled (OpPlusEq (ptr)),
-                    &Disabled (OpPlusEq (str)),
-                    &Disabled (OpPlusEq (val)),
-
-                    // sentinel
-                    (void*)0);
+    return StringMembers::run_test (argc, argv, __FILE__,
+                                    "lib.string.op+=",
+                                    test_op_plus_eq, tests, test_count);
 }

Modified: incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp?rev=397022&r1=397021&r2=397022&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.replace.cpp Tue Apr 25 16:44:57 2006
@@ -973,8 +973,7 @@
 
 DEFINE_TEST_DISPATCH (test_replace);
 
-static int
-run_test (int, char*[])
+int main (int argc, char** argv)
 {
     static const StringMembers::Test
     tests [] = {
@@ -999,53 +998,7 @@
 
     const std::size_t test_count = sizeof tests / sizeof *tests;
 
-    StringMembers::run_test (test_replace, tests, test_count);
-
-    return 0;
-}
-
-/**************************************************************************/
-
-int main (int argc, char** argv)
-{
-    return rw_test (argc, argv, __FILE__,
-                    "lib.string.replace",
-                    0 /* no comment */,
-                    run_test,
-                    "|-no-char_traits# "
-                    "|-no-user_traits# "
-                    "|-no-user_char# "
-                    "|-no-exceptions# "
-                    "|-no-exception-safety# "
-
-                    "|-no-replace-size-size-ptr# "
-                    "|-no-replace-size-size-str# "
-                    "|-no-replace-size-size-ptr-size# "
-                    "|-no-replace-size-size-str-size-size# "
-                    "|-no-replace-size-size-size-val# "
-                    "|-no-replace-ptr# "
-                    "|-no-replace-str# "
-                    "|-no-replace-ptr-size# "
-                    "|-no-replace-size-val# "
-                    "|-no-replace-range#",
-
-                    &StringMembers::opt_no_char_traits,
-                    &StringMembers::opt_no_user_traits,
-                    &StringMembers::opt_no_user_char,
-                    &StringMembers::opt_no_exceptions,
-                    &StringMembers::opt_no_exception_safety,
-
-                    &Disabled (Replace (size_size_ptr)),
-                    &Disabled (Replace (size_size_str)),
-                    &Disabled (Replace (size_size_ptr_size)),
-                    &Disabled (Replace (size_size_str_size_size)),
-                    &Disabled (Replace (size_size_size_val)),
-                    &Disabled (Replace (iter_iter_ptr)),
-                    &Disabled (Replace (iter_iter_str)),
-                    &Disabled (Replace (iter_iter_ptr_size)),
-                    &Disabled (Replace (iter_iter_size_val)),
-                    &Disabled (Replace (iter_iter_range)),
-
-                    // sentinel
-                    (void*)0);
+    return StringMembers::run_test (argc, argv, __FILE__,
+                                    "lib.string.replace",
+                                    test_replace, tests, test_count);
 }



Mime
View raw message