Farid Zaripov wrote:
 > -----Original Message-----
 > From: Martin Sebor [mailto:[EMAIL PROTECTED]
 > Sent: Wednesday, July 12, 2006 3:39 AM
 > To: stdcxx-dev@incubator.apache.org
 > Subject: Re: test for lib.string.io
 >
 > With the patch applied I get 120 failed assertions out of the
 > io test, all of them on lines 872 through 886. They all look
 > like they are due to the test expecting failbit for
 > insertions into the stream buffer that fail and the library
 > setting badbit. I think the library does the right thing and
 > the standard needs to be fixed to say that
 > operator<<(ostream&, string) a) is a Formatted Output
 > Function and b) should behave according to the requirements
 > on such functions and thus should set badbit and not failbit
 > when it fails to produce the expected output.

I updated the test (failbit checking is replaced to the badbit checking). The updated diff in attach.

I assume this needs the recent changes to rw_streambuf.h, right?
(They will need to be committed first.)

I made a few trivial formatting changes (please take a look at
them to make sure they make sense to you and follow the same
convention in the future -- thanks :) With the changes I say
go ahead and commit it. The next step will be replacing the
ctype facet with the one in rw_ctype.h.

Martin
--- /build/sebor/stdcxx/tests/strings/21.string.io.cpp  Sun Jul 16 15:01:31 2006
+++ /build/sebor/dev/stdlib/tests/strings/21.string.io.cpp      Sun Jul 16 
15:15:57 2006
@@ -9,8 +9,6 @@
 * 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
@@ -38,7 +36,6 @@
 #include <rw_new.h>       // for bad_alloc, replacement operator new
 #include <rw_streambuf.h> // for MyStreambuf
 
-
 /**************************************************************************/
 
 static const char* const exceptions[] = {
@@ -1079,11 +1076,11 @@
             sbuf.throw_when_ [sbuf.memfun_inx (
                 test_inserter ? Overflow : Underflow) ] = throw_on [throw_inx];
 
-            sbuf.throw_when_ [sbuf.memfun_inx (Xsgetn) ]    = 
+            sbuf.throw_when_ [sbuf.memfun_inx (Xsgetn)] = 
                 throw_count [0];
-            sbuf.throw_when_ [sbuf.memfun_inx (Sync) ]      = 
+            sbuf.throw_when_ [sbuf.memfun_inx (Sync)] = 
                 throw_count [1];
-            sbuf.throw_when_ [sbuf.memfun_inx (Xsputn) ]    = 
+            sbuf.throw_when_ [sbuf.memfun_inx (Xsputn)] = 
                 throw_count [2];
         }
         else {
@@ -1167,17 +1164,18 @@
             catch (std::ios_base::failure& ex) {
                 caught = exceptions [1];
                 rw_assert (caught == expected, 0, tcase.line,
-                        "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
-                        "unexpectedly%{;} caught std::%s(%#s)",
-                        __LINE__, 0 != expected, expected, caught, ex.what ());
+                           "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
+                           "unexpectedly%{;} caught std::%s(%#s)",
+                           __LINE__, 0 != expected, expected, caught,
+                           ex.what ());
 
             }
             catch (...) {
                 caught = exceptions [0];
                 rw_assert (0, 0, tcase.line,
-                        "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
-                        "unexpectedly%{;} caught %s",
-                        __LINE__, 0 != expected, expected, caught);
+                           "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
+                           "unexpectedly%{;} caught %s",
+                           __LINE__, 0 != expected, expected, caught);
             }
 
 #endif   // _RWSTD_NO_EXCEPTIONS
@@ -1221,18 +1219,18 @@
                 // keep
 
                 const std::streamsize width =
-                    (  func.which_ == StringIds::getline_istream_str
+                       func.which_ == StringIds::getline_istream_str
                     || func.which_ == StringIds::getline_istream_str_val
 #ifndef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
-                    || (func.which_ == StringIds::inserter_ostream_cstr
-                       && ret_state != Good)
+                    || func.which_ == StringIds::inserter_ostream_cstr
+                    && ret_state != Good
 #endif  // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
-                    ) ? tcase.off : tcase.val;
+                    ? tcase.off : tcase.val;
 
                 success = width == ret_width;
                 rw_assert (success, 0, tcase.line,
-                    "line %d. %{$FUNCALL}: expected width() == %td, got %td",
-                    __LINE__, width, ret_width);
+                           "line %d. %{$FUNCALL}: expected width() == %td, "
+                           "got %td", __LINE__, width, ret_width);
             }
 
             // tcase.size2 is the expected iostate
@@ -1245,12 +1243,13 @@
                 success = res_state ?
                     (res_state == (ret_state & res_state)) : (0 == ret_state);
                 rw_assert (success, 0, tcase.line,
-                        "line %d. %{$FUNCALL}: expected rdstate() == %{Is}, 
got %{Is}",
-                        __LINE__, res_state, ret_state);
+                           "line %d. %{$FUNCALL}: expected rdstate() "
+                           "== %{Is}, got %{Is}",
+                           __LINE__, res_state, ret_state);
             }
 
-            if (!streambuf_threw ||
-                (Overflow == sbuf.threw_ || Underflow == sbuf.threw_)) {
+            if (   !streambuf_threw
+                || Overflow == sbuf.threw_ || Underflow == sbuf.threw_) {
 
                 size_t res_sz = streambuf_threw ?
                     sbuf.throw_when_ [sbuf.memfun_inx (sbuf.threw_)] - 1 :
@@ -1259,10 +1258,11 @@
                 // verify that strings length are equal
                 success = res_sz == ret_sz;
                 rw_assert (success, 0, tcase.line,
-                        "line %d. %{$FUNCALL}: expected %{/*.*Gs} with length "
-                        "%zu, got %{/*.*Gs} with length %zu", __LINE__, 
-                        cwidth, int (res_sz), tdata.res_, res_sz,
-                        cwidth, int (ret_sz), ret_str, ret_sz);
+                           "line %d. %{$FUNCALL}: expected %{/*.*Gs} with "
+                           "length %zu, got %{/*.*Gs} with length %zu",
+                           __LINE__, 
+                           cwidth, int (res_sz), tdata.res_, res_sz,
+                           cwidth, int (ret_sz), ret_str, ret_sz);
 
                 if (res_sz == ret_sz) {
                     // if the result length matches the expected length
@@ -1272,10 +1272,10 @@
 
                     success = match == res_sz;
                     rw_assert (success, 0, tcase.line,
-                            "line %d. %{$FUNCALL}: expected %{/*.*Gs}, "
-                            "got %{/*.*Gs}, difference at off %zu",
-                            __LINE__, cwidth, int (res_sz), tdata.res_,
-                            cwidth, int (ret_sz), ret_str, match);
+                               "line %d. %{$FUNCALL}: expected %{/*.*Gs}, "
+                               "got %{/*.*Gs}, difference at off %zu",
+                               __LINE__, cwidth, int (res_sz), tdata.res_,
+                               cwidth, int (ret_sz), ret_str, match);
                 }
             }
         }

Reply via email to