Anton Pevtsov wrote:
The attached file contains new test version updated according your
notes.

I used different array here, but may be it will be useful to create
another one using bitmaps and compare these versions.

I made a simplifying change to get_insert_format (I used the %{+}
directive to append directly to the buffer). See the attached diff.
I also removed all trailing blanks (not shown in the diff). With
these changes please go ahead and commit the test.

I see a number of failed assertions when I compile the test with
gcc 4.1.0 and run it on Solaris (also attached). Are those expected?
I.e., is there actually a problem with the library? If so (i.e., if
you can reproduce the problem), could you put together a small test
case and open an issue in Jira?


I found an issue in the rw_widen function implementation for chars:
[...]
I corrected this by adding '\0' symbol to the end of the resulting array
(char.cpp, line 248)

...
           // copy src into dst
           memcpy (dst, src, len);
           dst [len] = '\0';
...

What do you think about it?

Could you please enhance the 0.char.cpp test to exercise this and
commit both the enhanced test as well as your patch?


Also I split rw_assert's formatting parameters into three parts using rw_asnprintf function.

Current test version doesn't contain exception safety tests. I am
working on them.

Sounds good.

While I'm gone, please continue to work on the tests. You might as
well commit your work (tests only) so you don't accidentally lose
anything. I'll review it as I have time or when I get back.

Thanks!
Martin
--- /nfs/b20/sebor/tmp/21.string.insert.cpp     Wed Mar 29 12:58:03 2006
+++ /build/sebor/dev/stdlib/tests/strings/21_insert.cpp Thu Mar 30 19:08:45 2006
@@ -26,11 +26,9 @@
  **************************************************************************/
 
 #include <string>       // for string
-#include <cstddef>      // for size_t
+#include <cstdlib>      // for free(), size_t
 #include <stdexcept>    // for out_of_range, length_error
 
-#include <stdlib.h>
-
 #include <cmdopt.h>     // for rw_enabled()
 #include <driver.h>     // for rw_test()
 
@@ -837,73 +835,74 @@
                         const ITags which, 
                         const TestCase& cs)
 {
-    char* tmpbuf = 0;
-    std::size_t tmpbufsz = 0;
-
-    rw_asnprintf (&tmpbuf, &tmpbufsz, 
-                  "std::basic_string<%s, %s<%2$s>, %s<%2$s>>(%{#*s})",
+    if (   MemFun::DefaultTraits == pfid->tid_
+        && (MemFun::Char == pfid->cid_ || MemFun::WChar == pfid->cid_))
+        rw_asnprintf (pbuf, pbufsize,
+                      "std::%{?}w%{;}string (%{#*s}).insert",
+                      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})",
                   pfid->cname_, pfid->tname_, pfid->aname_, 
                   int (cs.str_len), cs.str);
 
     const bool self = 0 == cs.src;
 
-    switch (which)
-    {
+    switch (which) {
     case insert_off_ptr:
         rw_asnprintf (pbuf, pbufsize, 
-                      "%s.insert (%zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
-                      tmpbuf, cs.pos1, !self, int (cs.src_len), cs.src, self);
+                      "%{+} (%zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
+                      cs.pos1, !self, int (cs.src_len), cs.src, self);
         break;
 
     case insert_off_str:
         rw_asnprintf (pbuf, pbufsize, 
-                      "%s.insert (%zu, %{?}string (%{#*s})%{;}%{?}*this%{;})",
-                      tmpbuf, cs.pos1, !self, int (cs.src_len), cs.src, self);
+                      "%{+} (%zu, %{?}string (%{#*s})%{;}%{?}*this%{;})",
+                      cs.pos1, !self, int (cs.src_len), cs.src, self);
         break;
 
     case insert_off_ptr_size:
-        rw_asnprintf (pbuf, pbufsize, "%s.insert ("
+        rw_asnprintf (pbuf, pbufsize, "%{+} ("
                       "%zu, %{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)", 
-                      tmpbuf, cs.pos1, !self, int (cs.src_len), 
+                      cs.pos1, !self, int (cs.src_len),
                       cs.src, self, cs.count);
         break;
 
     case insert_off_str_off_size:
-        rw_asnprintf (pbuf, pbufsize, "%s.insert ("
+        rw_asnprintf (pbuf, pbufsize, "%{+} ("
                       "%zu, %{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
-                      tmpbuf, cs.pos1, !self, int (cs.src_len), cs.src, 
+                      cs.pos1, !self, int (cs.src_len), cs.src,
                       self, cs.pos2, cs.count);
         break;
 
     case insert_off_size_val:
         rw_asnprintf (pbuf, pbufsize, 
-                      "%s.insert (%zu, %zu, %#c)", 
-                      tmpbuf, cs.pos1, cs.count, cs.ch);
+                      "%{+} (%zu, %zu, %#c)",
+                      cs.pos1, cs.count, cs.ch);
         break;
 
     case insert_size_val:
         rw_asnprintf (pbuf, pbufsize, 
-                      "%s.insert (begin + %zu, %zu, %#c)", 
-                      tmpbuf, cs.pos1, cs.count, cs.ch);
+                      "%{+} (begin + %zu, %zu, %#c)",
+                      cs.pos1, cs.count, cs.ch);
         break;
 
     case insert_val:
         rw_asnprintf (pbuf, pbufsize, 
-                      "%s.insert (begin + %zu, %#c)", 
-                      tmpbuf, cs.pos1, cs.ch);
+                      "%{+} (begin + %zu, %#c)",
+                      cs.pos1, cs.ch);
         break;
 
     case insert_range:
