summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-13 04:27:18 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-13 04:27:18 +0000
commit604d1418470b1f6a4f0ebd237782edfe90cd4b94 (patch)
tree95a3390381843eee93ddc7a3e11b31bcb09fdf90
parent1da4678b906c74effde204d1edb97c2bf0eac653 (diff)
downloadppe42-gcc-604d1418470b1f6a4f0ebd237782edfe90cd4b94.tar.gz
ppe42-gcc-604d1418470b1f6a4f0ebd237782edfe90cd4b94.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48809 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc4
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_get_members_char.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_put_members_char.cc48
-rw-r--r--libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc45
5 files changed, 100 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ef8625a93b8..56cbc2c6187 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 35873e1f813..396f4236c4c 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -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;
diff --git a/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc b/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc
index 5b0892dd748..5e30ac75b99 100644
--- a/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_get_members_char.cc
@@ -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;
diff --git a/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc b/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc
index c0f8d1eb243..3c318cec211 100644
--- a/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc
@@ -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;
}
+
diff --git a/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc
index b592e4f24eb..36dde8ceef4 100644
--- a/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc
+++ b/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc
@@ -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;
}
OpenPOWER on IntegriCloud