stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r407130 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp
Date Wed, 17 May 2006 02:56:34 GMT
Author: sebor
Date: Tue May 16 19:56:33 2006
New Revision: 407130

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

	* 21.strings.h (TEST_DISPATCH): Added an Alloc parameter.
	(DEFINE_TEST_DISPATCH): Introduced a transitional overload of
	the dispatch function template taking an Allocator argument
	and dispatching to the test-defined one which doesn't take
	one.
	(DEFINE_STRING_TEST_DISPATCH): New macro to define a dispatch
	function to invoke a test-defined function template with an
	Allocator argument.
	(rw_disable_user_allocator): Transitional variable to disable
	tests exercising basic_string with a user-defined allocator.
	* 21.strings.cpp (rw_disable_user_allocator): Defined.
	(_rw_run_test): Conditionally enabled tests exercising user
	defined allocators.
	("|-enable-size-const#"): Added a missing command line option.

Modified:
    incubator/stdcxx/trunk/tests/include/21.strings.h
    incubator/stdcxx/trunk/tests/src/21.strings.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=407130&r1=407129&r2=407130&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/21.strings.h (original)
+++ incubator/stdcxx/trunk/tests/include/21.strings.h Tue May 16 19:56:33 2006
@@ -499,38 +499,39 @@
 #define Disabled(which)   \
     StringMembers::opt_memfun_disabled [which & ~StringMembers::mem_mask]
 
+
 #ifndef _RWSTD_NO_WCHAR_T
-#  define TEST_DISPATCH(fname, memfun, tcase)                   \
+#  define TEST_DISPATCH(Alloc, fname, memfun, tcase)            \
     if (StringMembers::DefaultTraits == memfun.traits_id_) {    \
         if (StringMembers::Char == memfun.char_id_)             \
             fname (char (), (std::char_traits<char>*)0,         \
-                   memfun.which_, tcase);                       \
+                   (Alloc<char>*)0, memfun.which_, tcase);      \
         else if (StringMembers::WChar == memfun.char_id_)       \
             fname (wchar_t (), (std::char_traits<wchar_t>*)0,   \
-                   memfun.which_, tcase);                       \
+                   (Alloc<wchar_t>*)0, memfun.which_, tcase);   \
         else                                                    \
             rw_note (0, 0, 0,                                   \
                      "%{$CLASS} tests not implemented");        \
     }                                                           \
     else {                                                      \
-       if (StringMembers::Char == memfun.char_id_)              \
-           fname (char (), (UserTraits<char>*)0,                \
-                  memfun.which_, tcase);                        \
+        if (StringMembers::Char == memfun.char_id_)             \
+            fname (char (), (UserTraits<char>*)0,               \
+                   (Alloc<char>*)0, memfun.which_, tcase);      \
        else if (StringMembers::WChar == memfun.char_id_)        \
-           fname (wchar_t (), (UserTraits<wchar_t>*)0,          \
-                  memfun.which_, tcase);                        \
+            fname (wchar_t (), (UserTraits<wchar_t>*)0,         \
+                   (Alloc<wchar_t>*)0, memfun.which_, tcase);   \
        else                                                     \
            fname (UserChar (), (UserTraits<UserChar>*)0,        \
-                  memfun.which_, tcase);                        \
+                  (Alloc<UserChar>*)0, memfun.which_, tcase);   \
     }                                                           \
     (void)0
 
 #else   // if defined (_RWSTD_NO_WCHAR_T)
-#  define TEST_DISPATCH(fname, memfun, tcase)                   \
+#  define TEST_DISPATCH(Alloc, fname, memfun, tcase)            \
     if (StringMembers::DefaultTraits == memfun.traits_id_) {    \
         if (StringMembers::Char == memfun.char_id_)             \
             fname (char (), (std::char_traits<char>*)0,         \
-                   memfun.which_, tcase);                       \
+                   (Alloc<char>*)0, memfun.which_, tcase);      \
         else if (StringMembers::WChar == memfun.char_id_)       \
             RW_ASSERT (!"logic error: wchar_t disabled");       \
         else                                                    \