-        rw_asnprintf (pbuf, pbufsize, "%s.insert (begin + %zu, "
+        rw_asnprintf (pbuf, pbufsize, "%{+} (begin + %zu, "
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
                       "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)", 
-                      tmpbuf, cs.pos1, !self, int (cs.src_len), cs.src, 
+                      cs.pos1, !self, int (cs.src_len), cs.src,
                       self, cs.pos2, !self, int (cs.src_len), cs.src, 
                       self, cs.pos2 + cs.count);
         break;
     }
-
-    free (tmpbuf);
 }
 
 /**************************************************************************/
# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("\0").insert (0, "a") expected "a\0" with length 2, got 
"abc\0" with length 4
# CLAUSE: lib.string.insert
# LINE: 172

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("\0").insert (0, "a") expected "a\0", got "abc\0", 
difference at pos 1
# CLAUSE: lib.string.insert
# LINE: 172

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("\0").insert (1, "a") expected "\0a" with length 2, got 
"\0abc" with length 4
# CLAUSE: lib.string.insert
# LINE: 173

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (0, "ab") expected "abcde" with length 5, 
got "abccde" with length 6
# CLAUSE: lib.string.insert
# LINE: 177

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (0, "ab") expected "abcde", got "abccde", 
difference at pos 3
# CLAUSE: lib.string.insert
# LINE: 177

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (1, "ab") expected "cabde" with length 5, 
got "cabcde" with length 6
# CLAUSE: lib.string.insert
# LINE: 178

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (1, "ab") expected "cabde", got "cabcde", 
difference at pos 3
# CLAUSE: lib.string.insert
# LINE: 178

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (2, "ab") expected "cdabe" with length 5, 
got "cdabce" with length 6
# CLAUSE: lib.string.insert
# LINE: 179

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (2, "ab") expected "cdabe", got "cdabce", 
difference at pos 4
# CLAUSE: lib.string.insert
# LINE: 179

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("cde").insert (3, "ab") expected "cdeab" with length 5, 
got "cdeabc" with length 6
# CLAUSE: lib.string.insert
# LINE: 180

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, char_traits<char_traits>, 
allocator<char_traits>>("last").insert (4, "test") expected "lasttest" with 
length 8, got { "lasttest", 'x' <repeats 4091 times> } with length 4099
# CLAUSE: lib.string.insert
# LINE: 202

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("\0").insert (0, "a") expected "a\0" with length 2, got 
"abc\0" with length 4
# CLAUSE: lib.string.insert
# LINE: 172

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("\0").insert (0, "a") expected "a\0", got "abc\0", 
difference at pos 1
# CLAUSE: lib.string.insert
# LINE: 172

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("\0").insert (1, "a") expected "\0a" with length 2, got 
"\0abc" with length 4
# CLAUSE: lib.string.insert
# LINE: 173

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (0, "ab") expected "abcde" with length 5, 
got "abccde" with length 6
# CLAUSE: lib.string.insert
# LINE: 177

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (0, "ab") expected "abcde", got "abccde", 
difference at pos 3
# CLAUSE: lib.string.insert
# LINE: 177

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (1, "ab") expected "cabde" with length 5, 
got "cabcde" with length 6
# CLAUSE: lib.string.insert
# LINE: 178

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (1, "ab") expected "cabde", got "cabcde", 
difference at pos 3
# CLAUSE: lib.string.insert
# LINE: 178

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (2, "ab") expected "cdabe" with length 5, 
got "cdabce" with length 6
# CLAUSE: lib.string.insert
# LINE: 179

# ASSERTION (S7) (4 lines):
# TEXT: line 806. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (2, "ab") expected "cdabe", got "cdabce", 
difference at pos 4
# CLAUSE: lib.string.insert
# LINE: 179

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("cde").insert (3, "ab") expected "cdeab" with length 5, 
got "cdeabc" with length 6
# CLAUSE: lib.string.insert
# LINE: 180

# ASSERTION (S7) (4 lines):
# TEXT: line 796. std::basic_string<char, UserTraits<UserTraits>, 
allocator<UserTraits>>("last").insert (4, "test") expected "lasttest" with 
length 8, got { "lasttest", 'x' <repeats 4091 times> } with length 4099
# CLAUSE: lib.string.insert
# LINE: 202

# +-----------------------+--------+--------+--------+
# | DIAGNOSTIC            | ACTIVE |  TOTAL |INACTIVE|
# +-----------------------+--------+--------+--------+
# | (S1) INFO             |     41 |     41 |     0% |
# | (S7) ASSERTION        |     22 |   4280 |    99% |
# +-----------------------+--------+--------+--------+

Reply via email to