diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-18 19:28:40 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-18 19:28:40 +0000 |
commit | d0c236445deccdb5271a245b6a44128dae366772 (patch) | |
tree | c2d965f605e2cc49ed79113b10c1508656af5be1 /libstdc++-v3/testsuite/22_locale | |
parent | 17b28e52019eff5c40389d7c25d6da967bb6f8c9 (diff) | |
download | gcc-d0c236445deccdb5271a245b6a44128dae366772.tar.gz |
2009-04-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/39802
* include/bits/locale_facets.tcc (num_get<>::_M_extract_int
(_InIter, _InIter, ios_base&, ios_base::iostate&, _ValueT&)):
Always accept negative values, for unsigned types too.
* testsuite/22_locale/num_get/get/char/39802.cc: New.
* testsuite/22_locale/num_get/get/wchar_t/39802.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146323 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_get/get/char/39802.cc | 77 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/39802.cc | 77 |
2 files changed, 154 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/39802.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/39802.cc new file mode 100644 index 00000000000..b31050895a5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/39802.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 22.2.2.1.1 num_get members + +#include <locale> +#include <sstream> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/39802 +void test01() +{ + using namespace std; + typedef istreambuf_iterator<char> iterator_type; + + bool test __attribute__((unused)) = true; + + stringstream ss; + const num_get<char>& ng = use_facet<num_get<char> >(ss.getloc()); + ios_base::iostate err; + iterator_type end; + const string empty; + + unsigned long ul0 = 1; + const unsigned long ul1 = numeric_limits<unsigned long>::max(); + + ss << "-0"; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == 0 ); + + ss.clear(); + ss.str(empty); + ss << "-1"; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == ul1 ); + + ss.clear(); + ss.str(empty); + ss << '-' << ul1; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == 1 ); + + ss.clear(); + ss.str(empty); + ss << '-' << ul1 << '0'; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == (ios_base::eofbit | ios_base::failbit) ); + VERIFY( ul0 == ul1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/39802.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/39802.cc new file mode 100644 index 00000000000..67138d1dac5 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/39802.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 22.2.2.1.1 num_get members + +#include <locale> +#include <sstream> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/39802 +void test01() +{ + using namespace std; + typedef istreambuf_iterator<wchar_t> iterator_type; + + bool test __attribute__((unused)) = true; + + wstringstream ss; + const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(ss.getloc()); + ios_base::iostate err; + iterator_type end; + const wstring empty; + + unsigned long ul0 = 1; + const unsigned long ul1 = numeric_limits<unsigned long>::max(); + + ss << L"-0"; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == 0 ); + + ss.clear(); + ss.str(empty); + ss << L"-1"; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == ul1 ); + + ss.clear(); + ss.str(empty); + ss << L'-' << ul1; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == ios_base::eofbit ); + VERIFY( ul0 == 1 ); + + ss.clear(); + ss.str(empty); + ss << L'-' << ul1 << L'0'; + err = ios_base::goodbit; + end = ng.get(ss.rdbuf(), 0, ss, err, ul0); + VERIFY( err == (ios_base::eofbit | ios_base::failbit) ); + VERIFY( ul0 == ul1 ); +} + +int main() +{ + test01(); + return 0; +} |