@@ -541,22 +542,50 @@
     else {                                                      \
         if (StringMembers::Char == memfun.char_id_)             \
             fname (char (), (UserTraits<char>*)0,               \
-                   memfun.which_, tcase);                       \
+                   (Alloc<char>*)0, memfun.which_, tcase);      \
         else if (StringMembers::WChar == memfun.char_id_)       \
              RW_ASSERT (!"logic error: wchar_t disabled");      \
         else if (StringMembers::UChar == memfun.char_id_)       \
             fname (UserChar (), (UserTraits<UserChar>*)0,       \
-                   memfun.which_, tcase);                       \
+                   (Alloc<UserChar>*)0, memfun.which_, tcase);  \
     }                                                           \
     (void)0
 
 #endif   // _RWSTD_NO_WCHAR_T
 
 
+extern _TEST_EXPORT
+int rw_disable_user_allocator;
+
+
+// transitional, to be replaced by DEFINE_STRING_TEST_DISPATCH()
 #define DEFINE_TEST_DISPATCH(fname)                             \
+    template <class charT, class Traits, class Allocator>       \
+    void                                                        \
+    fname (charT, Traits*, Allocator*,                          \
+           StringMembers::OverloadId which,                     \
+           const StringMembers::TestCase &tcase) {              \
+        fname (charT (), (Traits*)0, which, tcase);             \
+    }                                                           \
+                                                                \
     static void                                                 \
     fname (const MemFun &memfun, const TestCase &tcase) {       \
-        TEST_DISPATCH (fname, memfun, tcase);                   \
+        /* disable tests exercising user-define allocator */    \
+        rw_disable_user_allocator = 1;                          \
+        TEST_DISPATCH (std::allocator, fname, memfun, tcase);   \
+    } typedef void rw_unused_typedef
+
+#define DEFINE_STRING_TEST_DISPATCH(fname)                              \
+    static void                                                         \
+    fname (const MemFun &memfun, const TestCase &tcase) {               \
+        if (StringMembers::DefaultAllocator == memfun.alloc_id_) {      \
+            TEST_DISPATCH (std::allocator, fname, memfun, tcase);       \
+        }                                                               \
+        else if (StringMembers::UserAllocator == memfun.alloc_id_) {    \
+            TEST_DISPATCH (UserAlloc, fname, memfun, tcase);            \
+        }                                                               \
+        else                                                            \
+            RW_ASSERT (!"logic error: bad allocator");                  \
     } typedef void rw_unused_typedef
     
 

Modified: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=407130&r1=407129&r2=407130&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Tue May 16 19:56:33 2006
@@ -716,6 +716,11 @@
 _rw_string_test_count;
 
 
+// TODO: remove this
+_TEST_EXPORT
+int rw_disable_user_allocator;
+
+
 static int
 _rw_run_test (int, char*[])
 {
@@ -784,7 +789,7 @@
 
     static const StringMembers::Allocator alloc_types[] = {
         StringMembers::DefaultAllocator,
-        // StringMembers::UserAllocator,   // not implemented yet
+        StringMembers::UserAllocator,
         StringMembers::UnknownAllocator
     };
 
@@ -818,6 +823,12 @@
 
             for (size_t k = 0; alloc_types [k]; ++k) {
 
+                // TODO: remove this as soon as user-defined allocators
+                // are fully exercised
+                if (   StringMembers::UserAllocator == alloc_types [k]
+                    && rw_disable_user_allocator)
+                    continue;
+
                 if (_rw_opt_no_alloc_types [k]) {
                     // issue only the first note
                     rw_note (1 < _rw_opt_no_alloc_types [k]++, _rw_this_file,
@@ -945,6 +956,7 @@
                     "|-enable-ptr# "
                     "|-enable-str# "
                     "|-enable-size# "
+                    "|-enable-size-const# "
                     "|-enable-ptr_size# "
                     "|-enable-str_size# "
                     "|-enable-ptr_size_size# "



Mime
View raw message