You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/04/21 23:13:32 UTC
svn commit: r396006 [1/2] - in /incubator/stdcxx/trunk/tests:
include/21.strings.h src/21.strings.cpp strings/21.string.replace.cpp
Author: sebor
Date: Fri Apr 21 14:13:30 2006
New Revision: 396006
URL: http://svn.apache.org/viewcvs?rev=396006&view=rev
Log:
2006-04-21 Martin Sebor <se...@roguewave.com>
* 21.strings.h (append_last, assign_last, insert_last, replace_last):
Made constants one greater than the last valid index for each member
function.
(append_overloads, assign_overloads, insert_overloads,
replace_overloads, member_functions): Removed from the definition
of the MemberFunction enumeration and moved them into an enum of
their own.
(append, assign, insert, replace): Removed.
* 21.strings.cpp (format): Adjusted for the above, simplified the
formatting of basic_string template arguments by leaving out the
name of the default allocator for brevity. Implemented the formatting
for replace.
2006-04-21 Anton Pevtsov <an...@moscow.vdiweb.com>
Martin Sebor <se...@roguewave.com>
* 21.string.replace.cpp (<21.strings.h>, StringMembers): Included
header and used class to simplify.
(ReplaceTags, TestCase, rw_opt_no_replace_*): Removed, replaced with
StringMembers equivalents.
(test_exceptions, test_replace_range, test_replace): Made locals const
wherever appropriate.
Modified:
incubator/stdcxx/trunk/tests/include/21.strings.h
incubator/stdcxx/trunk/tests/src/21.strings.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=396006&r1=396005&r2=396006&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/21.strings.h (original)
+++ incubator/stdcxx/trunk/tests/include/21.strings.h Fri Apr 21 14:13:30 2006
@@ -61,14 +61,10 @@
append_size_val,
// append (InputIterator, InputIterator)
append_range,
- append_last = append_range,
-
- // number of member function overloads
- append_overloads = append_last - append_first,
+ append_last,
//////////////////////////////////////////////////////////////
- assign,
- assign_first = assign,
+ assign_first = append_last,
// assign (const value_type*)
assign_ptr = assign_first,
// assign (const basic_string&)
@@ -81,14 +77,10 @@
assign_size_val,
// assign (InputIterator, InputIterator)
assign_range,
- assign_last = assign_range,
-
- // number of member function overloads
- assign_overloads = assign_last - assign_first,
+ assign_last,
//////////////////////////////////////////////////////////////
- insert,
- insert_first = insert,
+ insert_first = assign_last,
// insert (size_type, const value_type*)
insert_off_ptr = insert_first,
// insert (size_type, const basic_string&)
@@ -105,14 +97,10 @@
insert_size_val,
// insert (iterator p, InputIterator, InputIterator)
insert_range,
- insert_last = insert_range,
-
- // number of member function overloads
- insert_overloads = insert_last - insert_first,
+ insert_last,
//////////////////////////////////////////////////////////////
- replace,
- replace_first = replace,
+ replace_first = insert_last,
// (size_type, size_type, const value_type*)
replace_off_size_ptr = replace_first,
// (size_type, size_type, basic_string&)
@@ -133,14 +121,21 @@
replace_size_val,
// (iterator, iterator, InputIterator, InputIterator)
replace_range,
- replace_last = replace_range,
+ replace_last
+ };
+ enum {
+ // number of member function overloads
+ append_overloads = append_last - append_first,
+ // number of member function overloads
+ assign_overloads = assign_last - assign_first,
+ // number of member function overloads
+ insert_overloads = insert_last - insert_first,
// number of member function overloads
replace_overloads = replace_last - replace_first,
-
- //////////////////////////////////////////////////////////////
- // must be last: total number of member functions
- member_functions
+ // total number of member functions
+ member_functions = append_overloads + assign_overloads
+ + insert_overloads + replace_overloads
};
// describes a single test case for any overload
Modified: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=396006&r1=396005&r2=396006&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Fri Apr 21 14:13:30 2006
@@ -79,26 +79,39 @@
const bool self = 0 == tcase.arg;
- if ( DefaultTraits == tid
- && (Char == cid || WChar == cid))
+ if (DefaultTraits == tid && (Char == cid || WChar == cid)) {
+ // format std::string and std::wstring
rw_asnprintf (&buf, &bufsize,
"std::%{?}w%{;}string (%{?}%{#*s}%{;}).",
WChar == cid,
tcase.str != 0, int (tcase.str_len), tcase.str);
- else
+ }
+ else {
+ // format std::basic_string specializations other than
+ // std::string and std::wstring, leaving out the name
+ // of the default allocator for brevity
rw_asnprintf (&buf, &bufsize,
- "std::basic_string<%s, %s<%1$s>, %s<%1$s>>"
+ "std::basic_string<%s, %s<%1$s>%{?}, %s<%1$s>%{;}>"
"(%{?}%{#*s}%{;}).",
char_names [cid],
traits_names [tid],
- allocator_names [aid],
+ DefaultAllocator != aid, allocator_names [aid],
tcase.str != 0, int (tcase.str_len), tcase.str);
+ }
- const char *fname = "assign";
+ const char* fname = 0;
+
+ if (append_first <= tcase.which && tcase.which < append_last)
+ fname = "append";
+ else if (assign_first <= tcase.which && tcase.which < assign_last)
+ fname = "assign";
+ else if (insert_first <= tcase.which && tcase.which < insert_last)
+ fname ="insert";
+ else if (replace_first <= tcase.which && tcase.which < replace_last)
+ fname ="replace";
switch (tcase.which) {
case append_ptr:
- fname = "append";
case assign_ptr:
rw_asnprintf (&buf, &bufsize,
"%{+}%s (%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
@@ -106,7 +119,6 @@
break;
case append_str:
- fname = "append";
case assign_str:
rw_asnprintf (&buf, &bufsize,
"%{+}%s (%{?}string (%{#*s})%{;}%{?}*this%{;})",
@@ -114,7 +126,6 @@
break;
case append_ptr_size:
- fname = "append";
case assign_ptr_size:
rw_asnprintf (&buf, &bufsize, "%{+}%s ("
"%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
@@ -123,7 +134,6 @@
break;
case append_str_off_size:
- fname = "append";
case assign_str_off_size:
rw_asnprintf (&buf, &bufsize, "%{+}%s ("
"%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
@@ -132,21 +142,92 @@
break;
case append_size_val:
- fname = "append";
case assign_size_val:
rw_asnprintf (&buf, &bufsize,
"%{+} %s (%zu, %#c)", tcase.size, tcase.val);
break;
case append_range:
- fname = "append";
case assign_range:
rw_asnprintf (&buf, &bufsize, "%{+}%s ("
- "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
- "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)",
+ "%{?}%{#*s}%{;}%{?}this->%{;}begin() + %zu, "
+ "%{?}%{#*s}%{;}%{?}this->%{;}.begin() + %zu)",
fname, !self, int (tcase.arg_len), tcase.arg,
self, tcase.off, !self, int (tcase.arg_len), tcase.arg,
self, tcase.off + tcase.size);
+ break;
+
+ case replace_off_size_ptr:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+ "%zu, %zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
+ fname, tcase.off, tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self);
+ break;
+
+ case replace_off_size_str:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+ "%zu, %zu, %{?}string (%{#*s})%{;}%{?}*this%{;})",
+ fname, tcase.off, tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self);
+ break;
+
+ case replace_off_size_ptr_size:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+ "%zu, %zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
+ fname, tcase.off, tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self, tcase.size2);
+ break;
+
+ case replace_off_size_str_off_size:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s (%zu, %zu, "
+ "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
+ fname, tcase.off, tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self,
+ tcase.off2, tcase.size2);
+ break;
+
+ case replace_off_size_size_val:
+ rw_asnprintf (&buf, &bufsize,
+ "%{+}%s (%zu, %zu, %zu, %#c)",
+ fname, tcase.off, tcase.size, tcase.size2, tcase.val);
+ break;
+
+ case replace_ptr:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s (begin() + %zu, begin() + %zu, "
+ "%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
+ fname, tcase.off, tcase.off + tcase.size,
+ !self, int (tcase.arg_len), tcase.arg, self);
+ break;
+
+ case replace_str:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s (begin() + %zu, begin() + %zu, "
+ "%{?}string (%{#*s})%{;}%{?}*this%{;})",
+ fname, tcase.off, tcase.off + tcase.size,
+ !self, int (tcase.arg_len), tcase.arg, self);
+ break;
+
+ case replace_ptr_size:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s (begin() + %zu, begin() + %zu, "
+ "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
+ fname, tcase.off, tcase.off + tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self, tcase.size2);
+ break;
+
+ case replace_size_val:
+ rw_asnprintf (&buf, &bufsize,
+ "%{+}%s (begin() + %zu, begin() + %zu, %zu, %#c)",
+ fname, tcase.off, tcase.off + tcase.size,
+ tcase.size2, tcase.val);
+ break;
+
+ case replace_range:
+ rw_asnprintf (&buf, &bufsize, "%{+}%s (begin() + %zu, begin() + %zu, "
+ "%{?}%{#*s}%{;}%{?}this->%{;}begin() + %zu, "
+ "%{?}%{#*s}%{;}%{?}this->%{;}begin() + %zu)",
+ fname, tcase.off, tcase.off + tcase.size, !self,
+ int (tcase.arg_len), tcase.arg, self, tcase.off2, !self,
+ int (tcase.arg_len), tcase.arg, self,
+ tcase.off2 + tcase.size2);
break;
default: