locale_facets.tcc (money_put::do_put(string): Correct output iterator value.

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.

From-SVN: r48809
This commit is contained in:
Benjamin Kosnik 2002-01-13 04:27:18 +00:00 committed by Benjamin Kosnik
parent 38b29e6477
commit ae72572be9
5 changed files with 100 additions and 6 deletions

View 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

View 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;

View 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;

View 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;
}

View 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;
}