OSDN Git Service

2002-01-12 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Jan 2002 04:27:18 +0000 (04:27 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Jan 2002 04:27:18 +0000 (04:27 +0000)
* include/bits/locale_facets.tcc (money_put::do_put(string):
Correct output iterator value.
* testsuite/22_locale/money_put_members_char.cc (test03): Add.
* testsuite/22_locale/money_put_members_wchar_t.cc: Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48809 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/testsuite/22_locale/money_get_members_char.cc
libstdc++-v3/testsuite/22_locale/money_put_members_char.cc
libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc

index ef8625a..56cbc2c 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-12  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/locale_facets.tcc (money_put::do_put(string):
+       Correct output iterator value.
+       * testsuite/22_locale/money_put_members_char.cc (test03): Add.
+       * testsuite/22_locale/money_put_members_wchar_t.cc: Same.
+       
 2002-01-11  Phil Edwards  <pme@gcc.gnu.org>
 
        * include/Makefile.am, include/Makefile.in (stamp-std):  Fix typo from
index 35873e1..396f423 100644 (file)
@@ -1415,8 +1415,8 @@ namespace std
            }
 
          // Write resulting, fully-formatted string to output iterator.
-         for (size_type __j = 0; __j < __len; ++__j)
-           __s = __res[__j];
+         for (size_type __j = 0; __j < __len; ++__j, ++__s)
+           *__s = __res[__j];
        }
       __io.width(0);
       return __s; 
index 5b0892d..5e30ac7 100644 (file)
@@ -255,7 +255,7 @@ void test03()
   bool test = true;
 
   // Check money_get works with other iterators besides streambuf
-  // output iterators.
+  // input iterators.
   typedef string::const_iterator iter_type;
   typedef money_get<char, iter_type> mon_get_type;
   const ios_base::iostate goodbit = ios_base::goodbit;
index c0f8d1e..3c318ce 100644 (file)
@@ -1,6 +1,6 @@
 // 2001-08-27 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001-2002 Free Software Foundation
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -161,7 +161,7 @@ void test01()
   VERIFY( result11 == "-,01****************");
 }
 
-// test double/string versions
+// test double version
 void test02()
 {
   using namespace std;
@@ -241,9 +241,53 @@ void test02()
   VERIFY( result4 != result2 );
 }
 
+void test03()
+{
+  using namespace std;
+  bool test = true;
+
+  // Check money_put works with other iterators besides streambuf
+  // output iterators. (As long as output_iterator requirements are met.)
+  typedef string::iterator iter_type;
+  typedef money_put<char, iter_type> mon_put_type;
+  const ios_base::iostate goodbit = ios_base::goodbit;
+  const ios_base::iostate eofbit = ios_base::eofbit;
+  ios_base::iostate err = goodbit;
+  const locale loc_c = locale::classic();
+  // woman, art, thief (stole the blues)
+  const string str("1943 Janis Joplin");
+  const long double ld = 1943;
+  const string x(str.size(), 'x'); // have to have allocated string!
+  string res;
+
+  ostringstream oss; 
+  oss.imbue(locale(loc_c, new mon_put_type));
+
+  // Iterator advanced, state, output.
+  const mon_put_type& mp = use_facet<mon_put_type>(oss.getloc());
+
+  // 01 string
+  res = x;
+  iter_type ret1 = mp.put(res.begin(), false, oss, ' ', str);
+  string sanity1(res.begin(), ret1);
+  VERIFY( err == goodbit );
+  VERIFY( res == "1943xxxxxxxxxxxxx" );
+  VERIFY( sanity1 == "1943" );
+
+  // 02 long double
+  res = x;
+  iter_type ret2 = mp.put(res.begin(), false, oss, ' ', ld);
+  string sanity2(res.begin(), ret2);
+  VERIFY( err == goodbit );
+  VERIFY( res == "1943xxxxxxxxxxxxx" );
+  VERIFY( sanity2 == "1943" );
+}
+
 int main()
 {
   test01();
   test02();
+  test03();
   return 0;
 }
+
index b592e4f..36dde8c 100644 (file)
@@ -1,6 +1,6 @@
 // 2001-09-09 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001-2002 Free Software Foundation
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -240,6 +240,48 @@ void test02()
   VERIFY( result3 != result1 );
   VERIFY( result4 != result2 );
 }
+
+void test03()
+{
+  using namespace std;
+  bool test = true;
+
+  // Check money_put works with other iterators besides streambuf
+  // output iterators. (As long as output_iterator requirements are met.)
+  typedef wstring::iterator iter_type;
+  typedef money_put<wchar_t, iter_type> mon_put_type;
+  const ios_base::iostate goodbit = ios_base::goodbit;
+  const ios_base::iostate eofbit = ios_base::eofbit;
+  ios_base::iostate err = goodbit;
+  const locale loc_c = locale::classic();
+  // woman, art, thief (stole the blues)
+  const wstring str(L"1943 Janis Joplin");
+  const long double ld = 1943;
+  const wstring x(str.size(), 'x'); // have to have allocated string!
+  wstring res;
+
+  wostringstream oss; 
+  oss.imbue(locale(loc_c, new mon_put_type));
+
+  // Iterator advanced, state, output.
+  const mon_put_type& mp = use_facet<mon_put_type>(oss.getloc());
+
+  // 01 string
+  res = x;
+  iter_type ret1 = mp.put(res.begin(), false, oss, ' ', str);
+  wstring sanity1(res.begin(), ret1);
+  VERIFY( err == goodbit );
+  VERIFY( res == L"1943xxxxxxxxxxxxx" );
+  VERIFY( sanity1 == L"1943" );
+
+  // 02 long double
+  res = x;
+  iter_type ret2 = mp.put(res.begin(), false, oss, ' ', ld);
+  wstring sanity2(res.begin(), ret2);
+  VERIFY( err == goodbit );
+  VERIFY( res == L"1943xxxxxxxxxxxxx" );
+  VERIFY( sanity2 == L"1943" );
+}
 #endif
 
 int main()
@@ -247,6 +289,7 @@ int main()
 #ifdef _GLIBCPP_USE_WCHAR_T
   test01();
   test02();
+  test03();
 #endif
   return 0;
 }