diff options
author | Paolo Carlini <pcarlini@suse.de> | 2005-07-11 09:48:31 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2005-07-11 09:48:31 +0000 |
commit | 8637038aa8da786fcb53e8192cf9dac20bc62ed5 (patch) | |
tree | 6343aca46f182bb041925af7a81b63923d2157c7 /libstdc++-v3/testsuite | |
parent | 1f97667f30ad19585986527b282e4ae0d1b3a1a3 (diff) | |
download | gcc-8637038aa8da786fcb53e8192cf9dac20bc62ed5.zip gcc-8637038aa8da786fcb53e8192cf9dac20bc62ed5.tar.gz gcc-8637038aa8da786fcb53e8192cf9dac20bc62ed5.tar.bz2 |
ostream.tcc (basic_ostream<>::operator<<(long), [...]): Don't deal with oct and hex and casts to unsigned here...
2005-07-11 Paolo Carlini <pcarlini@suse.de>
* include/bits/ostream.tcc (basic_ostream<>::operator<<(long),
basic_ostream<>::operator<<(long long)): Don't deal with oct
and hex and casts to unsigned here...
* include/bits/locale_facets.tcc (__int_to_char(_CharT*, long,
const _CharT*, ios_base::fmtflags), __int_to_char(_CharT*, long
long, const _CharT*, ios_base::fmtflags)): ... do that here,
instead, as per Table 57.
(num_put<>::_M_insert_int): Tidy treatment of numeric base and
sign.
* include/std/std_ostream.h (operator<<(short), operator<<(int)):
Adjust logic, as per the letter of the resolution of DR117 [WP].
* testsuite/22_locale/num_put/put/char/10.cc: New.
* testsuite/22_locale/num_put/put/wchar_t/10.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc:
Likewise.
* testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc:
Likewise.
From-SVN: r101872
Diffstat (limited to 'libstdc++-v3/testsuite')
4 files changed, 272 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc new file mode 100644 index 0000000..97c5712 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc @@ -0,0 +1,68 @@ +// 2005-07-11 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.2.2.1 num_put members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale loc_c = locale::classic(); + + const string empty; + + stringstream ss; + ss.imbue(loc_c); + const num_put<char>& np = use_facet<num_put<char> >(ss.getloc()); + + long l = -1; + unsigned long ul = 0; + + ss.setf(ios::hex, ios::basefield); + np.put(ss.rdbuf(), ss, '+', l); + VERIFY( ss.str() != "1" ); + ss >> ul; + VERIFY( ul == static_cast<unsigned long>(l) ); + +#ifdef _GLIBCXX_USE_LONG_LONG + long long ll = -1LL; + unsigned long long ull = 0ULL; + + ss.str(empty); + ss.clear(); + np.put(ss.rdbuf(), ss, '+', ll); + VERIFY( ss.str() != "1" ); + ss >> ull; + VERIFY( ull == static_cast<unsigned long long>(ll) ); +#endif +} + +int main() +{ + test01(); + return 0; +} + + diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc new file mode 100644 index 0000000..2e9243c --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc @@ -0,0 +1,68 @@ +// 2005-07-11 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.2.2.1 num_put members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale loc_c = locale::classic(); + + const wstring empty; + + wstringstream ss; + ss.imbue(loc_c); + const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(ss.getloc()); + + long l = -1; + unsigned long ul = 0; + + ss.setf(ios::hex, ios::basefield); + np.put(ss.rdbuf(), ss, L'+', l); + VERIFY( ss.str() != L"1" ); + ss >> ul; + VERIFY( ul == static_cast<unsigned long>(l) ); + +#ifdef _GLIBCXX_USE_LONG_LONG + long long ll = -1LL; + unsigned long long ull = 0ULL; + + ss.str(empty); + ss.clear(); + np.put(ss.rdbuf(), ss, L'+', ll); + VERIFY( ss.str() != L"1" ); + ss >> ull; + VERIFY( ull == static_cast<unsigned long long>(ll) ); +#endif +} + +int main() +{ + test01(); + return 0; +} + + diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc new file mode 100644 index 0000000..4382473 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc @@ -0,0 +1,68 @@ +// 2005-07-11 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.6.2.5.2 Arithmetic inserters + +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + stringstream ostr1, ostr2, ostr3, ostr4; + + ostr1.setf(ios_base::oct); + ostr1.setf(ios_base::hex); + + short s = -1; + ostr1 << s; + VERIFY( ostr1.str() == "-1" ); + + ostr2.setf(ios_base::oct); + ostr2.setf(ios_base::hex); + + int i = -1; + ostr2 << i; + VERIFY( ostr2.str() == "-1" ); + + ostr3.setf(ios_base::oct); + ostr3.setf(ios_base::hex); + + long l = -1; + ostr3 << l; + VERIFY( ostr3.str() == "-1" ); + +#ifdef _GLIBCXX_USE_LONG_LONG + ostr4.setf(ios_base::oct); + ostr4.setf(ios_base::hex); + + long long ll = -1LL; + ostr4 << ll; + VERIFY( ostr4.str() == "-1" ); +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc new file mode 100644 index 0000000..87013e7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc @@ -0,0 +1,68 @@ +// 2005-07-11 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.6.2.5.2 Arithmetic inserters + +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstringstream ostr1, ostr2, ostr3, ostr4; + + ostr1.setf(ios_base::oct); + ostr1.setf(ios_base::hex); + + short s = -1; + ostr1 << s; + VERIFY( ostr1.str() == L"-1" ); + + ostr2.setf(ios_base::oct); + ostr2.setf(ios_base::hex); + + int i = -1; + ostr2 << i; + VERIFY( ostr2.str() == L"-1" ); + + ostr3.setf(ios_base::oct); + ostr3.setf(ios_base::hex); + + long l = -1; + ostr3 << l; + VERIFY( ostr3.str() == L"-1" ); + +#ifdef _GLIBCXX_USE_LONG_LONG + ostr4.setf(ios_base::oct); + ostr4.setf(ios_base::hex); + + long long ll = -1LL; + ostr4 << ll; + VERIFY( ostr4.str() == L"-1" ); +#endif +} + +int main() +{ + test01(); + return 0; +} |