aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/22_locale/num_get
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2003-12-19 09:35:24 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2003-12-19 09:35:24 +0000
commit1b4513069a1ba56abff09f27977da3d10ffcd7f3 (patch)
tree85a14266411b4a664f0e48d4aec9dde4fee5d49f /libstdc++-v3/testsuite/22_locale/num_get
parented8d88031c395a0029393904e44afe077d7a5b93 (diff)
downloadgcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.zip
gcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.tar.gz
gcc-1b4513069a1ba56abff09f27977da3d10ffcd7f3.tar.bz2
locale_facets.tcc (num_get::_M_extract_float): When __found_sci becomes true stop eating thousands separators and the decimal...
2003-12-19 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (num_get::_M_extract_float): When __found_sci becomes true stop eating thousands separators and the decimal radix separator. * testsuite/22_locale/num_get/get/char/9.cc: New. * testsuite/22_locale/num_get/get/wchar_t/9.cc: Likewise. * config/locale/generic/c_locale.cc (__convert_to_v): Don't check that *__sanity == '\0': parsing may stop earlier, still be successful. * config/locale/gnu/c_locale.cc: Likewise. * testsuite/22_locale/num_get/get/char/10.cc: New. * testsuite/22_locale/num_get/get/wchar_t/10.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc: Tweak in one place accordingly. * testsuite/22_locale/money_get/get/char/1.cc: Fix typo. * testsuite/22_locale/money_get/get/wchar_t/1.cc: Likewise. From-SVN: r74826
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/num_get')
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc72
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc65
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc72
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc65
4 files changed, 274 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
new file mode 100644
index 0000000..259dea9
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/10.cc
@@ -0,0 +1,72 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 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.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ istringstream iss;
+ const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ float f = 0.0f;
+ double d = 0.0;
+ long double ld = 0.0l;
+ float f1 = 1.0f;
+ double d1 = 3.0;
+ long double ld1 = 6.0l;
+
+ iss.str("1e.");
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, f);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == '.' );
+ VERIFY( f == f1 );
+
+ iss.str("3e+");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d1 );
+
+ iss.str("6e ");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, ld);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == ' ' );
+ VERIFY( ld == ld1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
new file mode 100644
index 0000000..5934b61
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/9.cc
@@ -0,0 +1,65 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 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.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ istringstream iss;
+ iss.imbue(loc_de);
+
+ const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ double d = 0.0;
+ double d1 = 1e1;
+ double d2 = 3e1;
+
+ iss.str("1e1,");
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == ',' );
+ VERIFY( d == d1 );
+
+ iss.str("3e1.");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == '.' );
+ VERIFY( d == d2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
new file mode 100644
index 0000000..85fa574
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/10.cc
@@ -0,0 +1,72 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 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.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ wistringstream iss;
+ const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ float f = 0.0f;
+ double d = 0.0;
+ long double ld = 0.0l;
+ float f1 = 1.0f;
+ double d1 = 3.0;
+ long double ld1 = 6.0l;
+
+ iss.str(L"1e.");
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, f);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L'.' );
+ VERIFY( f == f1 );
+
+ iss.str(L"3e+");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d1 );
+
+ iss.str(L"6e ");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, ld);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L' ' );
+ VERIFY( ld == ld1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
new file mode 100644
index 0000000..df3db53
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/9.cc
@@ -0,0 +1,65 @@
+// 2003-12-19 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2003 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.1.1 num_get members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ wistringstream iss;
+ iss.imbue(loc_de);
+
+ const num_get<wchar_t>& ng = use_facet<num_get<wchar_t> >(iss.getloc());
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ double d = 0.0;
+ double d1 = 1e1;
+ double d2 = 3e1;
+
+ iss.str(L"1e1,");
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L',' );
+ VERIFY( d == d1 );
+
+ iss.str(L"3e1.");
+ iss.clear();
+ err = ios_base::goodbit;
+ end = ng.get(iss.rdbuf(), 0, iss, err, d);
+ VERIFY( err == ios_base::goodbit );
+ VERIFY( *end == L'.' );
+ VERIFY( d == d2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}